Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 8 commits
  • 8 files changed
  • 0 comments
  • 1 contributor
2  .gitignore
@@ -5,3 +5,5 @@ TAGS
5 5
 db/schema.rb
6 6
 log/
7 7
 db/*.sqlite3
  8
+
  9
+db/development.sqlite3
7  Gemfile
@@ -6,7 +6,12 @@ gem 'rails', '3.1.0'
6 6
 # gem 'rails',     :git => 'git://github.com/rails/rails.git'
7 7
 
8 8
 # for Heroku deployment - as described in Ap. A of ELLS book
9  
-group :development, :test do
  9
+group :development do
  10
+  gem 'sqlite3'
  11
+  gem 'ruby-debug19', :require => 'ruby-debug'
  12
+end
  13
+
  14
+group :test do
10 15
   gem 'sqlite3'
11 16
   gem 'ruby-debug19', :require => 'ruby-debug'
12 17
   gem 'cucumber-rails'
BIN  db/development.sqlite3
Binary file not shown
30  features/filter_movie_list.feature
@@ -23,13 +23,39 @@ Background: movies have been added to database
23 23
   
24 24
 Scenario: restrict to movies with 'PG' or 'R' ratings
25 25
   # enter step(s) to check the 'PG' and 'R' checkboxes
  26
+  Given I check the following ratings: PG, R
26 27
   # enter step(s) to uncheck all other checkboxes
  28
+  And I uncheck the following ratings: G, PG-13, NC-17
27 29
   # enter step to "submit" the search form on the homepage
  30
+  And I press "Refresh"
  31
+  
28 32
   # enter step(s) to ensure that PG and R movies are visible
  33
+  Then I should see the movies:
  34
+  | title                   | rating | release_date |
  35
+  | The Terminator          | R      | 26-Oct-1984  |
  36
+  | When Harry Met Sally    | R      | 21-Jul-1989  |
  37
+  | Amelie                  | R      | 25-Apr-2001  |
  38
+  | The Incredibles         | PG     | 5-Nov-2004   |
  39
+  | Raiders of the Lost Ark | PG     | 12-Jun-1981  |
29 40
   # enter step(s) to ensure that other movies are not visible
  41
+  And I should not see the movies:
  42
+  | title                   | rating | release_date |
  43
+  | Aladdin                 | G      | 25-Nov-1992  |
  44
+  | The Help                | PG-13  | 10-Aug-2011  |
  45
+  | Chocolat                | PG-13  | 5-Jan-2001   |
  46
+  | 2001: A Space Odyssey   | G      | 6-Apr-1968   |
  47
+  | Chicken Run             | G      | 21-Jun-2000  |
30 48
 
31 49
 Scenario: no ratings selected
32  
-  # see assignment
  50
+    Given I uncheck the following ratings: PG, R, G, PG-13, NC-17
  51
+    
  52
+    And I press "Refresh"
  53
+    
  54
+    Then I should not see any of the movies
33 55
 
34 56
 Scenario: all ratings selected
35  
-  # see assignment
  57
+  Given I check the following ratings: PG, R, G, PG-13, NC-17
  58
+
  59
+  And I press "Refresh"
  60
+
  61
+  Then I should see all of the movies
11  features/sort_movie_list.feature
@@ -22,8 +22,13 @@ Background: movies have been added to database
22 22
   And I am on the RottenPotatoes home page
23 23
 
24 24
 Scenario: sort movies alphabetically
25  
-  # your steps here
  25
+  Given I check the following ratings: PG, R, G, PG-13, NC-17
  26
+  And I press "Refresh"
  27
+  And I follow "title_header"
  28
+  Then I should see "Amelie" before "The Terminator"
26 29
 
27 30
 Scenario: sort movies in increasing order of release date
28  
-  # your steps here
29  
-
  31
+  Given I check the following ratings: PG, R, G, PG-13, NC-17
  32
+  And I press "Refresh"
  33
+  And I follow "release_date_header"
  34
+  Then I should see "Chicken Run" before "The Help"
27  features/step_definitions/movie_steps.rb
@@ -4,8 +4,10 @@
4 4
   movies_table.hashes.each do |movie|
5 5
     # each returned element will be a hash whose key is the table header.
6 6
     # you should arrange to add that movie to the database here.
  7
+    
  8
+    Movie.create!(movie)
7 9
   end
8  
-  assert false, "Unimplmemented"
  10
+  # assert false, "Unimplemented"
9 11
 end
10 12
 
11 13
 # Make sure that one string (regexp) occurs before or after another one
@@ -14,7 +16,11 @@
14 16
 Then /I should see "(.*)" before "(.*)"/ do |e1, e2|
15 17
   #  ensure that that e1 occurs before e2.
16 18
   #  page.content  is the entire content of the page as a string.
17  
-  assert false, "Unimplmemented"
  19
+  # assert false, "Unimplemented"
  20
+  regexp = Regexp.new(/(#{e1}){1}.*(#{e2}){1}/m)
  21
+  # puts page.body
  22
+  assert regexp.match(page.body)
  23
+  # step %Q{I should see /(#{e1}){1}.+(#{e2}){1}/m}
18 24
 end
19 25
 
20 26
 # Make it easier to express checking or unchecking several boxes at once
@@ -25,4 +31,21 @@
25 31
   # HINT: use String#split to split up the rating_list, then
26 32
   #   iterate over the ratings and reuse the "When I check..." or
27 33
   #   "When I uncheck..." steps in lines 89-95 of web_steps.rb
  34
+  rating_list.split(',').each do |r|
  35
+    step %Q{I #{uncheck}check "ratings_#{r.strip}"}
  36
+  end
  37
+end
  38
+
  39
+Then /I should (not )?see the movies/ do |neg, movies_table|
  40
+  movies_table.hashes.each do |movie|
  41
+    step %Q{I should #{neg}see "#{movie[:title]}"}
  42
+  end
  43
+  # assert false, "Unimplemented"
28 44
 end
  45
+
  46
+Then /I should (not )?see (all|any) of the movies/ do |neg, all|
  47
+  Movie.all.each do |movie|
  48
+    step %Q{I should #{neg}see "#{movie[:title]}"}
  49
+  end
  50
+end
  51
+
11  features/step_definitions/web_steps.rb
@@ -43,6 +43,7 @@ def with_scope(locator)
43 43
 
44 44
 Given /^(?:|I )am on (.+)$/ do |page_name|
45 45
   visit path_to(page_name)
  46
+  # puts page.body
46 47
 end
47 48
 
48 49
 When /^(?:|I )go to (.+)$/ do |page_name|
@@ -51,10 +52,12 @@ def with_scope(locator)
51 52
 
52 53
 When /^(?:|I )press "([^"]*)"$/ do |button|
53 54
   click_button(button)
  55
+  # puts page.body
54 56
 end
55 57
 
56 58
 When /^(?:|I )follow "([^"]*)"$/ do |link|
57 59
   click_link(link)
  60
+  # puts page.body
58 61
 end
59 62
 
60 63
 When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
@@ -90,10 +93,18 @@ def with_scope(locator)
90 93
   check(field)
91 94
 end
92 95
 
  96
+When /^(?:|I )check rating "([^"]*)"$/ do |field|
  97
+  check("ratings_" + field)
  98
+end
  99
+
93 100
 When /^(?:|I )uncheck "([^"]*)"$/ do |field|
94 101
   uncheck(field)
95 102
 end
96 103
 
  104
+When /^(?:|I )uncheck rating "([^"]*)"$/ do |field|
  105
+  uncheck("ratings_" + field)
  106
+end
  107
+
97 108
 When /^(?:|I )choose "([^"]*)"$/ do |field|
98 109
   choose(field)
99 110
 end
4  features/support/paths.rb
@@ -15,6 +15,10 @@ def path_to(page_name)
15 15
 
16 16
     when /^the home\s?page$/
17 17
       '/'
  18
+      
  19
+    when /^the RottenPotatoes home page$/
  20
+      '/movies'
  21
+      
18 22
 
19 23
     # Add more mappings here.
20 24
     # Here is an example that pulls values out of the Regexp:

No commit comments for this range

Something went wrong with that request. Please try again.