-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cucumber steps to test for movie sorting based on title and relea…
…se date
- Loading branch information
Oliver Martell
committed
Apr 3, 2012
1 parent
45839b7
commit 3abb45c
Showing
16 changed files
with
570 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Feature: display list of movies filtered by MPAA rating | ||
|
||
As a concerned parent | ||
So that I can quickly browse movies appropriate for my family | ||
I want to see movies matching only certain MPAA ratings | ||
|
||
Background: movies have been added to database | ||
|
||
Given the following movies exist: | ||
| title | rating | release_date | | ||
| Aladdin | G | 25-Nov-1992 | | ||
| The Terminator | R | 26-Oct-1984 | | ||
| When Harry Met Sally | R | 21-Jul-1989 | | ||
| The Help | PG-13 | 10-Aug-2011 | | ||
| Chocolat | PG-13 | 5-Jan-2001 | | ||
| Amelie | R | 25-Apr-2001 | | ||
| 2001: A Space Odyssey | G | 6-Apr-1968 | | ||
| The Incredibles | PG | 5-Nov-2004 | | ||
| Raiders of the Lost Ark | PG | 12-Jun-1981 | | ||
| Chicken Run | G | 21-Jun-2000 | | ||
|
||
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 | ||
|
||
Scenario: no ratings selected | ||
# see assignment | ||
|
||
Scenario: all ratings selected | ||
# see assignment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Feature: display list of movies sorted by different criteria | ||
|
||
As an avid moviegoer | ||
So that I can quickly browse movies based on my preferences | ||
I want to see movies sorted by title or release date | ||
|
||
Background: movies have been added to database | ||
|
||
Given the following movies exist: | ||
| title | rating | release_date | | ||
| Aladdin | G | 25-Nov-1992 | | ||
| The Terminator | R | 26-Oct-1984 | | ||
| When Harry Met Sally | R | 21-Jul-1989 | | ||
| The Help | PG-13 | 10-Aug-2011 | | ||
| Chocolat | PG-13 | 5-Jan-2001 | | ||
| Amelie | R | 25-Apr-2001 | | ||
| 2001: A Space Odyssey | G | 6-Apr-1968 | | ||
| The Incredibles | PG | 5-Nov-2004 | | ||
| Raiders of the Lost Ark | PG | 12-Jun-1981 | | ||
| Chicken Run | G | 21-Jun-2000 | | ||
|
||
And I am on the RottenPotatoes home page | ||
|
||
Scenario: sort movies alphabetically | ||
When I sort the movies alphabetically | ||
Then I should see "Aladdin" before "When Harry Met Sally" | ||
|
||
Scenario: sort movies in increasing order of release date | ||
When I sort the movies in increasing order of release date | ||
Then I should see "2001: A Space Odyssey" before "The Help" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# 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. | ||
title = movie[:title] | ||
rating = movie[:rating] | ||
release_date = movie[:release_date] | ||
Movie.create!(title: title, rating: rating, release_date: release_date) | ||
end | ||
end | ||
|
||
# Make sure that one string (regexp) occurs before or after another one | ||
# on the same page | ||
|
||
Then /I should see "(.*)" before "(.*)"/ do |e1, e2| | ||
# ensure that that e1 occurs before e2. | ||
# page.content is the entire content of the page as a string. | ||
regexp = /#{e1}.*#{e2}.*/m | ||
assert_match page.source, regexp | ||
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 (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 | ||
rating_list.split(" ").each do |rating| | ||
When %{I uncheck "#{rating}"} | ||
end | ||
end | ||
|
||
When /^I sort the movies alphabetically$/ do | ||
click_link "title_header" | ||
end | ||
|
||
When /^I sort the movies in increasing order of release date$/ do | ||
click_link "release_date_header" | ||
end |
Oops, something went wrong.