Sha256: 01337ab3d4960cb04595f2469aed60afadb8242679003af9f998069e447d51ae

Contents?: true

Size: 1.06 KB

Versions: 47

Compression:

Stored size: 1.06 KB

Contents

module Spec
  module Matchers
    
    class Has #:nodoc:
      def initialize(sym, *args)
        @sym = sym
        @args = args
      end
      
      def matches?(target)
        @target = target
        begin
          return target.send(predicate, *@args)
        rescue => @error
          # This clause should be empty, but rcov will not report it as covered
          # unless something (anything) is executed within the clause
          rcov_error_report = "http://eigenclass.org/hiki.rb?rcov-0.8.0"
        end
        return false
      end
      
      def failure_message
        raise @error if @error
        "expected ##{predicate}(#{@args[0].inspect}) to return true, got false"
      end
      
      def negative_failure_message
        raise @error if @error
        "expected ##{predicate}(#{@args[0].inspect}) to return false, got true"
      end
      
      def description
        "have key #{@args[0].inspect}"
      end
      
      private
        def predicate
          "#{@sym.to_s.sub("have_","has_")}?".to_sym
        end
        
    end
 
  end
end

Version data entries

47 entries across 47 versions & 8 rubygems

Version Path
deckshuffler-0.0.2 vendor/plugins/rspec/lib/spec/matchers/has.rb
has_finder-0.1.1 spec/rails/vendor/plugins/rspec/lib/spec/matchers/has.rb
has_finder-0.1.2 spec/rails/vendor/plugins/rspec/lib/spec/matchers/has.rb
has_finder-0.1.3 spec/rails/vendor/plugins/rspec/lib/spec/matchers/has.rb
picolena-0.0.99 app_generators/picolena/templates/vendor/plugins/rspec/lib/spec/matchers/has.rb
picolena-0.1.1 rails_plugins/rspec/lib/spec/matchers/has.rb
picolena-0.1.0 rails_plugins/rspec/lib/spec/matchers/has.rb
picolena-0.1.4 rails_plugins/rspec/lib/spec/matchers/has.rb
picolena-0.1.2 rails_plugins/rspec/lib/spec/matchers/has.rb
picolena-0.1.3 rails_plugins/rspec/lib/spec/matchers/has.rb
picolena-0.1.5 rails_plugins/rspec/lib/spec/matchers/has.rb
puppet-0.23.0 test/lib/spec/matchers/has.rb
puppet-0.22.4 test/lib/spec/matchers/has.rb
puppet-0.23.2 test/lib/spec/matchers/has.rb
puppet-0.23.1 test/lib/spec/matchers/has.rb
riess-0.0.8 vendor/rspec-0.8.2/lib/spec/matchers/has.rb
rspec-0.8.0 lib/spec/matchers/has.rb
rspec-0.8.1 lib/spec/matchers/has.rb
rspec-0.9.3 lib/spec/matchers/has.rb
rspec-1.0.1 lib/spec/matchers/has.rb