Sha256: c8f4fc61733997d3949bb0dbeaff2eb8ba847c6ed80bf813fe53bc048eafce4b

Contents?: true

Size: 944 Bytes

Versions: 58

Compression:

Stored size: 944 Bytes

Contents

module BeHttp
  include Spec::Matchers
  def be_http(status, headers, body)
    SimpleMatcher.new(nil) do |given, matcher|
      description = (<<-DESC).gsub(/^ +/, "")
      be an http of
      expected status: #{status.inspect}
      actual status  : #{given.status.inspect}

      expected headers containing: #{headers.inspect}
      actual headers             : #{given.headers.inspect}

      expected body containing: #{body.inspect}
      actual body             : #{given.body.inspect}
      DESC
      matcher.failure_message = description
      matcher.negative_failure_message = "not #{description}"

      passed = true
      unless given.status == status
        passed = false
      end
      unless headers.all?{|k, v| given.headers[k] == headers[k]}
        passed = false
      end
      unless body.is_a?(Regexp) ? given.body =~ body : given.body.include?(body)
        passed = false
      end
      passed
    end
  end
end

Version data entries

58 entries across 30 versions & 8 rubygems

Version Path
pivotal-screw-unit-0.5.0 vendor/js-test-core/spec/spec_helpers/be_http.rb
pivotal-screw-unit-0.5.0 vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb
pivotal-screw-unit-0.5.1 vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb
pivotal-screw-unit-0.5.1 vendor/js-test-core/spec/spec_helpers/be_http.rb
pivotal-screw-unit-0.5.2 vendor/js-test-core/spec/spec_helpers/be_http.rb
pivotal-screw-unit-0.5.2 vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb
pivotal-screw-unit-0.5.3 vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb
pivotal-screw-unit-0.5.3 vendor/js-test-core/spec/spec_helpers/be_http.rb
pivotal-screw-unit-server-0.5.10 vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb
pivotal-screw-unit-server-0.5.10 vendor/js-test-core/spec/spec_helpers/be_http.rb
pivotal-screw-unit-server-0.5.11 vendor/js-test-core/spec/spec_helpers/be_http.rb
pivotal-screw-unit-server-0.5.11 vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb
pivotal-screw-unit-server-0.5.12 vendor/js-test-core/spec/spec_helpers/be_http.rb
pivotal-screw-unit-server-0.5.12 vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb
pivotal-screw-unit-server-0.5.3 vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb
pivotal-screw-unit-server-0.5.3 vendor/js-test-core/spec/spec_helpers/be_http.rb
pivotal-screw-unit-server-0.5.4 vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb
pivotal-screw-unit-server-0.5.4 vendor/js-test-core/spec/spec_helpers/be_http.rb
pivotal-screw-unit-server-0.5.5 vendor/js-test-core/spec/spec_helpers/be_http.rb
pivotal-screw-unit-server-0.5.5 vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb