Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paperclip using rspec

I have a Rails 3.2 application in which I use paperclip to upload and store file attachments. This works great in itself, but I want to test it using rspec.

Now, the documentation provides some pretty nifty shoulda matchers to do just that. However, when I try to run them, it says my configuration in the spec helper is wrong:

uninitialized constant Paperclip::Shoulda (NameError)

I have the following in my spec helper:

RSpec.configure do |config|
  config.include Paperclip::Shoulda::Matchers
end

And this is in my Gemfile:

group :development, :test do
  gem "rspec-rails", "~> 2.0"
  gem "shoulda-matchers"
end

I am not sure what I am missing here?

like image 345
weltschmerz Avatar asked Apr 17 '26 21:04

weltschmerz


1 Answers

I found out what the problem was. I had require 'paperclip/matchers' behind the shoulda matchers, but instead I first need to require the paper clip matchers, and only afterwards include the shoulda matchers.

like image 173
weltschmerz Avatar answered Apr 20 '26 11:04

weltschmerz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!