Upgraded Rails and RSpec
[monkeycharger.git] / vendor / plugins / rspec / spec / spec / matchers / match_spec.rb
blobb8aa06b07db11d6b9ea83f6d14f4d4ae53450825
1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
3 describe "should match(expected)" do
4   it "should pass when target (String) matches expected (Regexp)" do
5     "string".should match(/tri/)
6   end
8   it "should fail when target (String) matches expected (Regexp)" do
9     lambda {
10       "string".should match(/rings/)
11     }.should fail
12   end
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
21 describe "should_not match(expected)" do
22   it "should pass when target (String) matches expected (Regexp)" do
23     "string".should_not match(/rings/)
24   end
26   it "should fail when target (String) matches expected (Regexp)" do
27     lambda {
28       "string".should_not match(/tri/)
29     }.should fail
30   end
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