Sha256: 57dc1bd30633c92a7343181b961f785233efaf830292389f1862c87a2781917f

Contents?: true

Size: 1.12 KB

Versions: 12

Compression:

Stored size: 1.12 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.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 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

12 entries across 12 versions & 1 rubygems

Version Path
consul-1.0.2 lib/consul/spec/matchers.rb
consul-1.0.1 lib/consul/spec/matchers.rb
consul-1.0.0 lib/consul/spec/matchers.rb
consul-0.14.1 lib/consul/spec/matchers.rb
consul-0.14.0 lib/consul/spec/matchers.rb
consul-0.13.2 lib/consul/spec/matchers.rb
consul-0.13.1 lib/consul/spec/matchers.rb
consul-0.13.0 lib/consul/spec/matchers.rb
consul-0.12.4 lib/consul/spec/matchers.rb
consul-0.12.3 lib/consul/spec/matchers.rb
consul-0.12.2 lib/consul/spec/matchers.rb
consul-0.12.1 lib/consul/spec/matchers.rb