Add "calling_it" method to the ExampleGroup DSL
Created by: exviva
Treats the subject as a proc, to allow expressing expectations on consequences of calling the subject, not only its properties.
The following examples are equivalent:
describe BankTransfer, "::perform" do
let(:bank_account) { BankAccount.new(100) }
subject { BankTransfer.perform(bank_account, 30) }
it "should change bank account deposit" do
expect { subject }.to change { bank_account.deposit }.by(30)
# or: proc { subject }.should change { bank_account.deposit }.by(30)
end
end
describe BankTransfer, "::perform" do
let(:bank_account) { BankAccount.new(100) }
subject { BankTransfer.perform(bank_account, 30) }
calling_it { should change { bank_account.deposit }.by(30) }
end
I'm not 100% happy with the name, but maybe the community would have better suggestions?
Also, I'd gladly add more documentation if the idea gets accepted (just need some hints where exactly to add it).