私はSaaSコースを受講していますが、第4章ではCucumberを使用することになっています。私はすべての指示に従い、すべてがどのように機能するかを示すスクリーンキャストを見ましたが、それでもこのエラーで立ち往生しています。
Scenario: Add a movie # features/AddMovie.feature:3
Given I am on the RottenPotatoes home page # features/step_definitions/web_steps.rb:44
When I follow "Add new movie" # features/step_definitions/web_steps.rb:56
Then I should be on the Create New Movie page # features/step_definitions/web_steps.rb:230
When I fill in "Title" with "Men In Black" # features/step_definitions/web_steps.rb:60
And I select "PG-13" from "Rating" # features/step_definitions/web_steps.rb:85
And I press "Save Changes" # features/step_definitions/web_steps.rb:52
Then I should be on the RottenPotatoes home page # features/step_definitions/web_steps.rb:230
<"/movies"> expected but was
<"/movies/1">. (MiniTest::Assertion)
./features/step_definitions/web_steps.rb:235:in `/^(?:|I )should be on (.+)$/'
features/AddMovie.feature:10:in `Then I should be on the RottenPotatoes home page'
And I should see "Men In Black" # features/step_definitions/web_steps.rb:105
Failing Scenarios:
cucumber features/AddMovie.feature:3 # Scenario: Add a movie
Feature: User can manually add movie
Scenario: Add a movie
Given I am on the RottenPotatoes home page
When I follow "Add new movie"
Then I should be on the Create New Movie page
When I fill in "Title" with "Men In Black"
And I select "PG-13" from "Rating"
And I press "Save Changes"
Then I should be on the RottenPotatoes home page
And I should see "Men In Black"
およびのコードスニペットpath.rb
def path_to(page_name)
case page_name
when /^the home\s?page$/
'/'
when /^the RottenPotatoes home page/
movies_path
when /^the Create New Movie page/
new_movie_path
end
movies_controller.rb
class MoviesController < ApplicationController
def index
@movies = Movie.all( :order => "title" )
end
def show
id = params[ :id ] # retrieve movie ID from URI route
begin
@movie = Movie.find( id )
rescue
flash[ :warning ] = "The movie was not found."
redirect_to movies_path
end
# will render app/views/movies/show.html.haml by default
end
def new
# default: render 'new' template
end
def create
@movie = Movie.create( params[ :movie ] )
flash[ :notice ] = "#{ @movie.title } was successfully created."
redirect_to movie_path( @movie.id )
end
def edit
id = params[ :id ]
@movie = Movie.find_by_id( id )
end
def update
@movie = Movie.find_by_id 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