Fix and improve a couple matcher descriptions.
This commit is contained in:
parent
8cbf94b287
commit
29ebbecf9a
|
@ -17,7 +17,7 @@ module Shoulda # :nodoc:
|
|||
def initialize(url_or_description, context, &block)
|
||||
if block
|
||||
@url_block = block
|
||||
@location = @url_or_description
|
||||
@location = url_or_description
|
||||
else
|
||||
@url = url_or_description
|
||||
@location = @url
|
||||
|
|
|
@ -62,7 +62,12 @@ module Shoulda # :nodoc:
|
|||
end
|
||||
|
||||
def description
|
||||
"send an email"
|
||||
description = "send an email"
|
||||
description << " with a subject of #{@email_subject.inspect}" if @email_subject
|
||||
description << " containing #{@body.inspect}" if @body
|
||||
description << " from #{@sender.inspect}" if @sender
|
||||
description << " to #{@recipient.inspect}" if @recipient
|
||||
description
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Shoulda::Matchers::ActionController::RedirectToMatcher do
|
||||
|
||||
context "a controller that redirects" do
|
||||
before do
|
||||
@controller = build_response { redirect_to '/some/url' }
|
||||
|
@ -34,4 +33,8 @@ describe Shoulda::Matchers::ActionController::RedirectToMatcher do
|
|||
end
|
||||
end
|
||||
|
||||
it "should use the correct description when provided a block" do
|
||||
matcher = redirect_to('somewhere else') { '/some/other/url' }
|
||||
matcher.description.should == 'redirect to somewhere else'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,4 +68,17 @@ describe Shoulda::Matchers::ActionMailer::HaveSentEmailMatcher do
|
|||
should_not have_sent_email.with_subject(/ham/).from('you@example.com').with_body(/ham/).to('them@example.com')
|
||||
end
|
||||
end
|
||||
|
||||
it "should provide a detailed description of the e-mail expected to be sent" do
|
||||
matcher = have_sent_email
|
||||
matcher.description.should == 'send an email'
|
||||
matcher = matcher.with_subject("Welcome!")
|
||||
matcher.description.should == 'send an email with a subject of "Welcome!"'
|
||||
matcher = matcher.with_body("Welcome, human!")
|
||||
matcher.description.should == 'send an email with a subject of "Welcome!" containing "Welcome, human!"'
|
||||
matcher = matcher.from("alien@example.com")
|
||||
matcher.description.should == 'send an email with a subject of "Welcome!" containing "Welcome, human!" from "alien@example.com"'
|
||||
matcher = matcher.to("human@example.com")
|
||||
matcher.description.should == 'send an email with a subject of "Welcome!" containing "Welcome, human!" from "alien@example.com" to "human@example.com"'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue