- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我目前使用的是 Ruby 1.9.3 版(尽管我在使用 Ruby 2.0.0 时遇到了同样的问题)。在 Windows 7 64 位上。我正在关注“The Cucumber Book”并卡在第 7.2 章 - “使用转换删除重复项”。我的文件夹结构如下:
\cash_withdrawal
\cash_withdrawal\Gemfile
\cash_withdrawal\Gemfile.lock
\cash_withdrawal\features
\cash_withdrawal\features\cash-withdrawal.feature
\cash_withdrawal\features\step_definitions
\cash_withdrawal\features\step_definitions\cash_withdrawal_steps.rb
\cash_withdrawal\features\step_definitions\lib
\cash_withdrawal\features\step_definitions\lib\nice_bank.rb
\cash_withdrawal\features\support
\cash_withdrawal\features\support\env.rb
\cash_withdrawal\features\support\transforms.rb
\cash_withdrawal\features\support\world_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
当我运行 cucumber
我得到:
C:\Users\Nikita.Harrison\AutomatedTesting\cash_withdrawal>cucumber cannot load such file -- CAPTURE_CASH_AMOUNT (LoadError) C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in
r equire'
r equire' C:/Users/Nikita.Harrison/AutomatedTesting/cash_withdrawal/features/step_definiti ons/cash_withdrawal_steps.rb:1:in
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in
<top (required)>'
load' C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.10/lib/cucumber/rb_support/rb_l anguage.rb:122:in
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.10/lib/cucumber/rb_support/rb_l
anguage.rb:122:inload_code_file'
load_file' C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.10/lib/cucumber/runtime/support _code.rb:83:in
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.10/lib/cucumber/runtime/support
_code.rb:180:inblock in load_files!' C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.10/lib/cucumber/runtime/support
each' C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.10/lib/cucumber/runtime/support _code.rb:82:in
_code.rb:82:inload_files!' C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.10/lib/cucumber/runtime.rb:184:
load_step_definitions' C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.10/lib/cucumber/runtime.rb:42:i n
inrun!'
execute!' C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.10/bin/cucumber:13:in
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.10/lib/cucumber/cli/main.rb:47:
in<top (re quired)>' C:/Ruby193/bin/cucumber:23:in
load' C:/Ruby193/bin/cucumber:23:in `'
如果我运行 irb
然后运行 require "CAPTURE_CASH_AMOUNT"
我收到此错误:
irb(main):006:0> require "CAPTURE_CASH_AMOUNT" LoadError: cannot load such file -- CAPTURE_CASH_AMOUNT from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_requir e.rb:55:in
require'
require' from (irb):6 from C:/Ruby193/bin/irb:12:in `'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_requir
e.rb:55:in
我尝试了很多修复方法,包括“require_relative”,但似乎无法解决我的问题。如果我删除 require 'CAPTURE_CASH_AMOUNT'
来自 cash_withdrawal_steps.rb
文件并运行 cucumber 然后我的“步骤定义”没有按定义显示:
C:\Users\Nikita.Harrison\AutomatedTesting\cash_withdrawal>cucumber
Feature: Cash withdrawal
@test Scenario: Successful withdrawal from an account in credit #
features\cash_with drawal.feature:4
Given I have deposited $100 in my Account # features\cash_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
如果我添加 require File.join(File.dirname("C:/Users/Nikita.Harrison/AutomatedTesting/cash_withdrawal/features/support"), 'support', 'transforms')
到 env.rb
文件并运行 cucumber
我得到:
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 #
features\cash_with drawal.feature:4
Given I have deposited $100 in my Account # features\cash_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
我知道我一定是做错了什么,但我就是找不到什么需要帮助。 gem 文件内容:
# 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'
我想我已经包含了所有需要的信息。
最佳答案
我刚刚遇到了同样的问题,我相信这是 bundler 的问题。无论如何,我通过运行解决了这个问题:
bundle update
bundle exec ruby <yourfilename.rb>
希望这对您有所帮助!
关于ruby - kernel_require.rb :55:in `require' : cannot load such file error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21831880/
下面是activeresource.rb的全部内容: require 'active_resource' 谁能解释一下这其中的逻辑? 为什么不简单地让 activeresource.rb 包含 act
Neo4j.rb 中是否有针对 Rails 6 的开发?在一个新的 Rails 6(rc1) 项目中,如果我创建几个脚手架然后运行“rake neo4j:migrate:all”,我会收到一个错误,当
对此很陌生,所以我一直在尝试解决这个问题,但无法找到答案。 gem update --system 安装 rb-appscript 时出现以下错误。 gem install rb-appscript
我正在为涉及选中/取消选中框的场景编写步骤定义。在步骤定义中,我尝试使用 web_steps.rb 中的现有步骤。但是我收到错误:未定义的步骤:“我检查'评级'”。我必须做些什么才能让我的 myfea
为什么 Controller 命名为“users_controller.rb”而模型不命名为“user_model.rb”? 为什么有“application_controller.rb”但在view
我对 Ruby on Rails 完全陌生,正在运行以下命令$rails生成设备用户 我期望生成文件 _devise_create_users.rb 。但是它会生成文件 _add_devise_to_
我的 Rails 应用程序(在 Heroku 上运行)有一个暂存和生产环境。目前,我必须在每个文件中分别定义 staging.rb 和 production.rb 中的很多内容,例如: # Cod
我是 Rails 新手,并且对 ASP.net 有很好的了解。在 ASP.net Web 应用程序中,我有一个 web.config 来完成所有设置,但在 Rails 中,有几个配置文件,我现在想知道
预先感谢您的帮助。 我正在尝试在 env.rb 中创建变量 File_path =("#{File.dirname(__FILE__)}/../../features/TestData/Testdat
按照这里的例子: http://rspec.info 但是它失败了: kernel_require.rb:45:in `require': cannot load such file -- bowli
我在使用 Ruby 时遇到了一个我无法解释的奇怪问题。我有以下脚本,它抓取剪贴板中当前的任何代码,通过语法高亮器运行它,然后将新版本放回剪贴板: #!/usr/bin/ruby1.9.1 requir
假设我想通过表单将此代码嵌入到单独的 ruby.rb 文件中: print "Hello, Please enter a value:" var = gets.to_i if var == 1
我正在从“MongoDB in Action”一书中学习 Mongodb 和 ruby 我已经安装好 Mongodb 并设法在其上执行了许多命令。 我可能没有正确安装 ruby。 我正在使用 Ub
更多新手问题。 我知道,如果我在我的应用程序帮助程序中定义了一个方法,那么整个应用程序代码都可以使用它。 在我的应用程序助手中,我有: def primary_user_is_admin if c
尝试将此代码块授予 capistrano 的版本 3 但无济于事。一切都变了。任何人都可以帮助我在正确的轨道上进行转换吗? 旧版本 2 deploy.rb: #require 'new_relic/r
我正在第二次学习 Rails 教程。当我输入这个 rails generate integration_test static_pages 我得到 spec/rails_helper.rb 和 spe
请问这个env.rb错误是什么意思? root# rake db:migrate WARNING: Cucumber-rails required outside of env.rb. The re
我已经看到这个问题出现在许多不同的情况下,并希望获得在 StackOverflow 上修复/调试它的最佳实践。 今天早上我想到了一个现实世界的例子: expected announcement.rb
这是我在 StackOverflow 上的第一个问题,请耐心等待...... 当我在Listing 8.6中使用authentication_pages_spec.rb时我的测试通过了。然后我在'sp
有谁知道在 JRuby 中是如何处理 tempfile.rb 的。它在 Ruby 中,但不在 JRuby 中。 有人有任何想法吗? 干杯 埃夫 最佳答案 您仍然可以“要求'tempfile'”并且它会
我是一名优秀的程序员,十分优秀!