未定义的方法`check_pending!' for ActiveRecord :: Migration(Rails教程)

时间:2014-02-02 15:41:40

标签: ruby-on-rails ruby rails-activerecord

我的sample_app \ spec \ requests \ user_pages_spec.rb文件:

 require 'spec_helper'

describe "User pages" do

  subject { page }

  describe "signup page" do
    before { visit signup_path }

    it { should have_content('Sign up') }
    it { should have_title(full_title('Sign up')) }
  end
end

经过测试后我得到了:

No DRb server is running. Running in local process instead ...
    -- check_pending!()
    C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:465:in `block in method_missing': undefined method `check_pending!' for #<ActiveRecord::Migration:0x4adcf18> (NoMethodError)
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:438:in `block in say_with_time'

1 个答案:

答案 0 :(得分:5)

check_pending!()它是Rails 4中ActiveRecord :: Migration的一种方法,在读取错误时,发现你当前的Rails版本是3.2,所以这个方法不起作用,如果你使用Spork和RSpec你会发现Spork改变了你的spec / spec_helper.rb文件并添加了几行包括这一行:

 ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)

如果您想继续测试而不检查是否仍有任何迁移正在运行,那么您所要做的就是对此行进行评论,如果您不使用Spork,测试仍然有效,仍然建议您打开spec / spec_helper.rb并查看代码。