forked from mlpinit/bootleg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextractor_spec.rb
59 lines (46 loc) · 1.48 KB
/
extractor_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require 'spec_helper'
describe Extractor do
it "should raise an error withouth arguments" do
expect{ Extractor.new }.to raise_error(ArgumentError)
end
it "should not raise error with one argument" do
expect { Extractor.new("http://www.moviefone.com")}.to_not raise_error(ArgumentError)
end
it "should raise an error with more then one argument" do
expect { Extractor.new("arg1", "arg2") }.to raise_error(ArgumentError)
end
before :all do
@theaters = Extractor.new("http://www.moviefone.com/showtimes/manchester-md/21102/theaters").page_theaters
end
it "should pull out no more then 5 theaters" do
@theaters.size.should eq(5)
end
describe Theater do
before :all do
@theater = @theaters[1]
end
it "name should match expression" do
expect(@theater[:name]).to match(/(\w|\s)/)
end
it "href should be a link" do
expect(@theater[:href]).to match(/http:\/\/www\.moviefone\.com/)
end
describe Movie do
before :all do
@movie = @theater[:movies].first
end
it "should have a name, href and showtimes" do
expect(@movie.size).to eq(3)
end
it "name should match expression" do
expect(@movie[:name]).to match(/(\w|\s)/)
end
it "href shoud mathc expression" do
expect(@movie[:href]).to match(/http:\/\/www\.moviefone\.com/)
end
it "shotimes returns an array" do
expect(@movie[:showtimes].class).to be(Array)
end
end
end
end