我在Java HotSpot(TM)64位服务器VM 1.7.0_67-b01上运行了jRuby 1.7.15(1.9.3p392)2014-09-03 82b5cc3的Rails应用程序(4.1.4)。
您可以在https://gist.github.com/eqbal/fe9477ddc20c6a9088fb看到我的Gemfile。
我的Gemfile.lock:https://gist.github.com/eqbal/17a3dc5d6a4024d62cc0。
如您所见,我正在使用rspec(2.14.1)和rspec-rails(2.14.2)。
我有一个类似这样的user_spec.rb文件:
require 'spec_helper'
describe User do
include_context "stubbed organization"
subject { build_stubbed(:super_admin, organization: organization) }
let(:notification_queue) { build_stubbed(:notification_queue) }
before(:each) do
allow(NotificationQueue).to receive(:find_each)
end
it "has name assigned" do
user = build(:member, first_name: 'John', last_name: 'Smiths')
expect(user.first_name).to eq('John')
expect(user.last_name).to eq('Smiths')
end
it "has a first name" do
subject.first_name = nil
expect(subject).not_to be_valid
end
it "has a last name" do
subject.last_name = nil
expect(subject).not_to be_valid
end
end
一旦我运行测试,我得到以下结果:
⇒ rspec spec/models/user_spec.rb
/Users/info/.rvm/gems/jruby-1.7.15@j-platform/gems/simplecov-0.8.2/lib/simplecov.rb:31 warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
[rspec-sidekiq] WARNING! Sidekiq will *NOT* process jobs in this environment. See https://github.com/philostler/rspec-sidekiq/wiki/FAQ-&-Troubleshooting
3/3: ****************************************_,------,
0/3: ****************************************_| /\_/\
0/3: ****************************************~|_( x .x)
3/3: **************************************** "" ""
Failures:
1) User has a first name
Failure/Error: Unable to find matching line from backtrace
NoMethodError:
undefined method `has_key?' for nil:NilClass
# ./app/models/client.rb:125:in `initialize_apps_data'
# ./spec/shared/stubbed_organization.rb:3:in `client'
# ./spec/shared/stubbed_organization.rb:15:in `(root)'
2) User has a last name
Failure/Error: Unable to find matching line from backtrace
NoMethodError:
undefined method `has_key?' for nil:NilClass
# ./app/models/client.rb:125:in `initialize_apps_data'
# ./spec/shared/stubbed_organization.rb:3:in `client'
# ./spec/shared/stubbed_organization.rb:15:in `(root)'
3) User has name assigned
Failure/Error: Unable to find matching line from backtrace
NoMethodError:
undefined method `has_key?' for nil:NilClass
# ./app/models/client.rb:125:in `initialize_apps_data'
# ./spec/shared/stubbed_organization.rb:3:in `client'
# ./spec/shared/stubbed_organization.rb:15:in `(root)'
我的rspec本地安装:
⇒ gem list | grep rspec
guard-rspec (4.2.9)
rspec (3.2.0, 2.14.1, 2.13.0)
rspec-core (3.2.3, 2.14.8, 2.13.1)
rspec-expectations (3.2.1, 2.14.5, 2.13.0)
rspec-mocks (3.2.1, 2.14.6, 2.13.1)
rspec-rails (3.2.1, 2.14.2, 2.13.0, 2.0.0.beta.18)
rspec-sidekiq (1.0.0)
rspec-support (3.2.2)
spring-commands-rspec (1.0.2)
如果我转而使用ruby-2.0.0-p353并捆绑安装宝石,然后尝试运行相同的测试,我会得到以下结果:
⇒ bundle exec rspec spec/models/user_spec.rb
/Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require': dlopen(/Users/info/.rvm/gems/ruby-2.0.0-p353/gems/http_parser.rb-0.6.0/lib/ruby_http_parser.bundle, 9): Library not loaded: @executable_path/../lib/libruby.1.9.1.dylib (LoadError)
Referenced from: /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/http_parser.rb-0.6.0/lib/ruby_http_parser.bundle
Reason: image not found - /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/http_parser.rb-0.6.0/lib/ruby_http_parser.bundle
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/http_parser.rb-0.6.0/lib/http_parser.rb:2:in `<top (required)>'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/http_parser.rb-0.6.0/lib/http/parser.rb:1:in `<top (required)>'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/twitter-5.9.0/lib/twitter/streaming/connection.rb:1:in `<top (required)>'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/twitter-5.9.0/lib/twitter/streaming/client.rb:4:in `<top (required)>'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/twitter-5.9.0/lib/twitter.rb:26:in `<top (required)>'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `each'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `block in require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `each'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.4/lib/bundler.rb:133:in `require'
from /Users/info/code/plumtales/j-platform/config/application.rb:9:in `<top (required)>'
from /Users/info/code/plumtales/j-platform/config/environment.rb:2:in `require'
from /Users/info/code/plumtales/j-platform/config/environment.rb:2:in `<top (required)>'
from /Users/info/code/plumtales/j-platform/spec/spec_helper.rb:11:in `require'
from /Users/info/code/plumtales/j-platform/spec/spec_helper.rb:11:in `block in <top (required)>'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/spork-1.0.0rc4/lib/spork.rb:24:in `prefork'
from /Users/info/code/plumtales/j-platform/spec/spec_helper.rb:7:in `<top (required)>'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:867:in `require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:867:in `block in setup_load_path_and_require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:867:in `each'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:867:in `setup_load_path_and_require'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.14.8/lib/rspec/core/configuration_options.rb:25:in `configure'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:21:in `run'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:80:in `run'
from /Users/info/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:17:in `block in autorun'
请注意本地安装的宝石:
⇒ gem list | grep rspec
guard-rspec (4.3.1, 4.2.9, 4.2.8, 4.2.0, 3.1.0)
mongoid-rspec (1.10.0)
mutant-rspec (0.5.10)
opal-rspec (0.3.0.beta3)
rspec (3.0.0, 2.99.0, 2.14.1, 2.12.0)
rspec-collection_matchers (1.0.0)
rspec-core (3.1.7, 3.0.4, 3.0.3, 2.99.2, 2.14.8, 2.14.7, 2.14.6, 2.14.5, 2.14.4, 2.12.2)
rspec-expectations (3.1.2, 3.0.4, 3.0.3, 2.99.2, 2.14.5, 2.14.4, 2.14.3, 2.14.0, 2.12.1)
rspec-given (3.1.1)
rspec-html-matchers (0.5.0)
rspec-instafail (0.2.4)
rspec-mocks (3.0.4, 3.0.3, 2.99.2, 2.14.6, 2.14.4, 2.14.3, 2.14.1, 2.12.1)
rspec-rails (3.0.2, 2.99.0, 2.14.2, 2.14.1, 2.14.0, 2.0.0.beta.18)
rspec-sidekiq (1.0.0)
rspec-spies (2.1.4)
rspec-support (3.1.2, 3.0.4, 3.0.3)
rspec_junit_formatter (0.2.0, 0.1.6)
spring-commands-rspec (1.0.2)
任何帮助将不胜感激。