Class: RSpec::Http::ResponseCodeMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-test-subject/monkey-patches/rspec-http.rb

Instance Method Summary collapse

Instance Method Details

#common_messageObject



16
17
18
19
20
21
22
23
# File 'lib/vagrant-test-subject/monkey-patches/rspec-http.rb', line 16

def common_message
  status_code = (@target.respond_to? :status) ? @target.status : @target.code
  message = "have a response code of #{@expected_code}, but got #{status_code}"
  if status_code == 302 || status_code == 201
    message += " with a location of #{@target['Location'] || @target['location']}" 
  end
  message
end

#matches?(target) ⇒ Boolean

Override, this stupidly doesn’t work with the stdlib net/http

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
# File 'lib/vagrant-test-subject/monkey-patches/rspec-http.rb', line 6

def matches?(target)
  @target = target
  if @target.respond_to? :status then
    return @target.status.to_s == @expected_code.to_s
  elsif @target.respond_to? :code then
    # Net::HTTPResponse
    return @target.code.to_s == @expected_code.to_s
  end
end