安装Capybara后,我收到错误:
NoMethodError: undefined method `join' for nil:NilClass
每当我尝试运行rspec时。
我一直试图添加和删除不同的要求,但似乎没有任何效果。有没有人知道发生了什么?
spec_helper.rb
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.filter_run :focus
config.run_all_when_everything_filtered = true
config.disable_monkey_patching!
config.warnings = true
if config.files_to_run.one?
config.default_formatter = 'doc'
end
config.profile_examples = 10
config.order = :random
Kernel.srand config.seed
config.include FactoryGirl::Syntax::Methods
#FactoryGirl.definition_file_paths = [File.expand_path('../factories', __FILE__)]
config.warnings = false
config.infer_spec_type_from_file_location!
config.include SpecTestHelper, :type => :controller
config.include Capybara::DSL
end
Capybara.default_driver = :selenium
rails_helper.rb
ENV['RAILS_ENV'] ||= 'test'
require 'spec_helper'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
end
对于我包含的所有规范文件:
require 'spec_helper'
请帮忙!
更新
这是回溯:
NoMethodError: undefined method `join' for nil:NilClass
(root) at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/capybara-2.4.4/lib/capybara/rails.rb:15
require at org/jruby/RubyKernel.java:1071
require at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251
load_dependency at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:236
require at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251
(root) at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/rspec-rails-3.2.1/lib/rspec/rails/vendor/capybara.rb:1
require at org/jruby/RubyKernel.java:1071
require at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251
load_dependency at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:236
require at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251
(root) at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/rspec-rails-3.2.1/lib/rspec/rails/vendor/capybara.rb:7
require at org/jruby/RubyKernel.java:1071
(root) at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/rspec-rails-3.2.1/lib/rspec/rails.rb:1
require at org/jruby/RubyKernel.java:1071
(root) at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/rspec-rails-3.2.1/lib/rspec/rails.rb:13
each at org/jruby/RubyArray.java:1613
(root) at /Users/ssuhli200/Downloads/cimport/spec/spec_helper.rb:1
(root) at /Users/ssuhli200/Downloads/cimport/spec/spec_helper.rb:5
each at org/jruby/RubyArray.java:1613
(root) at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1
requires= at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1181
requires= at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1181
process_options_into at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/rspec-core-3.2.3/lib/rspec/core/configuration_options.rb:110
process_options_into at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/rspec-core-3.2.3/lib/rspec/core/configuration_options.rb:109
configure at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/rspec-core-3.2.3/lib/rspec/core/configuration_options.rb:22
setup at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:96
load at org/jruby/RubyKernel.java:1087
run at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:85
eval at org/jruby/RubyKernel.java:1107
(root) at /Users/ssuhli200/.rvm/gems/jruby-1.7.18@cimport/bin/jruby_executable_hooks:15
答案 0 :(得分:1)
您需要import numpy as np
import pandas as pd
data = pd.DataFrame({'MasterUserId': ['one', 'one', 'two', 'three'] * 6,
'visittime_cat': ['A', 'B', 'C'] * 8,
'week_cat': ['foo', 'foo', 'foo', 'bar', 'bar', 'bar'] * 4,
'var3': np.random.randn(24),
'var4': np.random.randn(24)})
storage = cross_tab(data, "MasterUserId")
storage.keys()
['crosstab_week_cat', 'crosstab_var4', 'crosstab_visittime_cat', 'crosstab_var3']
storage['crosstab_week_cat']
week_cat bar foo
MasterUserId
one 6 6
three 4 2
two 2 4
[3 rows x 2 columns]
而不是rails_helper
。问题是Capybara在你的Rails应用程序启动之前调用spec_helper
(在你的Rails帮助程序中处理)。