Rspec 0示例,0次失败ActiveRecord :: Base:Class(NoMethodError)

时间:2014-12-12 20:09:06

标签: activerecord rspec ruby-on-rails-4.1 nomethoderror

当我运行'rspec spec / models / behavior_spec.rb'时,我收到以下错误

Finished in 0.01035 seconds (files took 6.44 seconds to load)
0 examples, 0 failures    
/Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.1.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined method `increment_open_transactions' for ActiveRecord::Base:Class (NoMethodError)
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/database_cleaner-0.9.1/lib/database_cleaner/active_record/transaction.rb:13:in `start'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/database_cleaner-0.9.1/lib/database_cleaner/base.rb:73:in `start'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/database_cleaner-0.9.1/lib/database_cleaner/configuration.rb:75:in `block in start'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/database_cleaner-0.9.1/lib/database_cleaner/configuration.rb:75:in `each'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/database_cleaner-0.9.1/lib/database_cleaner/configuration.rb:75:in `start'
from /Users/NamNguyen/Documents/gomoment/rev1/spec/support/factory_girl.rb:7:in `block (2 levels) in <top (required)>'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:294:in `instance_exec'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:294:in `instance_exec'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:349:in `run'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:410:in `block in run'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:410:in `each'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:410:in `run'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:485:in `run'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:111:in `block in run_specs'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/reporter.rb:54:in `report'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:108:in `run_specs'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:86:in `run'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke'
from /Users/NamNguyen/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/exe/rspec:4:in `<top (required)>'
from /Users/NamNguyen/.rbenv/versions/2.1.1/bin/rspec:23:in `load'
from /Users/NamNguyen/.rbenv/versions/2.1.1/bin/rspec:23:in `<main>'

这是我在Gemfile中的组测试开发部分

group :test, :development do
  gem 'rspec-rails', '~> 3.0.0'
  gem "factory_girl_rails", "~> 4.0"
end

这是我的behavior_spec.rb

require 'spec_helper'
require 'rails_helper'

Rspec.describe Behavior, :type => :model do
  describe ".match_all?" do
    it "should be true if pattern is nil" do
    end
  end
end

我搜索了有关获取0 example, 0 failures的其他帖子,但没有任何内容适用于这种情况。非常感谢你提前帮助。

0 个答案:

没有答案