Sha256: 00df3c11a8b1b9f7ba0a363c0e4f5798175c01c2048921ed92286e387bbfd6fc

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

module Consul
  module Spec
    module Matchers

      class CheckPower

        def initialize(*args)
          @expected_args = args
        end

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

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

        def failure_message_when_negated
          "expected #{@controller_class} to not check against power #{@expected_args.inspect}"
        end
        # Compatibility for older rspec versions
        alias_method :negative_failure_message, :failure_message_when_negated

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

      end

      def check_power(*args)
        CheckPower.new(*args)
      end

    end
  end
end

ActiveSupport::TestCase.send :include, Consul::Spec::Matchers

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
consul-1.3.2 lib/consul/spec/matchers.rb
consul-1.3.1 lib/consul/spec/matchers.rb
consul-1.2.0 lib/consul/spec/matchers.rb
consul-1.1.2 lib/consul/spec/matchers.rb
consul-1.1.1 lib/consul/spec/matchers.rb
consul-1.1.0 lib/consul/spec/matchers.rb
consul-1.0.3 lib/consul/spec/matchers.rb