]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/spec/spec/matchers/match_spec.rb
added RSpec and RSpec on Rails
[rails.git] / vendor / gems / rspec-1.1.2 / spec / spec / matchers / match_spec.rb
1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
3 describe "should match(expected)" do
4   it "should pass when target (String) matches expected (Regexp)" do
5     "string".should match(/tri/)
6   end
7
8   it "should fail when target (String) does not match expected (Regexp)" do
9     lambda {
10       "string".should match(/rings/)
11     }.should fail
12   end
13   
14   it "should provide message, expected and actual on failure" do
15     matcher = match(/rings/)
16     matcher.matches?("string")
17     matcher.failure_message.should == ["expected \"string\" to match /rings/", /rings/, "string"]
18   end
19 end
20
21 describe "should_not match(expected)" do
22   it "should pass when target (String) matches does not match (Regexp)" do
23     "string".should_not match(/rings/)
24   end
25
26   it "should fail when target (String) matches expected (Regexp)" do
27     lambda {
28       "string".should_not match(/tri/)
29     }.should fail
30   end
31
32   it "should provide message, expected and actual on failure" do
33     matcher = match(/tri/)
34     matcher.matches?("string")
35     matcher.negative_failure_message.should == ["expected \"string\" not to match /tri/", /tri/, "string"]
36   end
37 end