I have the following code (removed unrelated parts):
# Picture.rb
image_accessor :image_file do
puts "config: #{Config.get(:preprocess_image_resize).present?}"
end
image_accessor is provided by dragonfly.
I want to stub Config.get
(which works great for many other specs in other scenarios), but here it does not have any effect.
This is the test:
it "should resize the image file to the given value" do
Config.stub!(:get) { |arg| arg == :preprocess_image_resize ? '1x1' : false }
end
When running the test I expect to see "config: true" in the console. But I always get "config: false".
I cant explain why - perhaps because of the evaluation in the block?
Any ideas how to stub this then?