Sha256: e28bdf2f5bebe3bcd909dde14e94e359ae24607389b0f60f50f41c9c3ff35631

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

module Spec
  module Example
    # Lightweight proxy for 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
      
      # Optional hash passed to the example declaration
      attr_reader :options

      # This is the docstring passed to the <tt>it()</tt> method or any
      # of its aliases
      attr_reader :description
      
      # 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
        Spec.deprecate("ExampleProxy#backtrace","ExampleProxy#location")
        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.location == location)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec-1.2.6 lib/spec/example/example_proxy.rb
rspec-1.2.5 lib/spec/example/example_proxy.rb