Class: Spec::Example::ExampleGroupProxy
- Defined in:
- lib/vendor/plugins/rspec/lib/spec/example/example_group_proxy.rb
Overview
Lightweight proxy for an example group. This is the object that is passed to Spec::Runner::Formatter::BaseFormatter#example_group_started
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
This is the description passed to the
describe()
method or any of its aliases. -
#examples ⇒ Object
readonly
A collection of ExampleGroupProxy objects, one for each example declared in this group.
-
#location ⇒ Object
readonly
The file and line number at which the proxied example group was declared.
-
#nested_descriptions ⇒ Object
readonly
Used by Spec::Runner::Formatter::NestedTextFormatter to access the description of each example group in a nested group separately.
-
#options ⇒ Object
readonly
Optional hash passed to the example group declaration.
Instance Method Summary collapse
-
#==(other) ⇒ Object
:nodoc:.
-
#backtrace ⇒ Object
Deprecated - use location() instead.
-
#filtered_description(regexp) ⇒ Object
Deprecated - just use gsub on the description instead.
-
#initialize(example_group) ⇒ ExampleGroupProxy
constructor
:nodoc:.
Constructor Details
#initialize(example_group) ⇒ ExampleGroupProxy
:nodoc:
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_proxy.rb', line 7 def initialize(example_group) # :nodoc: @description = example_group.description @nested_descriptions = example_group.nested_descriptions @examples = example_group.example_proxies @location = example_group.location @backtrace = example_group.location # deprecated - see the backtrace method below @options = example_group..dup @options.delete(:location) @options.delete(:scope) end |
Instance Attribute Details
#description ⇒ Object (readonly)
This is the description passed to the describe()
method or any of its aliases
25 26 27 |
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_proxy.rb', line 25 def description @description end |
#examples ⇒ Object (readonly)
A collection of ExampleGroupProxy objects, one for each example declared in this group.
33 34 35 |
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_proxy.rb', line 33 def examples @examples end |
#location ⇒ Object (readonly)
The file and line number at which the proxied example group was declared. This is extracted from caller
, and is therefore formatted as an individual line in a backtrace.
38 39 40 |
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_proxy.rb', line 38 def location @location end |
#nested_descriptions ⇒ Object (readonly)
Used by Spec::Runner::Formatter::NestedTextFormatter to access the description of each example group in a nested group separately.
29 30 31 |
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_proxy.rb', line 29 def nested_descriptions @nested_descriptions end |
#options ⇒ Object (readonly)
Optional hash passed to the example group declaration. Note that RSpec uses this hash internally and reserves the keys :location and :scope for its own use (and removes them from this hash)
21 22 23 |
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_proxy.rb', line 21 def @options end |
Instance Method Details
#==(other) ⇒ Object
:nodoc:
56 57 58 |
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_proxy.rb', line 56 def ==(other) # :nodoc: other.description == description end |
#backtrace ⇒ Object
Deprecated - use location() instead
41 42 43 44 |
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_proxy.rb', line 41 def backtrace Spec::deprecate("ExampleGroupProxy#backtrace","ExampleGroupProxy#location") @backtrace end |
#filtered_description(regexp) ⇒ Object
Deprecated - just use gsub on the description instead.
47 48 49 50 51 52 53 54 |
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_proxy.rb', line 47 def filtered_description(regexp) Spec::deprecate("ExampleGroupProxy#filtered_description","gsub (or similar) to modify ExampleGroupProxy#description") ExampleGroupMethods.build_description_from( *nested_descriptions.collect do |description| description =~ regexp ? description.gsub($1, "") : description end ) end |