- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 rspec2
安装了 spork
和 guard
,当运行 guard
命令时,我得到这个错误:
undefined method `generators' for #<RSpec::Core::Configuration:0x007fb3944b23b0> (NoMethodError)
/Users/amiterandole/Desktop/current/rails/depot/spec/spec_helper.rb:64:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core.rb:108:in `configure'
/Users/amiterandole/Desktop/current/rails/depot/spec/spec_helper.rb:18:in `block in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/spork-1.0.0rc3/lib/spork.rb:24:in `prefork'
/Users/amiterandole/Desktop/current/rails/depot/spec/spec_helper.rb:6:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/spork-1.0.0rc3/lib/spork/test_framework.rb:138:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/spork-1.0.0rc3/lib/spork/test_framework.rb:138:in `block (2 levels) in preload'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/spork-1.0.0rc3/lib/spork/app_framework.rb:49:in `preload'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/spork-1.0.0rc3/lib/spork/test_framework.rb:134:in `block in preload'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/spork-1.0.0rc3/lib/spork.rb:62:in `exec_prefork'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/spork-1.0.0rc3/lib/spork/test_framework.rb:120:in `preload'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/spork-1.0.0rc3/lib/spork/run_strategy/forking.rb:25:in `preload'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/spork-1.0.0rc3/lib/spork/runner.rb:74:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/spork-1.0.0rc3/lib/spork/runner.rb:10:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/spork-1.0.0rc3/bin/spork:10:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/spork:19:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/spork:19:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/shellwords.rb:35:in `block in shellsplit': Unmatched double quote: "--format RSpec::Instafail' > .rspec" (ArgumentError)
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/shellwords.rb:33:in `scan'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/shellwords.rb:33:in `shellsplit'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/shellwords.rb:128:in `shellsplit'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:115:in `block in args_from_options_file'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:115:in `map'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:115:in `args_from_options_file'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:109:in `options_from'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:101:in `project_options'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:81:in `file_options'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:77:in `all_configs'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:34:in `parse_options'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:69:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:17:in `block in autorun'
14:48:19 - ERROR - Could not start Spork server for RSpec after 30 seconds. I will continue waiting for a further 60 seconds.
14:49:19 - ERROR - Could not start Spork server for RSpec. Make sure you can use it manually first.
14:49:19 - INFO - Guard::RSpec is running
14:49:19 - INFO - Running all specs
14:49:19 - ERROR - Guard::RSpec failed to achieve its <start>, exception was:
> [#CFA8FD5ABE83] ArgumentError: Unmatched double quote: "--format RSpec::Instafail' > .rspec"
> [#CFA8FD5ABE83] /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/shellwords.rb:35:in `block in shellsplit'
> [#CFA8FD5ABE83] /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/shellwords.rb:33:in `scan'
> [#CFA8FD5ABE83] /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/shellwords.rb:33:in `shellsplit'
> [#CFA8FD5ABE83] /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/shellwords.rb:128:in `shellsplit'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:115:in `block in args_from_options_file'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:115:in `map'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:115:in `args_from_options_file'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:109:in `options_from'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:101:in `project_options'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:81:in `file_options'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:77:in `all_configs'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.12.2/lib/rspec/core/configuration_options.rb:34:in `parse_options'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-rspec-2.3.3/lib/guard/rspec/runner.rb:59:in `parsed_or_default_formatter'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-rspec-2.3.3/lib/guard/rspec/runner.rb:79:in `rspec_arguments'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-rspec-2.3.3/lib/guard/rspec/runner.rb:119:in `run_via_drb'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-rspec-2.3.3/lib/guard/rspec/runner.rb:36:in `run'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-rspec-2.3.3/lib/guard/rspec.rb:35:in `run_all'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-rspec-2.3.3/lib/guard/rspec.rb:31:in `start'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/runner.rb:99:in `block in run_supervised_task'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/runner.rb:97:in `catch'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/runner.rb:97:in `run_supervised_task'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/runner.rb:54:in `block (2 levels) in run'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/runner.rb:175:in `block (3 levels) in scoped_guards'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/runner.rb:174:in `each'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/runner.rb:174:in `block (2 levels) in scoped_guards'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/runner.rb:173:in `catch'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/runner.rb:173:in `block in scoped_guards'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/runner.rb:172:in `each'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/runner.rb:172:in `scoped_guards'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/runner.rb:53:in `block in run'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/lumberjack-1.0.2/lib/lumberjack.rb:27:in `unit_of_work'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/runner.rb:52:in `run'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard.rb:187:in `block in start'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard.rb:363:in `block in within_preserved_state'
> [#CFA8FD5ABE83] <internal:prelude>:10:in `synchronize'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard.rb:360:in `within_preserved_state'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard.rb:185:in `start'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/lib/guard/cli.rb:110:in `start'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor.rb:275:in `dispatch'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/guard-1.6.0/bin/guard:6:in `<top (required)>'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/bin/guard:19:in `load'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/bin/guard:19:in `<main>'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
> [#CFA8FD5ABE83] /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
14:49:19 - INFO - Guard::RSpec has just been fired
14:49:21 - INFO - Bundle already up-to-date
14:49:21 - INFO - Guard is now watching at '/Users/amiterandole/Desktop/current/rails/depot'
如果我取出生成器配置,一切似乎都运行良好。我正在使用 rails 3.2.11
和 ruby-1.9.3-p194
这是我的 gemfile 的样子:
group :development, :test do
gem 'meta_request', '0.2.1'
gem "rspec-rails", "~> 2.0"
gem "factory_girl_rails", ">= 3.3.0"
gem "guard-rspec"
gem "capybara", ">= 1.1.2"
gem "database_cleaner"
gem "launchy", ">= 2.1.0"
gem 'rb-fsevent', '~> 0.9.1'
gem 'spork', '~> 1.0rc'
gem 'guard-spork', '~> 1.0rc'
gem "guard-bundler"
gem "guard-migrate"
end
这是我的保护文件:
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch('config/environments/test.rb')
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile')
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
watch('test/test_helper.rb') { :test_unit }
watch(%r{features/support/}) { :cucumber }
watch(%r{^spec/support/.+\.rb$})
end
guard 'rspec', :cli => "--drb" do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
这是我的spec_helper.rb
:
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'database_cleaner'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
config.include FactoryGirl::Syntax::Methods
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
config.generators do |g|
g.view_specs false
g.helper_specs false
g.test_framework :rspec, :fixture => true
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
end
end
Spork.each_run do
# This code will be run each time you run your specs.
FactoryGirl.reload
end
end
我该如何解决这个问题?
最佳答案
我发现了错误。显然 config.generators
block 在 application.rb
中:
config.generators do |g|
g.view_specs false
g.helper_specs false
g.test_framework :rspec, :fixture => true
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
end
关于testing - #<RSpec::Core::Configuration 的未定义方法 `generators',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14375805/
我想知道 Rspec 中的命令式和声明式步骤是什么。 这是 Rspec 书中的示例代码: Scenario: transfer money (declarative) Given I have $10
我正在尝试使用 Travis 设置 CI。但是我遇到了在 Travis 上失败但在本地没有的测试,甚至提供了相同的种子。 我认为种子运行相同,但现在我不确定,并想弄清楚它是否存在,所以我现在在哪里看。
RSpec 的文档提到了 --bisect option ,当运行时提供最小的复制,例如 rspec ./spec/calculator_10_spec.rb[1:1] ./spec/calculat
我有一些昂贵的测试设置,仅对我的规范中的少数示例是必需的,如果需要,它只需要运行一次。因为它很慢,所以我试图避免将它放在 before(:each) block 中,但 before(:all) 似乎
在我的 Gemfile 中 gem 'rspec-rails', '~> 3.3' 我发现,errors_on 匹配器移动到了另一个 gem:https://github.com/rspec/rspe
如果我运行此命令“rspec ./spec/requests/api/v1/password_reset_request_spec.rb”,此文件中的所有测试都会通过。 但是,当我运行“rspec”时
我花了 4 天时间尝试正确安装 Ruby on Rails,但我遇到了一个大问题。我第一次使用Linux(对我来说更舒服),但遇到问题后,我使用了Windows。令我惊讶的是,我在 Windows 上
我在这样的验证中测试了很多坏字符串: ['0', '3:a', 'xx:11', '-1', '-3:00', 'h', 'h2', 'h2h', 'm', 'm10', 'm10m', '2hm',
我的测试套件中有一部分运行着一堆非常慢的导入器。这些测试不需要经常运行(除非实际上正在处理导入器)所以我使用 Rspec 标签将它们分开:http://relishapp.com/rspec/rspe
Rspec 尝试在运行任何规范文件或整个测试套件结束时运行 Test::Unit 测试。它仍然没关系,因为我没有任何测试单元测试文件,但它尝试传递给 rspec 的命令行选项,因为它们将传递给 Tes
我有一段代码要测试: class User :destroy end 请举例测试关联代码的RSpec代码。 最佳答案 对我来说,这个变体效果很好: describe User do it { s
我正在尝试在 rails Controller 规范中重用一些通用代码。我对管理员用户和普通用户有不同的上下文。但是,对于特定操作,大部分行为是相同的,因此我尝试将这种常见行为提取到辅助函数中: de
我有两个类OneClass和 AnotherClass : class OneClass def initialize(*args) @another_member = AnotherCl
我有一个看起来像这样的模型: class Gist def self.create(options) post_response = Faraday.post do |request|
我是 RSPEC 的新手。我编写了一个名为 result_spec.rb 的 RSPEC 代码,如下所示: describe '#grouped_scores' do subject { result
我对字符串类进行了如下扩展: class String def last_character self[-1] end end 我将 string.rb 文件放在 lib 中,如下所示
我是 RSpec 的新手,我在其中编写了一个测试场景: my_object.should_not be_valid 它工作正常。但是,我想测试模型的特定属性是否无效。这样的 RSpec 行为是现成的吗
我正在尝试测试邮政编码属性的长度以确保其长度为 5 个字符。现在我正在测试以确保它不是空白,然后是 4 个字符太短,6 个字符太长。 有没有办法测试它是否正好是 5 个字符?到目前为止,我在网上或 r
我将rspec与电子邮件规范gem一起使用。我正在尝试做: last_delivery = ActionMailer::Base.deliveries.last last_delivery.body.
我创建了一个新的 rails 应用程序,并按照此处的 rspec-rails 安装说明进行操作 - https://github.com/rspec/rspec-rails然后我在我的 app/lib
我是一名优秀的程序员,十分优秀!