Skip to content

Instantly share code, notes, and snippets.

@yarinb
Created May 18, 2012 21:18
Show Gist options
  • Save yarinb/2727648 to your computer and use it in GitHub Desktop.
Save yarinb/2727648 to your computer and use it in GitHub Desktop.
Rspec stubs are bad practice
require 'rspec/mocks/standalone'
class Service
def self.access_thirdparty_action
puts "communicating with the world!"
end
end
class ServiceManager
def work
puts "before work"
Service.access_thirdparty_action
puts "after work"
end
end
describe Service do
it "works" do
Service.stub!(:access_thirdparty_action)
ServiceManager.new.work
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment