bootleg 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,6 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'nokogiri'
4
4
  gem 'mechanize'
5
+ gem 'rspec'
5
6
 
6
7
  # Specify your gem's dependencies in bootleg.gemspec
7
8
 
@@ -1,3 +1,3 @@
1
1
  module Bootleg
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -2,7 +2,7 @@ require_relative 'modules/zipcode'
2
2
  require_relative 'modules/href'
3
3
 
4
4
  class Finder
5
- def initialize(zipcode = '20906')
5
+ def initialize(zipcode)
6
6
  zipcode.extend Zipcode
7
7
  @href = zipcode.search
8
8
  end
@@ -1,10 +1,6 @@
1
1
  require_relative 'movie'
2
2
 
3
3
  module Theater
4
- def details
5
- self.css('h3.title').css('a')
6
- end
7
-
8
4
  def name
9
5
  details.text.strip
10
6
  end
@@ -23,4 +19,9 @@ module Theater
23
19
  end
24
20
  values
25
21
  end
22
+
23
+ private
24
+ def details
25
+ self.css('h3.title').css('a')
26
+ end
26
27
  end
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe Extractor do
4
+ it "should raise an error withouth arguments" do
5
+ expect{ Extractor.new }.to raise_error(ArgumentError)
6
+ end
7
+
8
+ it "should not raise error with one argument" do
9
+ expect { Extractor.new("http://www.moviefone.com")}.to_not raise_error(ArgumentError)
10
+ end
11
+
12
+ it "should raise an error with more then one argument" do
13
+ expect { Extractor.new("arg1", "arg2") }.to raise_error(ArgumentError)
14
+ end
15
+
16
+ before :all do
17
+ @theaters = Extractor.new("http://www.moviefone.com/showtimes/manchester-md/21102/theaters").page_theaters
18
+ end
19
+
20
+ it "should pull out no more then 5 theaters" do
21
+ @theaters.size.should eq(5)
22
+ end
23
+
24
+ describe Theater do
25
+ before :all do
26
+ @theater = @theaters[1]
27
+ end
28
+
29
+ it "name should match expression" do
30
+ expect(@theater[:name]).to match(/(\w|\s)/)
31
+ end
32
+
33
+ it "href should be a link" do
34
+ expect(@theater[:href]).to match(/http:\/\/www\.moviefone\.com/)
35
+ end
36
+
37
+ describe Movie do
38
+
39
+ before :all do
40
+ @movie = @theater[:movies].first
41
+ end
42
+ it "should have a name, href and showtimes" do
43
+ expect(@movie.size).to eq(3)
44
+ end
45
+
46
+ it "name should match expression" do
47
+ expect(@movie[:name]).to match(/(\w|\s)/)
48
+ end
49
+
50
+ it "href shoud mathc expression" do
51
+ expect(@movie[:href]).to match(/http:\/\/www\.moviefone\.com/)
52
+ end
53
+
54
+ it "shotimes returns an array" do
55
+ expect(@movie[:showtimes].class).to be(Array)
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Finder do
4
+ it "should raise an error with no arguments" do
5
+ expect { Finder.new }.to raise_error(ArgumentError)
6
+ end
7
+
8
+ it "should not raise error with one argument" do
9
+ expect { Finder.new("smth") }.to_not raise_error(ArgumentError)
10
+ end
11
+
12
+ it "should raise an error with more then one arguments" do
13
+ expect { Finder.new("smth", "smthelse") }.to raise_error(ArgumentError)
14
+ end
15
+
16
+
17
+ describe Href do
18
+ before :all do
19
+ @hrefs = Finder.new('21102').hrefs
20
+ end
21
+
22
+ it "should have a size of 3" do
23
+ expect(@hrefs.size).to eq(3)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Presenter do
4
+ it "should not work" do
5
+ pending 'to be continued...'
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'bootleg'
5
+
6
+ RSpec.configure do |config|
7
+ #optional
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootleg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-09 00:00:00.000000000 Z
12
+ date: 2012-11-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -84,6 +84,11 @@ files:
84
84
  - lib/modules/theater.rb
85
85
  - lib/modules/zipcode.rb
86
86
  - lib/presenter.rb
87
+ - spec/.rspec
88
+ - spec/extractor_spec.rb
89
+ - spec/finder_spec.rb
90
+ - spec/presenter_spec.rb
91
+ - spec/spec_helper.rb
87
92
  homepage: ''
88
93
  licenses: []
89
94
  post_install_message:
@@ -108,4 +113,9 @@ rubygems_version: 1.8.24
108
113
  signing_key:
109
114
  specification_version: 3
110
115
  summary: ! '...comming soon...'
111
- test_files: []
116
+ test_files:
117
+ - spec/.rspec
118
+ - spec/extractor_spec.rb
119
+ - spec/finder_spec.rb
120
+ - spec/presenter_spec.rb
121
+ - spec/spec_helper.rb