README.rdoc in email_spec-0.3.5 vs README.rdoc in email_spec-0.3.6

- old
+ new

@@ -6,15 +6,15 @@ == Setup script/plugin install git://github.com/bmabey/email-spec.git === Gem Setup + + gem install email_spec - gem install bmabey-email_spec - # config/environments/test.rb - config.gem 'bmabey-email_spec', :lib => 'email_spec' + config.gem 'email_spec', :lib => 'email_spec' === Cucumber To use the steps in features put the following in your env.rb: @@ -30,24 +30,24 @@ This will give you a bunch of steps to get started with in step_definitions/email_steps.rb === RSpec - First you need to require the helpers and matchers in your spec_helper.rb like so: +First you need to require the helpers and matchers in your spec_helper.rb like so: require "email_spec/helpers" require "email_spec/matchers" - You will then need to include EmailSpec::Helpers and EmailSpec::Matchers in your example groups. - If you want to have access to the helpers and matchers in all of your examples you can do the following in your spec_helper.rb: +You will then need to include EmailSpec::Helpers and EmailSpec::Matchers in your example groups. +If you want to have access to the helpers and matchers in all of your examples you can do the following in your spec_helper.rb: Spec::Runner.configure do |config| config.include(EmailSpec::Helpers) config.include(EmailSpec::Matchers) end - Otherwise, you will need to include them in the example groups you wish to use them: +Otherwise, you will need to include them in the example groups you wish to use them: describe "Signup Email" do include EmailSpec::Helpers include EmailSpec::Matchers ... @@ -69,55 +69,55 @@ For more examples, check out examples/rails_root in the source for a small example app that implements these steps. === RSpec - ==== Testing In Isolation ==== - It is often useful to test your mailers in isolation. You can accomplish this by using mocks to verify that the mailer is being called in the correct place and then write focued examples for the actual mailer. This is a simple example from the sample app found in the gem: +==== Testing In Isolation +It is often useful to test your mailers in isolation. You can accomplish this by using mocks to verify that the mailer is being called in the correct place and then write focued examples for the actual mailer. This is a simple example from the sample app found in the gem: - Verify that the mailer is used correctly in the controller (this would apply to a model as well): +Verify that the mailer is used correctly in the controller (this would apply to a model as well): - describe "POST /signup (#signup)" do - it "should deliver the signup email" do - # expect - UserMailer.should_receive(:deliver_signup).with("email@example.com", "Jimmy Bean") - # when - post :signup, "Email" => "email@example.com", "Name" => "Jimmy Bean" - end - end + describe "POST /signup (#signup)" do + it "should deliver the signup email" do + # expect + UserMailer.should_receive(:deliver_signup).with("email@example.com", "Jimmy Bean") + # when + post :signup, "Email" => "email@example.com", "Name" => "Jimmy Bean" + end + end - Examples for the #signup method in UserMailer: +Examples for the #signup method in UserMailer: - describe "Signup Email" do - include EmailSpec::Helpers - include EmailSpec::Matchers - include ActionController::UrlWriter + describe "Signup Email" do + include EmailSpec::Helpers + include EmailSpec::Matchers + include ActionController::UrlWriter - before(:all) do - @email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks") - end + before(:all) do + @email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks") + end - it "should be set to be delivered to the email passed in" do - @email.should deliver_to("jojo@yahoo.com") - end + it "should be set to be delivered to the email passed in" do + @email.should deliver_to("jojo@yahoo.com") + end - it "should contain the user's message in the mail body" do - @email.should have_text(/Jojo Binks/) - end + it "should contain the user's message in the mail body" do + @email.should have_text(/Jojo Binks/) + end - it "should contain a link to the confirmation link" do - @email.should have_text(/#{confirm_account_url}/) - end + it "should contain a link to the confirmation link" do + @email.should have_text(/#{confirm_account_url}/) + end - it "should have the correct subject" do - @email.should have_subject(/Account confirmation/) - end - + it "should have the correct subject" do + @email.should have_subject(/Account confirmation/) end - ==== Using the helpers when not testing in isolation ==== + end - Don't. :) Seriously, if you do just take a look at the helpers and use them as you wish. +==== Using the helpers when not testing in isolation + +Don't. :) Seriously, if you do just take a look at the helpers and use them as you wish. == Original Authors Ben Mabey, Aaron Gibralter, Mischa Fierer