Sha256: 8d3905ee40342966843c410f5e24f04a68f8c8d1aab4287493fd892946353afa

Contents?: true

Size: 911 Bytes

Versions: 118

Compression:

Stored size: 911 Bytes

Contents

module WebMock
  class StubRequestSnippet
    def initialize(request_stub)
      @request_stub = request_stub
    end

    def body_pattern
      request_pattern.body_pattern
    end

    def to_s(with_response = true)
      request_pattern = @request_stub.request_pattern
      string = "stub_request(:#{request_pattern.method_pattern.to_s},"
      string << " \"#{request_pattern.uri_pattern.to_s}\")"

      with = ""

      if (request_pattern.body_pattern)
        with << ":body => #{request_pattern.body_pattern.to_s}"
      end

      if (request_pattern.headers_pattern)
        with << ",\n       " unless with.empty?

        with << ":headers => #{request_pattern.headers_pattern.to_s}"
      end
      string << ".\n  with(#{with})" unless with.empty?
      if with_response
        string << ".\n  to_return(:status => 200, :body => \"\", :headers => {})"
      end
      string
    end
  end
end

Version data entries

118 entries across 109 versions & 8 rubygems

Version Path
cloudsmith-api-2.0.16 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.15 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.14 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.13 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.12 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.11 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.10 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.9 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.8 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.7 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.6 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.5 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.4 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.3 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.2 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.1 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-2.0.0 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-1.142.3 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-1.120.3 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb
cloudsmith-api-1.61.3 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/lib/webmock/stub_request_snippet.rb