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

« back to all changes in this revision

Viewing changes to vendor/gems/rspec/lib/spec/mocks/order_group.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 Spec
 
2
  module Mocks
 
3
    class OrderGroup
 
4
      def initialize error_generator
 
5
        @error_generator = error_generator
 
6
        @ordering = Array.new
 
7
      end
 
8
      
 
9
      def register(expectation)
 
10
        @ordering << expectation
 
11
      end
 
12
      
 
13
      def ready_for?(expectation)
 
14
        return @ordering.first == expectation
 
15
      end
 
16
      
 
17
      def consume
 
18
        @ordering.shift
 
19
      end
 
20
      
 
21
      def handle_order_constraint expectation
 
22
        return unless @ordering.include? expectation
 
23
        return consume if ready_for?(expectation)
 
24
        @error_generator.raise_out_of_order_error expectation.sym
 
25
      end
 
26
      
 
27
    end
 
28
  end
 
29
end