Permalink
Browse files

Merge remote branch 'hw3_public/master' into hw3_start

Conflicts:
	.gitignore
	Gemfile
	app/assets/stylesheets/application.css
	app/controllers/movies_controller.rb
	app/models/movie.rb
	app/views/movies/index.html.haml
	config/cucumber.yml
	config/database.yml
	config/routes.rb
	lib/tasks/cucumber.rake
  • Loading branch information...
2 parents b34151c + 609b1fc commit a25e60f640df956a1fe333c402bf5ef6107dfbf2 Richard Xia committed Feb 8, 2012
View
@@ -1,4 +1,5 @@
#*
+\#*\#
*~
TAGS
db/schema.rb
View
24 Gemfile
@@ -5,6 +5,20 @@ gem 'rails', '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
+# for Heroku deployment - as described in Ap. A of ELLS book
+group :development, :test do
+ gem 'sqlite3'
+ gem 'ruby-debug19', :require => 'ruby-debug'
+ gem 'cucumber-rails'
+ gem 'cucumber-rails-training-wheels'
+ gem 'database_cleaner'
+ gem 'capybara'
+ gem 'launchy'
+end
+group :production do
+# gem 'pg'
+end
+
# Gems used only for assets and not required
# in production environments by default.
group :assets do
@@ -22,13 +36,5 @@ gem 'jquery-rails'
# Deploy with Capistrano
# gem 'capistrano'
-group :development, :test do
- gem 'sqlite3'
- gem 'ruby-debug19'
-end
-
-group :production do
- gem 'pg'
-end
-
+# To use debugger
gem 'haml'
@@ -30,9 +30,27 @@ def new
end
def create
- debugger
@movie = Movie.create!(params[:movie])
flash[:notice] = "#{@movie.title} was successfully created."
+ redirect_to movies_path
+ end
+
+ def edit
+ @movie = Movie.find params[:id]
+ end
+
+ def update
+ @movie = Movie.find params[:id]
+ @movie.update_attributes!(params[:movie])
+ flash[:notice] = "#{@movie.title} was successfully updated."
+ redirect_to movie_path(@movie)
+ end
+
+ def destroy
+ @movie = Movie.find(params[:id])
+ @movie.destroy
+ flash[:notice] = "Movie '#{@movie.title}' deleted."
+ redirect_to movies_path
end
end
View
No changes.
View
@@ -1,7 +1,7 @@
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
-std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
+std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
View
@@ -12,7 +12,7 @@ development:
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
-test:
+test: &test
adapter: sqlite3
database: db/test.sqlite3
pool: 5
@@ -23,3 +23,6 @@ production:
database: db/production.sqlite3
pool: 5
timeout: 5000
+
+cucumber:
+ <<: *test
View
@@ -13,7 +13,7 @@
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
resources :movies
-
+
# Sample resource route with options:
# resources :products do
# member do
@@ -0,0 +1,25 @@
+class AddMoreMovies < ActiveRecord::Migration
+ MORE_MOVIES = [
+ {:title => 'Aladdin', :rating => 'G', :release_date => '25-Nov-1992'},
+ {:title => 'The Terminator', :rating => 'R', :release_date => '26-Oct-1984'},
+ {:title => 'When Harry Met Sally', :rating => 'R', :release_date => '21-Jul-1989'},
+ {:title => 'The Help', :rating => 'PG-13', :release_date => '10-Aug-2011'},
+ {:title => 'Chocolat', :rating => 'PG-13', :release_date => '5-Jan-2001'},
+ {:title => 'Amelie', :rating => 'R', :release_date => '25-Apr-2001'},
+ {:title => '2001: A Space Odyssey', :rating => 'G', :release_date => '6-Apr-1968'},
+ {:title => 'The Incredibles', :rating => 'PG', :release_date => '5-Nov-2004'},
+ {:title => 'Raiders of the Lost Ark', :rating => 'PG', :release_date => '12-Jun-1981'},
+ {:title => 'Chicken Run', :rating => 'G', :release_date => '21-Jun-2000'},
+ ]
+ def up
+ MORE_MOVIES.each do |movie|
+ Movie.create!(movie)
+ end
+ end
+
+ def down
+ MORE_MOVIES.each do |movie|
+ Movie.find_by_title_and_rating(movie[:title], movie[:rating]).destroy
+ end
+ end
+end
@@ -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 checkboxes selected
+ # see assignment
+
+Scenario: all checkboxes selected
+ # see assignment
@@ -0,0 +1,29 @@
+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
+
+Feature: sort movies alphabetically
+ # your steps here
+
+Feature: sort movies in increasing order of release date
+ # your steps here
+
@@ -0,0 +1,26 @@
+# 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
+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.
+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
+end
Oops, something went wrong.

0 comments on commit a25e60f

Please sign in to comment.