Skip to content

Instantly share code, notes, and snippets.

@bwiggs
Created September 24, 2013 23:50
Show Gist options
  • Save bwiggs/6692978 to your computer and use it in GitHub Desktop.
Save bwiggs/6692978 to your computer and use it in GitHub Desktop.
This was how I solved mocking the request object for a Draper decorator from RSpec.
describe 'ArticleDecorator'
describe '#opengraph_image_url' do
it 'should provide the default image as a fallback' do
request = stub(host: 'local.example.com', port: 3000)
ArticleDecorator.any_instance.stub request: request
ArticleDecorator.new(Article.new).opengraph_image_url.should == "http://local.example.com:3000/images/default.png"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment