Sha256: b6ffcf34da8684eca1fa84bfb8fc47dc2e23b7cac44ece4634358a48a966baa6

Contents?: true

Size: 1018 Bytes

Versions: 7

Compression:

Stored size: 1018 Bytes

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.instance_variable_get('@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 negative_failure_message
          "expected #{@controller_class} to not check against power #{@expected_args.inspect}"
        end

        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-0.12.0 lib/consul/spec/matchers.rb
consul-0.11.2 lib/consul/spec/matchers.rb
consul-0.11.1 lib/consul/spec/matchers.rb
consul-0.11.0 lib/consul/spec/matchers.rb
consul-0.10.2 lib/consul/spec/matchers.rb
consul-0.10.1 lib/consul/spec/matchers.rb
consul-0.10.0 lib/consul/spec/matchers.rb