Class: Everdeen::Expectation

Inherits:
Object
  • Object
show all
Defined in:
lib/everdeen/expectation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Expectation

Returns a new instance of Expectation.



5
6
7
8
9
10
11
12
13
# File 'lib/everdeen/expectation.rb', line 5

def initialize(args = {})
  args.each do |key, value|
    next if ['response', 'request_criteria'].include?(key.to_s)
    instance_variable_set("@#{key}", value)
  end

  add_response(args[:response] || args['response'])
  add_request(args[:request_criteria] || args['request_criteria'])
end

Instance Attribute Details

#max_matchesObject (readonly)

Returns the value of attribute max_matches.



3
4
5
# File 'lib/everdeen/expectation.rb', line 3

def max_matches
  @max_matches
end

#request_criteriaObject (readonly)

Returns the value of attribute request_criteria.



3
4
5
# File 'lib/everdeen/expectation.rb', line 3

def request_criteria
  @request_criteria
end

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/everdeen/expectation.rb', line 3

def response
  @response
end

#uuidObject (readonly)

Returns the value of attribute uuid.



3
4
5
# File 'lib/everdeen/expectation.rb', line 3

def uuid
  @uuid
end

Instance Method Details

#pass_throughObject



15
16
17
# File 'lib/everdeen/expectation.rb', line 15

def pass_through
  !!@pass_through
end

#store_matching_requestsObject



19
20
21
# File 'lib/everdeen/expectation.rb', line 19

def store_matching_requests
  !!@store_matching_requests
end

#to_hashObject



23
24
25
26
27
28
29
30
31
# File 'lib/everdeen/expectation.rb', line 23

def to_hash
  {
    store_matching_requests: store_matching_requests,
    max_matches: max_matches,
    pass_through: pass_through,
    request_criteria: request_criteria.to_hash,
    respond_with: response.to_hash
  }
end