Permalink
Browse files

Features and steps added

  • Loading branch information...
1 parent 9a68400 commit a219c91dba86abd0469e8887dcdf3daf36235869 @jcarlosgarcia committed Feb 10, 2013
Showing with 55 additions and 17 deletions.
  1. +18 −2 features/filter_movie_list.feature
  2. +6 −1 features/sort_movie_list.feature
  3. +31 −14 features/step_definitions/movie_steps.rb
@@ -23,13 +23,29 @@ Background: movies have been added to database
Scenario: restrict to movies with 'PG' or 'R' ratings
# enter step(s) to check the 'PG' and 'R' checkboxes
+ When I check the following ratings: PG, R
# enter step(s) to uncheck all other checkboxes
+ When I uncheck the following ratings: G, PG-13, NC-17
# enter step to "submit" the search form on the homepage
+ And I press "ratings_submit"
# enter step(s) to ensure that PG and R movies are visible
+ Then I should see "The Terminator"
+ And I should see "When Harry Met Sally"
+ And I should see "Amelie"
+ And I should see "The Incredibles"
+ And I should see "Raiders of the Lost Ark"
# enter step(s) to ensure that other movies are not visible
+ And I should not see "Chicken Run"
+ And I should not see "2001: A Space Odyssey"
+ And I should not see "The Help"
+ And I should not see "Chocolat"
Scenario: no ratings selected
- # see assignment
+ When I uncheck the following ratings: G, PG, PG-13, NC-17, R
+ And I press "ratings_submit"
+ Then I should see none of the movies
Scenario: all ratings selected
- # see assignment
+ When I check the following ratings: G, PG, PG-13, NC-17, R
+ And I press "ratings_submit"
+ Then I should see all of the movies
@@ -20,12 +20,17 @@ Background: movies have been added to database
| Chicken Run | G | 21-Jun-2000 |
And I am on the RottenPotatoes home page
+ And I check the following ratings: G, PG, PG-13, NC-17, R
+ And I press "ratings_submit"
Scenario: sort movies alphabetically
When I follow "Movie Title"
- # your steps here
+ Then I should see "Amelie" before "Chocolat"
+ And I should see "Chicken Run" before "The Terminator"
Scenario: sort movies in increasing order of release date
When I follow "Release Date"
+ Then I should see "Raiders of the Lost Ark" before "Chicken Run"
+ And I should see "Amelie" before "The Incredibles"
# your steps here
@@ -1,28 +1,45 @@
# Add a declarative step here for populating the DB with movies.
-
+#
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.
- end
- flunk "Unimplemented"
+ 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
-# on the same page
+# on the same page
Then /I should see "(.*)" before "(.*)"/ do |e1, e2|
- # ensure that that e1 occurs before e2.
- # page.body is the entire content of the page as a string.
- flunk "Unimplemented"
+ # ensure that that e1 occurs before e2.
+ # page.body is the entire content of the page as a string.
+ assert page.body =~ /#{e1}.*#{e2}/m
+ # flunk "Unimplemented"
end
# Make it easier to express checking or unchecking several boxes at once
-# "When I uncheck the following ratings: PG, G, R"
-# "When I check the following ratings: G"
+# "When I uncheck the following ratings: PG, G, R"
+# "When I check the following ratings: G"
When /I (un)?check the following ratings: (.*)/ do |uncheck, rating_list|
# 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
+ # iterate over the ratings and reuse the "When I check..." or
+ # "When I uncheck..." steps in lines 89-95 of web_steps.rb
+ ratings = rating_list.split(", ")
+ ratings.each do |rating|
+ if uncheck then
+ uncheck("ratings_#{rating}")
+ else
+ check("ratings_#{rating}")
+ end
+ end
end
+
+Then /I should see (all|none) of the movies/ do |filter|
+ total_movies = 0
+ total_movies = Movie.count() if filter == 'all'
+ assert total_movies == page.all("#movies tr").size - 1
+end
+

0 comments on commit a219c91

Please sign in to comment.