Class: Webspicy::Specification::Pre::GlobalRequestHeaders

Inherits:
Object
  • Object
show all
Includes:
Webspicy::Specification::Pre
Defined in:
lib/webspicy/specification/pre/global_request_headers.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{}

Constants included from Condition

Condition::MATCH_ALL

Instance Attribute Summary collapse

Attributes included from Condition

#matching_description, #tester

Instance Method Summary collapse

Methods included from Webspicy::Specification::Pre

#counterexamples

Methods included from Condition

#bind, #fail!, match, #sooner_or_later, #to_s

Constructor Details

#initialize(headers, options = {}, &bl) ⇒ GlobalRequestHeaders

Returns a new instance of GlobalRequestHeaders.



9
10
11
12
13
# File 'lib/webspicy/specification/pre/global_request_headers.rb', line 9

def initialize(headers, options = {}, &bl)
  @headers = headers
  @options = DEFAULT_OPTIONS.merge(options)
  @matcher = bl
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



14
15
16
# File 'lib/webspicy/specification/pre/global_request_headers.rb', line 14

def headers
  @headers
end

#matcherObject (readonly)

Returns the value of attribute matcher.



14
15
16
# File 'lib/webspicy/specification/pre/global_request_headers.rb', line 14

def matcher
  @matcher
end

Instance Method Details

#instrumentObject



25
26
27
28
29
30
# File 'lib/webspicy/specification/pre/global_request_headers.rb', line 25

def instrument
  extra = headers.reject{|k|
    test_case.headers.has_key?(k)
  }
  test_case.headers.merge!(extra)
end

#match(service, pre) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/webspicy/specification/pre/global_request_headers.rb', line 16

def match(service, pre)
  if matcher
    return self if matcher.call(service)
    nil
  else
    self
  end
end