Created
July 30, 2014 13:38
-
-
Save pewniak747/125aeb592f4f44cc3c6f to your computer and use it in GitHub Desktop.
This file contains 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
describe CreateInvoice do | |
subject { CreateInvoice.new(user, notification_center, form) } | |
let(:user) { instance_double("User", subscriber?: true) } | |
let(:notification_center) { instance_double("NotificationCenter", invoice_created: nil) | |
let(:form) { instance_double("InvoiceForm", company_name: "ACME Corp.", billing_date: Time.now) | |
describe "passing valid parameters" do | |
it "is successful" do | |
expect(subject.call).to be_success | |
end | |
it "creates invoice" do | |
invoice = subject.call.invoice | |
expect(invoice).to be_persisted | |
expect(invoice.company_name).to eq("ACME Corp.") | |
end | |
it "notifies via notification center" do | |
expect(notification_center).to receive(:invoice_created) | |
subject.call | |
end | |
end | |
describe "user is not a subscriber" do | |
let(:user) { instance_double("User", subscriber?: false) } | |
it "is unsuccessful" do | |
expect(subject.call).not_to be_success | |
expect(subject.error_message).to match("not a subscriber") | |
end | |
end | |
# ... more failure scenarios | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment