Permalink
Browse files

Protect against unmatchable classes in flash matcher

  • Loading branch information...
1 parent a74cee3 commit 27841b7b4c82de6c67b4047e89f21e411edc3359 @grosser grosser committed with drapergeek Sep 1, 2012
@@ -25,6 +25,9 @@ def initialize
attr_reader :failure_message, :negative_failure_message
def to(value)
+ if !value.is_a?(String) && !value.is_a?(Regexp)
+ raise "cannot match against #{value.inspect}"
+ end
@value = value
self
end
@@ -1,6 +1,12 @@
require 'spec_helper'
describe Shoulda::Matchers::ActionController::SetTheFlashMatcher do
+ it "should fail with unmatchable to" do
+ expect{
+ set_the_flash.to(1).should
+ }.to raise_error("cannot match against 1")
+ end
+
context "a controller that sets a flash message" do
let(:controller) { build_response { flash[:notice] = 'value' } }

0 comments on commit 27841b7

Please sign in to comment.