Created
January 21, 2016 21:02
-
-
Save benedictfischer09/49ab39bb772d7d7ca768 to your computer and use it in GitHub Desktop.
Solution to first TDD exercise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "spec_helper" | |
require "signup" | |
describe Signup do | |
let(:account) { double('account') } | |
let(:user) { double('user') } | |
let(:signup) { Signup.new(email: "[email protected]", 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