Hi RSpec list,
I have a question about the "expect { ... }.to change" construct
(https://www.relishapp.com/rspec/rspec-expectations...
Is there an idiomatic way to test for multiple changes (i.e. chaining)?
Right now I'm doing
expect {
expect {
foobuzz
}.to change { a }
}.to change { b }
to test that calling foobuzz changes a and b. Is there a more compact
way?
(Using tap turns out rather ugly: .tap { |proc| proc.to change { a }
}. Not an improvement IMO.)
Thanks,
Jo
on 2011-12-08 23:11
on 2011-12-08 23:34
On Thu, Dec 8, 2011 at 3:30 PM, Jo Liss <joliss42@gmail.com> wrote: > expect { > foobuzz > }.to change { a } > }.to change { b } > > to test that calling foobuzz changes a and b. Is there a more compact way? If there are two outcomes, then I like to write two examples: it "changes a" do expect { foobuzz }.to change {a} end it "changes b" do expect { foobuzz }.to change {b} end HTH, David
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.