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

« back to all changes in this revision

Viewing changes to vendor/gems/rspec/examples/pure/custom_expectation_matchers.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
module AnimalSpecHelper
 
2
  class Eat
 
3
    def initialize(food)
 
4
      @food = food
 
5
    end
 
6
    
 
7
    def matches?(animal)
 
8
      @animal = animal
 
9
      @animal.eats?(@food)
 
10
    end
 
11
    
 
12
    def failure_message
 
13
      "expected #{@animal} to eat #{@food}, but it does not"
 
14
    end
 
15
    
 
16
    def negative_failure_message
 
17
      "expected #{@animal} not to eat #{@food}, but it does"
 
18
    end
 
19
  end
 
20
    
 
21
  def eat(food)
 
22
    Eat.new(food)
 
23
  end
 
24
end
 
25
 
 
26
module Animals
 
27
  class Animal
 
28
    def eats?(food)
 
29
      return foods_i_eat.include?(food)
 
30
    end
 
31
  end
 
32
  
 
33
  class Mouse < Animal
 
34
    def foods_i_eat
 
35
      [:cheese]
 
36
    end
 
37
  end
 
38
 
 
39
  describe Mouse do
 
40
    include AnimalSpecHelper
 
41
    before(:each) do
 
42
      @mouse = Animals::Mouse.new
 
43
    end
 
44
  
 
45
    it "should eat cheese" do
 
46
      @mouse.should eat(:cheese)
 
47
    end
 
48
  
 
49
    it "should not eat cat" do
 
50
      @mouse.should_not eat(:cat)
 
51
    end
 
52
  end
 
53
 
 
54
end