Class: Spec::Example::ExampleProxy

Inherits:
Object
  • Object
show all
Defined in:
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

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

:nodoc:



7
8
9
# File '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

- (Object) description (readonly)

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



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

def description
  @description
end

- (Object) location (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/spec/example/example_proxy.rb', line 21

def location
  @location
end

- (Object) options (readonly)

Optional hash passed to the example declaration



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

def options
  @options
end

Instance Method Details

- (Object) ==(other)

:nodoc:



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

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

- (Object) backtrace

Deprecated - use location()



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

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

- (Object) update(description)

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



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

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