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



27
28
29
30
# File 'lib/consul/spec/matchers.rb', line 27

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

#failure_message_when_negatedObject Also known as: negative_failure_message



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

def failure_message_when_negated
  "expected #{@controller_class} to not check against power #{@expected_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.send(:consul_power_args)
  @actual_args.present? && @actual_args.include?(@expected_args)
end