Skip to content

Instantly share code, notes, and snippets.

@balinterdi
Created July 20, 2010 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balinterdi/482904 to your computer and use it in GitHub Desktop.
Save balinterdi/482904 to your computer and use it in GitHub Desktop.
require "user_creation_service"
require "spec"
require "rr"
Spec::Runner.configure do |config|
config.mock_with RR::Adapters::Rspec
end
describe UserCreationService do
before do
@user = stub
@params = { :name => "Matz", :language => "Ruby" }
mock(@user_class = Object.new).create(@params) { @user }
mock(@log_class = Object.new).new_user(@user)
@service = UserCreationService.new(@user_class, @log_class)
@service.create(@params)
end
it "creates the user with the supplied parameters" do
@user_class.should have_received.create(@params)
end
it "logs the creation of the user" do
@log_class.should have_received.new_user(@user)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment