Skip to content

Instantly share code, notes, and snippets.

@ianpetzer
Created July 22, 2013 10:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianpetzer/6052955 to your computer and use it in GitHub Desktop.
Save ianpetzer/6052955 to your computer and use it in GitHub Desktop.
describe "mocked query of web service" do
it "should perform correct action on system data based on mocked response" do
RestClient = double
file = File.open('RELATIVE_FILE_PATH_HERE', 'r') #Relative to root of Rails app
data = file.read
file.close
response = double
response.stub(:code) { 200 }
response.stub(:body) { data }
response.stub(:headers) { {} }
RestClient.stub(:get) { response }
YourApp.call_method_that_results_in_web_service_query
#Your assertions here
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment