Sha256: 94eb9835de8f701f42a13e79b57490c7b48d2ef123cfeea6cf43c06593cfe0e7

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

module Spec
  module Integration
    module Matchers
      class DisplayObject # :nodoc:
        include ActionController::RecordIdentifier
        
        def initialize(objects, example)
          @objects = objects
          @example = example
        end
        
        def matches?(response)
          @currently_matching = nil
          @objects.each do |e|
            @currently_matching = e
            response.should @example.have_tag("##{dom_id(@currently_matching)}", :count => 1)
          end
          true
        rescue
          false
        end
        
        def failure_message
          "expected to find element having id #{dom_id(@currently_matching)} but none was found"
        end
        
        def negative_failure_message
          "expected not to find elements having ids #{@objects.collect {|e| dom_id(e)}.inspect}"
        end
      end
      
      # Specify that a response should be displaying an object according to
      # the pattern of using _dom_id_.
      #
      def display_object(*objects)
        DisplayObject.new(objects.flatten, self)
      end
      alias_method :display_objects, :display_object
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
radiant-0.7.2 vendor/plugins/spec_integration/lib/spec/integration/matchers/display_object.rb
radiant-0.7.0 vendor/plugins/spec_integration/lib/spec/integration/matchers/display_object.rb
radiant-0.7.1 vendor/plugins/spec_integration/lib/spec/integration/matchers/display_object.rb