Class: Transpec::Syntax::CurrentExample::RecordBuilder
- Inherits:
-
RecordBuilder
- Object
- RecordBuilder
- Transpec::Syntax::CurrentExample::RecordBuilder
- Includes:
- RSpecDSL
- Defined in:
- lib/transpec/syntax/current_example.rb
Constant Summary
Constants included from RSpecDSL
RSpecDSL::EXAMPLE_GROUP_METHODS, RSpecDSL::EXAMPLE_METHODS, RSpecDSL::HELPER_METHODS, RSpecDSL::HOOK_METHODS
Instance Attribute Summary collapse
-
#current_example ⇒ Object
readonly
Returns the value of attribute current_example.
Instance Method Summary collapse
- #base_dsl ⇒ Object
-
#initialize(current_example) ⇒ RecordBuilder
constructor
A new instance of RecordBuilder.
- #new_syntax ⇒ Object
- #old_syntax ⇒ Object
Methods inherited from RecordBuilder
Constructor Details
#initialize(current_example) ⇒ RecordBuilder
Returns a new instance of RecordBuilder.
77 78 79 |
# File 'lib/transpec/syntax/current_example.rb', line 77 def initialize(current_example) @current_example = current_example end |
Instance Attribute Details
#current_example ⇒ Object (readonly)
Returns the value of attribute current_example.
75 76 77 |
# File 'lib/transpec/syntax/current_example.rb', line 75 def current_example @current_example end |
Instance Method Details
#base_dsl ⇒ Object
97 98 99 100 101 |
# File 'lib/transpec/syntax/current_example.rb', line 97 def base_dsl dsl = "#{current_example.block_method_name}" dsl << '(:name)' if HELPER_METHODS.include?(current_example.block_method_name) dsl end |
#new_syntax ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/transpec/syntax/current_example.rb', line 89 def new_syntax if current_example.block_node "#{base_dsl} { |example| example }" else 'def helper_method RSpec.current_example; end' end end |
#old_syntax ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/transpec/syntax/current_example.rb', line 81 def old_syntax if current_example.block_node "#{base_dsl} { example }" else 'def helper_method example; end' end end |