AASM + RSpec错误:`require':无法加载此类文件-AASM / RSpec(LoadError)

时间:2018-11-27 21:25:34

标签: rspec rspec-rails aasm

AASM状态机已经在我的应用程序中启动并且正在运行,但是我想为我的模型规范文件使用AASM RSpec匹配器。

对于我的Gemfile,我已经安装了以下软件(当然是简短列表):

➜ ✗ gem list

*** LOCAL GEMS ***

aasm (5.0.1, 4.0.8)
capybara (2.6.2)
factory_girl (4.5.0)
factory_girl_rails (4.5.0)
faker (1.7.3)
rspec (3.4.0)
rspec-collection_matchers (1.1.2)
rspec-console (0.6.1)
rspec-core (3.4.2)
rspec-expectations (3.4.0)
rspec-its (1.2.0)
rspec-mocks (3.4.1)
rspec-rails (3.4.2)
rspec-rerun (1.1.0)
rspec-support (3.4.1)

对于AASM doc,我在我的spec_helper.rb文件中添加了require 'aasm/rspec'

require 'capybara/rspec'
require 'faker'
require 'factory_girl'
require 'database_cleaner'
require 'shoulda/matchers'
require 'paperclip/matchers'
require 'factory_girl_association_callbacks'
require 'rspec_controller_context'
require 'capybara/poltergeist'
require 'capybara/dsl'
require 'site_prism'
require 'email_spec'
require 'paper_trail/frameworks/rspec'
require 'aasm/rspec'

在将任何AASM Rspec匹配器添加到我的规范文件之前,我想确保设置正确。所以我只在文件上运行RSpec并收到以下错误:

Coverage report generated for RSpec to /Users/happymeal/coverage. 387 / 1272 LOC (30.42%) covered.
/Users/happymeal/.rvm/gems/ruby-2.2.9/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- aasm/rspec (LoadError)
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `block in require'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
    from /Users/happymeal/spec/rails_helper.rb:23:in `<top (required)>'
    from /Users/happymeal/spec/features/users/admin_create_spec.rb:1:in `require'
    from /Users/happymeal/spec/features/users/admin_create_spec.rb:1:in `<top (required)>'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/gems/rspec-core-3.4.2/lib/rspec/core/configuration.rb:1361:in `load'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/gems/rspec-core-3.4.2/lib/rspec/core/configuration.rb:1361:in `block in load_spec_files'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/gems/rspec-core-3.4.2/lib/rspec/core/configuration.rb:1359:in `each'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/gems/rspec-core-3.4.2/lib/rspec/core/configuration.rb:1359:in `load_spec_files'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/gems/rspec-core-3.4.2/lib/rspec/core/runner.rb:106:in `setup'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/gems/rspec-core-3.4.2/lib/rspec/core/runner.rb:92:in `run'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/gems/rspec-core-3.4.2/lib/rspec/core/runner.rb:78:in `run'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/gems/rspec-core-3.4.2/lib/rspec/core/runner.rb:45:in `invoke'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/gems/rspec-core-3.4.2/exe/rspec:4:in `<top (required)>'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/bin/rspec:23:in `load'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/bin/rspec:23:in `<main>'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/bin/ruby_executable_hooks:24:in `eval'
    from /Users/happymeal/.rvm/gems/ruby-2.2.9/bin/ruby_executable_hooks:24:in `<main>'

是的,我的规格文件的顶部是require 'rails_helper'

我有一种感觉,我真的很想念它。感谢所有帮助,因为我希望能够使用transition_fromhave_stateallow_eventallow_transition_to。预先感谢。

0 个答案:

没有答案