spec/rspec/matchers/matcher_spec.rb in rspec-expectations-2.0.0.beta.11 vs spec/rspec/matchers/matcher_spec.rb in rspec-expectations-2.0.0.beta.12
- old
+ new
@@ -228,15 +228,15 @@
matcher.matches?(8).should be_true
end
describe "#match_unless_raises" do
- context "with a passing assertion" do
+ context "with an assertion" do
let(:mod) do
Module.new do
def assert_equal(a,b)
- a == b ? nil : (raise UnexpectedError.new("#{a} does not equal #{b}"))
+ a == b ? nil : (raise UnexpectedError.new("#{b} does not equal #{a}"))
end
end
end
let(:matcher) do
m = mod
@@ -245,14 +245,26 @@
match_unless_raises UnexpectedError do
assert_equal expected, actual
end
end
end
- it "passes as you would expect" do
- matcher.matches?(4).should be_true
+
+ context "with passing assertion" do
+ it "passes" do
+ matcher.matches?(4).should be_true
+ end
end
- it "fails as you would expect" do
- matcher.matches?(5).should be_false
+
+ context "with failing assertion" do
+ it "fails" do
+ matcher.matches?(5).should be_false
+ end
+
+ it "provides the raised exception" do
+ matcher.matches?(5)
+ matcher.rescued_exception.message.
+ should eq("5 does not equal 4")
+ end
end
end
context "with an unexpected error" do
let(:matcher) do