Skip to content

Commit

Permalink
in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeBlyth committed Oct 25, 2012
1 parent d064cbd commit 988ceae
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ group :development, :test do
gem 'launchy'
end
group :test do
gem 'rspec'
gem 'rspec-rails'
# gem 'spork', '~> 1.0rc3'
gem 'cucumber-rails'
gem 'cucumber-rails-training-wheels'
gem 'pry'
gem 'pry-rails'
end
group :production do
# gem 'pg'
Expand Down
26 changes: 26 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ GEM
xpath (~> 0.1.4)
childprocess (0.3.5)
ffi (~> 1.0, >= 1.0.6)
coderay (1.0.8)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0)
Expand Down Expand Up @@ -89,10 +90,17 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.8)
mime-types (1.19)
multi_json (1.3.6)
nokogiri (1.5.5)
polyglot (0.3.3)
pry (0.9.10)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.3.1)
pry-rails (0.2.2)
pry (>= 0.9.10)
rack (1.3.6)
rack-cache (1.0.3)
rack (>= 0.4)
Expand Down Expand Up @@ -120,6 +128,19 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
rspec (2.11.0)
rspec-core (~> 2.11.0)
rspec-expectations (~> 2.11.0)
rspec-mocks (~> 2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.3)
rspec-rails (2.11.4)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.11.0)
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
Expand All @@ -142,6 +163,7 @@ GEM
libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
slop (3.3.3)
sprockets (2.0.4)
hike (~> 1.2)
rack (~> 1.0)
Expand Down Expand Up @@ -173,7 +195,11 @@ DEPENDENCIES
haml
jquery-rails
launchy
pry
pry-rails
rails (= 3.1.0)
rspec
rspec-rails
ruby-debug19
sass-rails (~> 3.1.0)
sqlite3
Expand Down
10 changes: 5 additions & 5 deletions features/filter_movie_list.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Background: movies have been added to database
And I am on the RottenPotatoes home page

Scenario: restrict to movies with 'PG' or 'R' ratings
# enter step(s) to check the 'PG' and 'R' checkboxes
# enter step(s) to uncheck all other checkboxes
# enter step to "submit" the search form on the homepage
# enter step(s) to ensure that PG and R movies are visible
# enter step(s) to ensure that other movies are not visible
Given I check the following ratings: PG, R
And I uncheck the following ratings: G, PG-13, NC-17
When I press "Refresh"
Then I should see all the movies with ratings: PG, R
And I should see no movies with ratings: G, PG-13, NC-17

Scenario: no ratings selected
# see assignment
Expand Down
2 changes: 2 additions & 0 deletions features/sort_movie_list.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ Background: movies have been added to database
And I am on the RottenPotatoes home page

Scenario: sort movies alphabetically
Given I uncheck the following ratings: G, PG, R, NC-17
When I follow "Movie Title"
Then I should see all of the movies
# your steps here

Scenario: sort movies in increasing order of release date
Expand Down
35 changes: 34 additions & 1 deletion features/step_definitions/movie_steps.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Add a declarative step here for populating the DB with movies.

def extract_movies
movie_array = page.html.scan(/<tr>\s?<td>(.*?)<\/td>\s?<td>(.*?)<\/td>/m)
return movie_array
end

def parse_ratings(rating_list)
ratings = rating_list.split(/[,;]\s*|\s+/)
end

Given /the following movies exist/ do |movies_table|
movies_table.hashes.each do |movie|
# each returned element will be a hash whose key is the table header.
# you should arrange to add that movie to the database here.
Movie.create(movie)
end
flunk "Unimplemented"
end

# Make sure that one string (regexp) occurs before or after another one
Expand All @@ -25,4 +34,28 @@
# HINT: use String#split to split up the rating_list, then
# iterate over the ratings and reuse the "When I check..." or
# "When I uncheck..." steps in lines 89-95 of web_steps.rb
ratings = parse_ratings(rating_list)
if uncheck
ratings.each {|r| uncheck "ratings_"+r}
else
ratings.each {|r| check "ratings_"+r}
end
#save_and_open_page
end

Then /^I should see all of the movies$/ do
page.should have_xpath(".//*[@id='movies']/tbody/tr[#{Movie.count+1}]")
end

Then /^I should see all the movies with ratings: (.*)/ do |rating_list|
ratings = parse_ratings(rating_list)
extract_movies.map{|movie| movie[0]}.sort.should ==
Movie.where("rating in (?)", ratings).select(:title).map{|m| m.title}.sort
end

Then /^I should see no movies with ratings: (.*)/ do |rating_list|
ratings = parse_ratings(rating_list)
unselected = Movie.where("rating in (?)", ratings).select(:title).map{|m| m.title}
extract_movies.each{|movie| unselected.should_not include(movie[0]) }
end

0 comments on commit 988ceae

Please sign in to comment.