Sha256: c9e001863a59ae6dc3d57ddca86bc77dbd8268c244f57a82d1955aba9646dc93

Contents?: true

Size: 820 Bytes

Versions: 2

Compression:

Stored size: 820 Bytes

Contents

module WebMock

  class RequestProfile < Request
    
    attr_reader :with_block

    def with(options = {}, &block)
      assign_options(options)
      @with_block = block
      self
    end
    
    def body=(body)
      @body = Body.new(body)
    end
    
    def to_s
      string = super
      string << " with given block" if @with_block
      string
    end

    class Body

      attr_reader :data

      def initialize(data)
        @data = data
      end

      def ==(other)
        other = Body.new(other) unless other.is_a?(Body)
        other.is_a?(Body) &&
          (other.is_empty? && self.is_empty? || other.data == self.data || self.data === other.data )        
      end

      def is_empty?
        @data.nil? || @data == ""
      end

      def to_s
        @data
      end

    end

  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webmock-0.9.1 lib/webmock/request_profile.rb
webmock-0.9.0 lib/webmock/request_profile.rb