我正在使用rails 2.3.5 黄瓜(0.10.0) 黄瓜栏杆(0.3.2) 水豚(0.4.1.2) rspec(2.5.0) rspec-core(2.5.1) rspec-expectations(2.5.0) rspec-mocks(2.5.0) rspec-rails(2.5.0)
我有这个场景
功能:用户登录
Scenario: User sees the admin login page
Given There exists an admin login page
When I visit the admin login page
Then she should see the "login , Password" fields
And she should see links to "Forgot Password? , Do not have an account?"
我的网页步骤
Given /^There exists an admin login page$/ do
Capybara.default_host = "admin.local"
Capybara.app_host = "http://admin.local:9887" if Capybara.current_driver == :selenium
end
When /^I visit the admin login page$/ do
visit ('/')
end
Then /^she should see the "([^"]*)" fields$/ do |fields|
fields.split(/,/).each do |field|
page.should have_xpath("//*[@id='user_session_#{field.downcase.strip}']")
end
end
Then /^she should see links to "([^"]*)"$/ do |links|
links.split(/,/).each do |link_name|
page.should have_content(link_name.strip)
end
end
我将管理控制台映射为子域,如网页步骤所示。
我面临的问题是,当我使用cucumber-f pretty
运行此方案时,所有步骤都通过,整个方案看起来不错。
但是当我做rake功能或耙黄瓜时:所有我得到以下错误(我发布错误跟踪)
$ rake features --trace --verbose
** Invoke features (first_time)
** Invoke cucumber (first_time)
** Invoke cucumber:ok (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
** Execute cucumber:ok
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -I "/Library/Ruby/Gems/1.8/gems/cucumber-0.10.0/lib:lib" "/Library/Ruby/Gems/1.8/gems/cucumber-0.10.0/bin/cucumber" --profile default
Using the default profile...
/Users/raghavendra/Projects/project/project/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
F----F
Failing Scenarios:
cucumber features/user_features/user_login_and_creation.feature:3 # Scenario: User sees the admin login page
1 scenario (1 failed)
4 steps (4 skipped)
0m0.005s
rake aborted!
Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:995:in `sh'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1010:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1010:in `sh'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1094:in `sh'
/Library/Ruby/Gems/1.8/gems/cucumber-0.10.0/lib/cucumber/rake/task.rb:72:in `run'
/Library/Ruby/Gems/1.8/gems/cucumber-0.10.0/lib/cucumber/rake/task.rb:142:in `define_task'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
任何想法或帮助都将受到高度赞赏:)
答案 0 :(得分:2)
虽然我不确定这与您的问题完全相关,但RSpec 2.x仅适用于Rails 3.x.您将需要RSpec 1.3.x与rails 2.3.x一起使用。
答案 1 :(得分:1)
如果您的cucumber.yml文件中定义了--strict,则在有任何挂起或未定义的步骤时,黄瓜会抛出非零返回值。尝试采取---严格,看看它是否适合你。