When you use Shoulda with RSpec, what you're doing most of the time is
using Shoulda *matchers* inside RSpec. For example, you could use
Shoulda's ActiveRecord matchers:
describe Report do
it { should belong_to(:project) }
it { should validate_presence_of(:project_id) }
it { should have_db_index(:project_id) }
end
The "have_db_index()"-like methods are the *matchers*.
Email Spec is another library that includes matchers:
Spec::Runner.configure do |config|
config.include(EmailSpec::Helpers)
config.include(EmailSpec::Matchers)
end
It is used like this:
it "should be delivered to the email passed in" do
should deliver_to("jo...@yahoo.com")
end
it "should contain the user's name in the mail body" do
@email.should have_body_text(/Jojo Binks/)
end
> --
> Individuals over processes. Interactions over tools.
>
> Agile Rails training from thoughtbot, the makers of Clearance, Shoulda, & Factory Girl:
> http://thoughtbot.com/services/training
>
> The Shoulda group:
> http://groups.google.com/group/shoulda
>
> To post to this group, send email to
> sho...@googlegroups.com
>
> To unsubscribe from this group, send email to
> shoulda+u...@googlegroups.com
>
Thanks for the explanation. It makes more sense now.
So I assume that I have to use RSpec if I want to use email-spec? I'd like to use email-spec with Test::Unit instead, and I had been wondering whether Shoulda could somehow make email-spec believe it was calling RSpec when in fact it was calling Test::Unit. But since the Shoulda matchers are where Shoulda integrates with RSpec I guess it's not possible. Is that right?
Thanks again,
Andy Stewart
-------
http://airbladesoftware.com
A nice thing about the transition is that the RSpec test runner can
run Test::Unit/Shoulda suites, so if you have an existing TU suite,
can just convert tests to RSpec as you change them and write in RSpec
for new code while the whole suite continues to run.
That's good to know. Thanks for all the help!
This is very much what I was hoping would be the case -- thanks for clarifying it.
I had a go at writing a single wrapper ("macro") for email-spec, with the aim of calling that from a step definition instead of the out-of-the-box matcher:
Unfortunately I ran into a `uninitialized constant Shoulda::Assertions (NameError)`. Is there a simple solution to this?