changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/spec/spec/matchers/match_spec.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
3describe "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
19end
20
21describe "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
37end