Class: ResourceKit::Testing::HaveActionMatchers

Inherits:
Object
  • Object
show all
Defined in:
lib/resource_kit/testing/have_action_matchers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action) ⇒ HaveActionMatchers

Returns a new instance of HaveActionMatchers.



6
7
8
# File 'lib/resource_kit/testing/have_action_matchers.rb', line 6

def initialize(action)
  @action = action
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



4
5
6
# File 'lib/resource_kit/testing/have_action_matchers.rb', line 4

def action
  @action
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/resource_kit/testing/have_action_matchers.rb', line 4

def path
  @path
end

#verbObject (readonly)

Returns the value of attribute verb.



4
5
6
# File 'lib/resource_kit/testing/have_action_matchers.rb', line 4

def verb
  @verb
end

Instance Method Details

#at_path(path) ⇒ Object



18
19
20
21
# File 'lib/resource_kit/testing/have_action_matchers.rb', line 18

def at_path(path)
  @path = path
  self
end

#handler_codesObject



38
39
40
# File 'lib/resource_kit/testing/have_action_matchers.rb', line 38

def handler_codes
  @handler_codes ||= []
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
36
# File 'lib/resource_kit/testing/have_action_matchers.rb', line 28

def matches?(subject)
  action = subject.resources.find_action(self.action)
  return false unless action

  %i(check_keys check_path check_verb).inject(true) do |rv, method_name|
    break false unless send(method_name, action)
    true
  end
end

#that_handles(*codes) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/resource_kit/testing/have_action_matchers.rb', line 10

def that_handles(*codes)
  codes.each do |code|
    handler_codes << StatusCodeMapper.code_for(code)
  end

  self
end

#with_verb(verb) ⇒ Object



23
24
25
26
# File 'lib/resource_kit/testing/have_action_matchers.rb', line 23

def with_verb(verb)
  @verb = verb
  self
end