Skip to content

Commit

Permalink
added tests -better late then never
Browse files Browse the repository at this point in the history
  • Loading branch information
mlpinit committed Nov 11, 2012
1 parent d23453f commit 724a8d0
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
2 changes: 2 additions & 0 deletions spec/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--format documentation
59 changes: 59 additions & 0 deletions spec/extractor_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
26 changes: 26 additions & 0 deletions spec/finder_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'spec_helper'

describe Finder do
it "should raise an error with no arguments" do
expect { Finder.new }.to raise_error(ArgumentError)
end

it "should not raise error with one argument" do
expect { Finder.new("smth") }.to_not raise_error(ArgumentError)
end

it "should raise an error with more then one arguments" do
expect { Finder.new("smth", "smthelse") }.to raise_error(ArgumentError)
end


describe Href do
before :all do
@hrefs = Finder.new('21102').hrefs
end

it "should have a size of 3" do
expect(@hrefs.size).to eq(3)
end
end
end
7 changes: 7 additions & 0 deletions spec/presenter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'spec_helper'

describe Presenter do
it "should not work" do
pending 'to be continued...'
end
end
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'rubygems'
require 'bundler/setup'

require 'bootleg'

RSpec.configure do |config|
#optional
end

0 comments on commit 724a8d0

Please sign in to comment.