Created
January 30, 2012 20:13
-
-
Save megatux/1706396 to your computer and use it in GitHub Desktop.
mock web access (http open) with webmock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#In Gemfile: | |
group :test do | |
gem 'webmock' | |
end | |
#In test class: | |
def setup | |
mock_file = Rails.root.join("test", "fixtures", "some_saved_website.html") | |
stub_request(:get, /http:\/\/www.some_web.com\/*/). | |
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}). | |
to_return(:status => 200, :body => File.new(mock_file), :headers => {}) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment