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/)
8 it "should fail when target (String) does not match expected (Regexp)" do
10 "string".should match(/rings/)
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"]
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/)
26 it "should fail when target (String) matches expected (Regexp)" do
28 "string".should_not match(/tri/)
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"]