~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to vendor/gems/rspec/spec/spec/matchers/match_spec.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mfrom: (1.1.8 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080726154345-c03m49twzxewdwjn
Tags: 0.24.5-2
* Fix puppetlast to work with 0.24.5
* Adjust logcheck to match against new log messages in 0.24.5
* Update standards version to 3.8.0 (no changes)
* Update changelog to reduce length of line to make lintian happy

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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