Sha256: 5b8727512845d77362e308dfbb75e0a7225a8cb43bf78690bec24e4af7ae5786

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

module Spec
  module Example
    # Lightweight representation of an example. This is the object
    # that is passed to example-related methods in
    # Spec::Runner::Formatter::BaseFormatter
    class ExampleProxy

      def initialize(description=nil, options={}, location=nil) # :nodoc:
        @description, @options, @location = description, options, location
      end
      
      # This is the docstring passed to the <tt>it()</tt> method or any
      # of its aliases
      attr_reader :description
      
      # Internal use only - used to store options to pass to example
      # when it is initialized
      attr_reader :options # :nodoc:

      # The file and line number at which the represented example
      # was declared. This is extracted from <tt>caller</tt>, and is therefore
      # formatted as an individual line in a backtrace.
      attr_reader :location
      
      # Deprecated - use location()
      def backtrace
        location
      end
      
      # Convenience method for example group - updates the value of
      # <tt>description</tt> and returns self.
      def update(description) # :nodoc:
        @description = description
        self
      end
      
      def ==(other) # :nodoc:
        (other.description == description) & (other.backtrace == backtrace)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec-1.2.1 lib/spec/example/example_proxy.rb
rspec-1.2.2 lib/spec/example/example_proxy.rb