Skip to content

Instantly share code, notes, and snippets.

@benedictfischer09
Created January 21, 2016 21:02
Show Gist options
  • Save benedictfischer09/49ab39bb772d7d7ca768 to your computer and use it in GitHub Desktop.
Save benedictfischer09/49ab39bb772d7d7ca768 to your computer and use it in GitHub Desktop.
Solution to first TDD exercise
require "spec_helper"
require "signup"
describe Signup do
let(:account) { double('account') }
let(:user) { double('user') }
let(:signup) { Signup.new(email: "user@example.com", account_name: "Example") }
before(:each) do
allow(Account).to receive(:create!).and_return(account)
allow(User).to receive(:create!).and_return(user)
end
describe "#save" do
it "creates an account with one user" do
result = signup.save
expect(Account).to have_received(:create!)
expect(result).to be(true)
end
end
describe "#user" do
it "returns the user created by #save" do
signup.save
expect(signup.user).to eq(user)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment