1

以下を含む機能ファイル (AddMovie.feature) だけを作成しました。

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"

cucumber を実行して次のコマンドでテストすると、次のようになります。

bundle exec cucumber features/AddMovie.feature 

結果としてこれが得られます:

Using the default profile...
Feature:  User can manually add movie

      Scenario:  Add a movie                              # features/AddMovie.feature:3
        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"

    1 scenario (1 passed)
    0 steps

「RottenPotatoes ホームページ」のパスを追加していないため、通常、このシナリオは失敗します。最後の行「0 steps」を読んだ場合、キュウリはどのステップも実行していません。

どうすればこれを修正できますか? AddMovie.feature で定義されたステップをテストするキュウリを作成しますか?

PS: コマンド cucumber features/Addmovies.feature を使用すると、このエラーが発生しました

Using the default profile...
You have already activated activesupport 3.2.8, but your Gemfile requires activesupport 3.1.0. Using bundle exec may solve this. (Gem::LoadError)
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/runtime.rb:31:in `block in setup'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/runtime.rb:17:in `setup'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler.rb:107:in `setup'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/setup.rb:7:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/home/ubuntu/Desktop/hw2_rottenpotatoes/config/boot.rb:6:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/home/ubuntu/Desktop/hw2_rottenpotatoes/config/application.rb:1:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/home/ubuntu/Desktop/hw2_rottenpotatoes/config/environment.rb:2:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-rails-1.3.0/lib/cucumber/rails.rb:7:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/home/ubuntu/Desktop/hw2_rottenpotatoes/features/support/env.rb:7:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/rb_support/rb_language.rb:129:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/rb_support/rb_language.rb:129:in `load_code_file'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime/support_code.rb:82:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:175:in `load_step_definitions'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:40:in `run!'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:43:in `execute!'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:20:in `execute'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/bin/cucumber:14:in `<top (required)>'
/usr/local/bin/cucumber:19:in `load'
/usr/local/bin/cucumber:19:in `<main>'

Bundle execを追加すると消えました

4

2 に答える 2

0

私はこの問題を解決します、あなたの解決策はこれを行います

bundler最新のgemをインストールする

gem install bundler --no-ri --no-rdoc

その後、実行しますcucumber features/find_movie_with_same_director.feature

それでもそのエラーが発生する場合は、以下のリンクを定義する手順に従ってください

Ruby on Rails-キュウリ実行時のエラー:activesupport 3.2.1はすでにアクティブ化されていますが、Gemfileにはactivesupport3.1.0が必要です。

于 2012-11-08T10:52:38.813 に答える
0

Have you initialized your database and run 'bundle install'? The error without bundle exec is because your bundle wants a different version of active support than the one presently installed.

Rails encourages convention over configuration. The convention for feature names is lower case snake_case.

Look at your other features. cucumber seems to execute all features the way you are invoking it. It could be a problem with something else in the directory.

Do you have any step files? They might also be your issue.

Also, Stackoverflow is not really the place for asking questions about homework (there is a forum for that).

于 2012-10-29T08:46:36.623 に答える