blob: 6551feb5de8c63dd551474acc128d6eb498475b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
describe BeNilMatcher do
it "matches when actual is nil" do
BeNilMatcher.new.matches?(nil).should == true
end
it "does not match when actual is not nil" do
BeNilMatcher.new.matches?("").should == false
BeNilMatcher.new.matches?(false).should == false
BeNilMatcher.new.matches?(0).should == false
end
it "provides a useful failure message" do
matcher = BeNilMatcher.new
matcher.matches?("some string")
matcher.failure_message.should == ["Expected \"some string\"", "to be nil"]
end
it "provides a useful negative failure message" do
matcher = BeNilMatcher.new
matcher.matches?(nil)
matcher.negative_failure_message.should == ["Expected nil", "not to be nil"]
end
end
|