Skip to content

Instantly share code, notes, and snippets.

@mostlyobvious
Created May 24, 2013 20:32
Show Gist options
  • Save mostlyobvious/5646319 to your computer and use it in GitHub Desktop.
Save mostlyobvious/5646319 to your computer and use it in GitHub Desktop.
require 'bogus/rspec'
class Model
def initialize(argument)
end
def self.from_argument(argument)
self.new(argument)
end
end
class Service
attr_reader :model_factory
def initialize(model_factory)
@model_factory = model_factory
end
def run(argument)
model_factory.from_argument(argument)
end
end
describe Service do
fake(:model_class, as: :class) { Model }
let(:argument) { :dummy }
let(:service) { described_class.new(model_class) }
before { service.run(argument) }
specify { model_class.should have_received.from_argument(argument) }
specify { model_class.should have_received.new(argument) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment