我正在使用我的Mac OS X盒子上的Rails和Cucumber。当我尝试运行以下场景时:
Feature: ActorDetail
In order to learn about an actor
As a costumer
I want to see their details
Scenario: Actors page should exist
Given I am on actor page
Then I should see "Actors"
当我尝试运行测试时,我得到以下内容:
kevin:11:17 PM:~/Documents/Rails/testApp: cucumber
Using the default profile...
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/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/ActorDetail.feature:6 # Scenario: Actors page should exist
1 scenario (1 failed)
2 steps (2 skipped)
0m0.138s
如果你知道我的意思,这是一个失败的测试,但不是我想让它失败的方式。我期待一条消息,告诉我没有为“演员”定义路径
有趣的是,如果我在“Actors”周围从双引号改为单引号,这就是我得到的:
kevin:11:09 PM:~/Documents/Rails/testApp: cucumber
Using the default profile...
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/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-UF
Failing Scenarios:
cucumber features/ActorDetail.feature:6 # Scenario: Actors page should exist
1 scenario (1 failed)
2 steps (1 skipped, 1 undefined)
0m0.144s
如果我提供的信息不足以说明我安装了什么宝石,配置等等,我很抱歉。到目前为止,我已经在Rails中开发了大约三个小时。
非常感谢,
KevDog
更新 我做了宝石更新,现在情况似乎变得更糟。这是当前的错误:
kevin:12:29 AM:~/Documents/Rails/testApp: cucumber
Using the default profile...
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
/Users/kevin/.gem/ruby/1.8/gems/nokogiri-1.4.2/lib/nokogiri/nokogiri.bundle: [BUG] Bus Error
ruby 1.8.7 (2008-05-31 patchlevel 0) [i686-darwin9.4.0]
Abort trap
听起来不太好。
答案 0 :(得分:8)
使用下面的命令来运行你的黄瓜功能,这将给出详细的输出。
cucumber --format pretty
答案 1 :(得分:0)
对于Gem::Dependency#version_requirements is deprecated
警告,看起来您需要升级Rails(至少为2.3.6)。 Rails 2.3.6和2.3.7都包含a commit that fixes the warning you are seeing。我不确定为什么你的gem更新不会解决这个问题,除非是因为它只是试图更新你主目录中的gem(我没有尝试过使用每个用户的GEM_HOME,所以我不确定它会如何交互需要安装系统gem目录中包含的更新版本的gem。也许你需要做sudo /usr/local/bin/gem update
而不是你之前运行的任何更新(一定要移开或删除你的家庭gems目录中破坏的nokogiri安装)。
在Then I should see
步骤中使用单引号和双引号时结果的差异可能是由于没有与单引号相匹配的步骤定义。检查您的features/step_definitions/web_steps.rb
文件以验证这一点(我的Cucumber 0.8.0版本包含一个JSON变体,双引号分隔变体(文字字符串)和斜杠分隔变体(正则表达式匹配)但没有单引号变体)。
此外,您可能需要使用the actor page
代替actor page
,或在actor page
中定义features/support/paths.rb
的路径映射。
答案 2 :(得分:0)
你有没有尝试过:
rake gems:install RAILS_ENV=test
这应该安装测试环境所需的所有宝石。 此外,根据您是否已定义任何模型,您可能还需要使用
准备测试数据库rake db:test:prepare
答案 3 :(得分:-3)
检查空白。在您发布的示例中,它没有正确缩进。
Feature: ActorDetail
In order to learn about an actor
As a costumer
I want to see their details
Scenario: Actors page should exist
Given I am on actor page
Then I should see "Actors"