Permalink
Browse files

Handle case when expected can't be indexed

  • Loading branch information...
1 parent 9b9946c commit ab1d0555852ed19243bcd8591ad67f8d52d0b954 @jeremywadsack committed Apr 8, 2012
@@ -16,7 +16,7 @@ def matches?(actual)
@actual[0] == @expected
end
else
- # TODO: Spec this case
+ raise ArgumentError.new("#{@expected.inspect} does not respond to :[]")
end
end
@@ -44,7 +44,7 @@ def matches?(actual)
@actual[-1] == @expected
end
else
- # TODO: Spec this case
+ raise ArgumentError.new("#{@expected.inspect} does not respond to :[]")
end
end
@@ -35,6 +35,12 @@
}.should fail_with("expected [0, 1, 2, 3, 4] to start with [1, 2]")
end
end
+
+ context Object.new do
+ it "should raise an error if expected value can't be indexed'" do
+ expect { subject.should start_with 0 }.to raise_error(ArgumentError, /does not respond to :\[\]/)
+ end
+ end
end
describe "should_not start_with" do
@@ -109,6 +115,12 @@
}.should fail_with("expected [0, 1, 2, 3, 4] to end with [1, 2]")
end
end
+
+ context Object.new do
+ it "should raise an error if expected value can't be indexed'" do
+ expect { subject.should start_with 0 }.to raise_error(ArgumentError, /does not respond to :\[\]/)
+ end
+ end
end
describe "should_not end_with" do

0 comments on commit ab1d055

Please sign in to comment.