Class: Consul::Spec::Matchers::CheckPower

Inherits:
Object
  • Object
show all
Defined in:
lib/consul/spec/matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CheckPower

Returns a new instance of CheckPower.



7
8
9
# File 'lib/consul/spec/matchers.rb', line 7

def initialize(*args)
  @expected_args = args
end

Instance Method Details

#descriptionObject



25
26
27
28
# File 'lib/consul/spec/matchers.rb', line 25

def description
  description = "check against power #{@expected_args.inspect}"
  description
end

#failure_messageObject



17
18
19
# File 'lib/consul/spec/matchers.rb', line 17

def failure_message
  "expected #{@controller_class} to check against power #{@expected_args.inspect} but it checked against #{@actual_args.inspect}"
end

#matches?(controller) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/consul/spec/matchers.rb', line 11

def matches?(controller)
  @controller_class = controller.class
  @actual_args = @controller_class.instance_variable_get('@consul_power_args')
  @actual_args.present? && @actual_args.include?(@expected_args)
end

#negative_failure_messageObject



21
22
23
# File 'lib/consul/spec/matchers.rb', line 21

def negative_failure_message
  "expected #{@controller_class} to not check against power #{@expected_args.inspect}"
end