嗨,我已经不知道为什么会发生这种情况,我是rspec的新手。请告诉我这个有什么问题。非常感谢您的帮助!
这是错误和跟踪。
1)公司应该有名为" name"," website"和" type"的 类型字符串 ←[31mFailure /错误:←[0m←[31m无法从backtrace←[0m找到匹配的行] ←[31mErrno :: ECONNREFUSED←[0米: ←[31mNo连接可能是因为目标机器主动拒绝它。 - 连接(2)←[0m←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/net/http.rb:762:在
initialize'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/net/http.rb:762:in
打开'←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/net/http.rb:762:在block in connect'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/timeout.rb:54:in
超时'←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/timeout.rb:99:在timeout'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/net/http.rb:762:in
连接'←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/net/http.rb:755:在do_start'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/net/http.rb:744:in
开始'←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/net/http.rb:1284:在request'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/httparty-0.13.1/lib/httparty/request.rb:93:in
表演'←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/httparty-0.13.1/lib/httparty.rb:521:在perform_request'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/httparty-0.13.1/lib/httparty.rb:473:in
帖子'←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/httparty-0.13.1/lib/httparty.rb:563:在post'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/neography-1.0.8/lib/neography/connection.rb:40:in
帖子'←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/neography-1.0.8/lib/neography/rest/gremlin.rb:18:在execute'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/neography-1.0.8/lib/neography/rest.rb:336:in
execute_script&#39;←[0m←[36m# C:/Workspace/comlinked_support/spec/spec_helper.rb:47:inblock (2 levels) in <top (required)>'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/extensions/instance_eval_with_args.rb:16:i n
instance_exec&#39;←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/extensions/instance_eval_with_args.rb:16:ininstance_eval_with_args'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:622:in
instance_eval_wit h_rescue&#39;←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/example.rb:236:在instance_eval_with_resc ue'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:31:in
跑&#39;←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:85:在block in run'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:85:in
每个&#39;←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:85:在run'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:446:in
run_hook&#39;←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:473:在run_after_each_ho oks'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/example.rb:292:in
run_after_each&#39;←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/example.rb:123:在block in run'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/example.rb:248:in
with_around_each_hooks&#39; ←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/example.rb:113:在 run_exam中的run'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:515:in
块&#39;←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:511:在map'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:511:in
run_examples&#39;←[0米←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:496:在 运行中
run'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb:24:in
阻止(2级)&lt;←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb:24:在map'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb:24:in
阻止跑步&#39;←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/reporter.rb:58:在report'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb:21:in
跑&#39;←[0m←[36m# C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:103:在run'←[0m ←[36m # C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:17:in
阻止自动运行&#39;←[0m
mongoid.yml
test:
sessions:
default:
database: comlinked_test
hosts:
- localhost:27017
options:
consistency: :strong
max_retries: 1
retry_interval: 0
options:
raise_not_found_error: false
spec_helper.rb
require 'simplecov'
require 'simplecov-rcov'
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
SimpleCov.start
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rails'
require 'capybara/rspec'
require 'database_cleaner'
OmniAuth.config.test_mode = true
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.expose_current_running_example_as :example
config.use_transactional_fixtures = false
config.color = true
config.include Warden::Test::Helpers
Warden.test_mode!
config.before(:suite) do
Fabrication.clear_definitions
DatabaseCleaner.clean_with(:truncation)
DatabaseCleaner[:active_record].strategy = :transaction
DatabaseCleaner[:mongoid].strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
$neo_server.execute_script("g.clear()")
end
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
config.include Devise::TestHelpers, :type => :controller
config.include Devise::TestHelpers, :type => :view
config.extend DeviseControllerSpecSupport, :type => :controller
config.include DeviseRequestSpecSupport, :type => :feature
config.include Mongoid::Matchers
config.include Capybara::DSL
Warden.test_reset!
end
company_spec.rb
require 'spec_helper'
describe Company do
it { should have_fields(:name, :website, :type).of_type(String) }
end
company.rb
class Company
include Mongoid::Document
include Geocoder::Model::Mongoid
include Mongoid::Slug
field :name, type: String
field :website, type: String
field :type, type: String
end