Class: Transpec::Syntax::CurrentExample::RecordBuilder

Inherits:
RecordBuilder
  • Object
show all
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 Method Summary collapse

Methods inherited from RecordBuilder

build, #build, param_names

Instance Method Details

#base_dslObject



92
93
94
95
96
# File 'lib/transpec/syntax/current_example.rb', line 92

def base_dsl
  dsl = "#{current_example.block_method_name}"
  dsl << '(:name)' if HELPER_METHODS.include?(current_example.block_method_name)
  dsl
end

#new_syntaxObject



84
85
86
87
88
89
90
# File 'lib/transpec/syntax/current_example.rb', line 84

def new_syntax
  if current_example.block_node
    "#{base_dsl} { |example| example }"
  else
    'def helper_method RSpec.current_example; end'
  end
end

#old_syntaxObject



76
77
78
79
80
81
82
# File 'lib/transpec/syntax/current_example.rb', line 76

def old_syntax
  if current_example.block_node
    "#{base_dsl} { example }"
  else
    'def helper_method example; end'
  end
end