jdliss / shoulda-callback-matchers

Test existence of your Rails callbacks without having to call them
MIT License
134 stars 18 forks source link

undefined method `callback' #30

Closed YassineDM closed 4 years ago

YassineDM commented 4 years ago

I got this error message with a callback, which does not seem to be related to Spring as mentioned in the doc:

Failure/Error: it { is_expected.to callback(:after_create_callback).after(:create) }

NoMethodError:
  undefined method `callback' for #<RSpec::ExampleGroups::UserAccount::Callbacks::FiresCallbacks:0x00007fbab10cba48>
# ./spec/models/user_account_spec.rb:80:in `block (4 levels) in <top (required)>'
# ./spec/rails_helper.rb:69:in `block (3 levels) in <top (required)>'
# ./spec/rails_helper.rb:68:in `block (2 levels) in <top (required)>'

Here is how Shoulda Matchers are configured in rails_helper.rb:

Shoulda::Matchers.configure do |config|
  config.integrate do |with|
    with.test_framework :rspec
    with.library :rails
  end
end

In Gemfile:

gem 'rails', '~> 6.0.2'

group :development, :test do
  gem 'rspec-rails', '~> 3.8'
  # ...
end

group :test do
  gem 'shoulda-matchers'
  # ...
end
chrisgeek commented 4 years ago

@YassineDM I think the Readme says

group :test do
  gem 'shoulda-callback-matchers', '~> 1.1.1'
end

and not

group :test do
  gem 'shoulda-matchers'
end
YassineDM commented 4 years ago

@chrisgeek, you're right, it is now perfectly working. Sorry for this careless mistake...