ruby – kernel_require.rb:55:在`require’中:无法加载这样
目前我使用的是
Ruby 1.9.3版本(尽管我与Ruby 2.0.0相同).在Windows 7 64位.我正在关注“黄瓜书”,并在第7.2章 – “使用变换删除重复”中被卡住.我的文件夹结构如下:
cash_withdrawal cash_withdrawalGemfile cash_withdrawalGemfile.lock cash_withdrawalfeatures cash_withdrawalfeaturescash-withdrawal.feature cash_withdrawalfeaturesstep_definitions cash_withdrawalfeaturesstep_definitionscash_withdrawal_steps.rb cash_withdrawalfeaturesstep_definitionslib cash_withdrawalfeaturesstep_definitionslibnice_bank.rb cash_withdrawalfeaturessupport cash_withdrawalfeaturessupportenv.rb cash_withdrawalfeaturessupporttransforms.rb cash_withdrawalfeaturessupportworld_extensions.rb 在我的cash_withdrawal_steps.rb文件中,我有: require 'CAPTURE_CASH_AMOUNT' Given /^I have deposited (#{CAPTURE_CASH_AMOUNT}) in my Account$/ do |amount| my_account.deposit(amount) my_account.balance.should eq(amount),"Expected the balance to be #{amount} but it was #{my_account.balance}" end 当我运行黄瓜我得到:
如果我运行irb然后运行需要“CAPTURE_CASH_AMOUNT”我得到这个错误:
我已经尝试过许多修复,包括’require_relative’,没有什么似乎可以解决我的问题. C:UsersNikita.HarrisonAutomatedTestingcash_withdrawal>cucumber Feature: Cash withdrawal @test Scenario: Successful withdrawal from an account in credit # featurescash_with drawal.feature:4 Given I have deposited $100 in my Account # featurescash_with drawal.feature:5 When I withdraw $20 # features/step_defi nitions/cash_withdrawal_steps.rb:7 Then $20 should be dispensed # features/step_defi nitions/cash_withdrawal_steps.rb:11 And the balance of my account should be $80 # features/step_defi nitions/cash_withdrawal_steps.rb:15 1 scenario (1 undefined) 4 steps (3 skipped,1 undefined) 0m0.006s You can implement step definitions for undefined steps with these snippets: Given(/^I have deposited $(d+) in my Account$/) do |arg1| pending # express the regexp above with the code you wish you had end 如果我添加需要File.join(File.dirname(“C:/Users/Nikita.Harrison/AutomatedTesting/cash_withdrawal/features/support”),“支持”,“转换”)到env.rb文件并运行黄瓜I得到: C:/Users/Nikita.Harrison/AutomatedTesting/cash_withdrawal/features/support/trans forms.rb:1: warning: already initialized constant CAPTURE_CASH_AMOUNT Feature: Cash withdrawal @test Scenario: Successful withdrawal from an account in credit # featurescash_with drawal.feature:4 Given I have deposited $100 in my Account # featurescash_with drawal.feature:5 When I withdraw $20 # features/step_defi nitions/cash_withdrawal_steps.rb:7 Then $20 should be dispensed # features/step_defi nitions/cash_withdrawal_steps.rb:11 And the balance of my account should be $80 # features/step_defi nitions/cash_withdrawal_steps.rb:15 1 scenario (1 undefined) 4 steps (3 skipped,1 undefined) 0m0.013s You can implement step definitions for undefined steps with these snippets: Given(/^I have deposited $(d+) in my Account$/) do |arg1| pending # express the regexp above with the code you wish you had end 我知道我一定在做错事,但是我根本找不到需要帮助的东西. # This Gemfile lists all Gems used throughout the book - with versions. source :rubygems # Build stuff gem 'bundler','1.5.3' #gem 'rake','10.1.1' #gem 'watchr','0.7' #gem 'bcat','0.6.2' # General stuff #gem 'aruba','0.4.11' gem 'cucumber','1.3.10',:require => 'cucumber' gem 'rake','10.1.1' gem 'rspec','2.14.1',:require => 'cucumber' gem 'rspec-expectations','2.14.5' gem 'watir-webdriver','0.6.7' 我想我已经包含了所有需要的信息. 解决方法
我刚刚遇到同样的问题,我相信这是捆绑的问题.无论如何,我通过运行解决了这个问题:
bundle update bundle exec ruby <yourfilename.rb> 希望这可以帮助! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |