Class: Spec::Example::ExampleProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/vendor/plugins/rspec/lib/spec/example/example_proxy.rb

Overview

Lightweight proxy for an example. This is the object that is passed to example-related methods in Spec::Runner::Formatter::BaseFormatter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description = nil, options = {}, location = nil) ⇒ ExampleProxy

:nodoc:



7
8
9
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_proxy.rb', line 7

def initialize(description=nil, options={}, location=nil) # :nodoc:
  @description, @options, @location = description, options, location
end

Instance Attribute Details

#descriptionObject (readonly)

This is the docstring passed to the it() method or any of its aliases



16
17
18
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_proxy.rb', line 16

def description
  @description
end

#locationObject (readonly)

The file and line number at which the represented example was declared. This is extracted from caller, and is therefore formatted as an individual line in a backtrace.



21
22
23
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_proxy.rb', line 21

def location
  @location
end

#optionsObject (readonly)

Optional hash passed to the example declaration



12
13
14
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_proxy.rb', line 12

def options
  @options
end

Instance Method Details

#==(other) ⇒ Object

:nodoc:



36
37
38
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_proxy.rb', line 36

def ==(other) # :nodoc:
  (other.description == description) & (other.location == location)
end

#backtraceObject

Deprecated - use location()



24
25
26
27
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_proxy.rb', line 24

def backtrace
  Spec.deprecate("ExampleProxy#backtrace","ExampleProxy#location")
  location
end

#update(description) ⇒ Object

Convenience method for example group - updates the value of description and returns self.



31
32
33
34
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_proxy.rb', line 31

def update(description) # :nodoc:
  @description = description
  self
end