Skip to content

Instantly share code, notes, and snippets.

@Valarissa
Created November 21, 2012 16:20
Show Gist options
  • Save Valarissa/4125789 to your computer and use it in GitHub Desktop.
Save Valarissa/4125789 to your computer and use it in GitHub Desktop.
How to make your stubs bleed over into other files...
## BAD
shared_examples_for 'NetSuite_BaseRequest' do
before(:each) do
@obj.stub(:endpoint => "http://test.test.com")
@obj.stub(:send_request) do |arg| # We're not testing requests being sent...
arg # Return the request that was to be sent.
end
end
describe "#get" do
it "places parameters in the request uri" do
@obj.get({:id => "test"}).path.should == "/?id=test"
end
it "sends a Get request" do
@obj.get({:id => "test"}).is_a?(Net::HTTP::Get).should == true
end
end
end
## GOOD
shared_examples_for 'NetSuite_BaseRequest' do
describe NetSuite::BaseRequest do
before(:each) do
@obj.stub(:endpoint => "http://test.test.com")
@obj.stub(:send_request) do |arg| # We're not testing requests being sent...
arg # Return the request that was to be sent.
end
end
describe "#get" do
it "places parameters in the request uri" do
@obj.get({:id => "test"}).path.should == "/?id=test"
end
it "sends a Get request" do
@obj.get({:id => "test"}).is_a?(Net::HTTP::Get).should == true
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment