Skip to content

Instantly share code, notes, and snippets.

Created December 12, 2013 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/7933735 to your computer and use it in GitHub Desktop.
Save anonymous/7933735 to your computer and use it in GitHub Desktop.
DT presentation comments
class Car
def initialize(model, engine = ::Engine.new)
@model = model
@engine = engine
end
def running
engine.running
end
def start
engine.start
end
private
attr_access :model, :engine
end
describe User do
let(:user) { User.new }
let(:nasty_external_library) { double(:nasty_external_library) }
before do
allow(::SomeNastyExternalLibrary).to receive(:new) { nasty_external_library }
allow(nasty_external_library).to receive(:activated?) { true }
end
describe "#ready_for_launch?" do
expect(user.ready_for_launch?).to be_true
end
end
class User
def ready_for_launch?
::SomeNastyExternalLibrary.new.activated?
end
end
describe Car do
let(:car) { Car.new("ford", engine) }
let(:engine) { double(:engine) }
describe "#start" do
it "starts the engine" do
expect(engine).to receive(:start)
car.start
end
end
describe "#running" do
let(:running_status) { double(:running_status) }
it "returns the engine running status" do
allow(engine).to receive(:running) { running_status }
expect(car.running).to eq(running_status)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment