mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Merge pull request #7 from chendry/master
Fix for AssignToMatcher failure message when object is of the wrong kind.
This commit is contained in:
commit
224f2e5a70
2 changed files with 14 additions and 2 deletions
|
@ -82,8 +82,8 @@ module Shoulda # :nodoc:
|
||||||
else
|
else
|
||||||
@failure_message =
|
@failure_message =
|
||||||
"Expected action to assign a kind of #{@expected_class} " <<
|
"Expected action to assign a kind of #{@expected_class} " <<
|
||||||
"for #{@variable}, but got #{@variable.inspect} " <<
|
"for #{@variable}, but got #{assigned_value.inspect} " <<
|
||||||
"(#{@variable.class.name})"
|
"(#{assigned_value.class.name})"
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,18 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Shoulda::Matchers::ActionController::AssignToMatcher do
|
describe Shoulda::Matchers::ActionController::AssignToMatcher do
|
||||||
|
|
||||||
|
it "should include the actual class in the failure message" do
|
||||||
|
WrongClass = Class.new do
|
||||||
|
def to_s; "wrong class" end
|
||||||
|
end
|
||||||
|
|
||||||
|
controller = build_response { @var = WrongClass.new }
|
||||||
|
matcher = AssignToMatcher.new(:var).with_kind_of(Fixnum)
|
||||||
|
matcher.matches?(controller)
|
||||||
|
|
||||||
|
matcher.failure_message.should =~ /but got wrong class \(WrongClass\)$/
|
||||||
|
end
|
||||||
|
|
||||||
context "a controller that assigns to an instance variable" do
|
context "a controller that assigns to an instance variable" do
|
||||||
before do
|
before do
|
||||||
@controller = build_response { @var = 'value' }
|
@controller = build_response { @var = 'value' }
|
||||||
|
|
Loading…
Reference in a new issue