Sha256: 93dfb7e0f499b9ef0d7a544ad69842b69e0d4920376becaaad9b3c123c7ddc79

Contents?: true

Size: 679 Bytes

Versions: 20

Compression:

Stored size: 679 Bytes

Contents

module WebMock
  
  class ResponsesSequence

    attr_accessor :times_to_repeat

    def initialize(responses)
      @times_to_repeat = 1
      @responses = responses
      @current_position = 0
    end

    def end?
      @times_to_repeat == 0
    end

    def next_response
      if @times_to_repeat > 0
        response = @responses[@current_position]
        increase_position
        response
      else
        @responses.last
      end
    end

    private

    def increase_position
      if @current_position == (@responses.length - 1)
        @current_position = 0
        @times_to_repeat -= 1
      else
        @current_position += 1
      end
    end

  end
  
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
vanity-1.7.1 vendor/ruby/1.9.1/gems/webmock-1.6.4/lib/webmock/responses_sequence.rb
webmock-1.6.4 lib/webmock/responses_sequence.rb
webmock-1.6.2 lib/webmock/responses_sequence.rb
webmock-1.6.1 lib/webmock/responses_sequence.rb
webmock-1.6.0 lib/webmock/responses_sequence.rb
webmock-1.5.0 lib/webmock/responses_sequence.rb
webmock-1.4.0 lib/webmock/responses_sequence.rb
webmock-1.3.5 lib/webmock/responses_sequence.rb
webmock-1.3.4 lib/webmock/responses_sequence.rb
webmock-1.3.3 lib/webmock/responses_sequence.rb
webmock-1.3.2 lib/webmock/responses_sequence.rb
webmock-1.3.1 lib/webmock/responses_sequence.rb
webmock-1.3.0 lib/webmock/responses_sequence.rb
webmock-1.2.2 lib/webmock/responses_sequence.rb
webmock-1.2.1 lib/webmock/responses_sequence.rb
webmock-1.2.0 lib/webmock/responses_sequence.rb
webmock-1.1.0 lib/webmock/responses_sequence.rb
webmock-1.0.0 lib/webmock/responses_sequence.rb
webmock-0.9.1 lib/webmock/responses_sequence.rb
webmock-0.9.0 lib/webmock/responses_sequence.rb