class Transpec::Syntax::ExampleGroup
Constants
- DIRECTORY_TO_TYPE_MAP
Public Instance Methods
add_explicit_type_metadata!()
click to toggle source
# File lib/transpec/syntax/example_group.rb, line 45 def add_explicit_type_metadata! return unless rspec_rails? return unless method_name == :describe return if explicit_type_metadata? type = implicit_type_metadata return unless type code = ', ' code << if metadata_hash_style == :arrow ":type => #{type.inspect}" else "type: #{type.inspect}" end insert_after(metadata_insertion_point, code) add_record(ExplicitTypeMetadataRecordBuilder.build(self)) end
convert_to_non_monkey_patch!()
click to toggle source
# File lib/transpec/syntax/example_group.rb, line 39 def convert_to_non_monkey_patch! return if receiver_node insert_before(expression_range, 'RSpec.') add_record(NonMonkeyPatchRecordBuilder.build(self)) end
dynamic_analysis_target?()
click to toggle source
Calls superclass method
Transpec::Syntax#dynamic_analysis_target?
# File lib/transpec/syntax/example_group.rb, line 29 def dynamic_analysis_target? return false unless super return false if receiver_node && const_name(receiver_node) != 'RSpec' EXAMPLE_GROUP_METHODS.include?(method_name) end
implicit_type_metadata()
click to toggle source
# File lib/transpec/syntax/example_group.rb, line 65 def implicit_type_metadata dirs = file_path.split('/') return nil unless dirs.first == 'spec' DIRECTORY_TO_TYPE_MAP[dirs[1]] end
should_be_in_example_group_context?()
click to toggle source
# File lib/transpec/syntax/example_group.rb, line 35 def should_be_in_example_group_context? false end
Private Instance Methods
explicit_type_metadata?()
click to toggle source
# File lib/transpec/syntax/example_group.rb, line 73 def explicit_type_metadata? metadata_key_nodes.any? do |node| next false unless node.sym_type? key = node.children.first key == :type end end
file_path()
click to toggle source
# File lib/transpec/syntax/example_group.rb, line 81 def file_path expression_range.source_buffer.name end
metadata_hash_style()
click to toggle source
# File lib/transpec/syntax/example_group.rb, line 85 def metadata_hash_style symbol_key_nodes = metadata_key_nodes.select(&:sym_type?) has_colon_separator_pair = symbol_key_nodes.any? do |sym_node| !sym_node.loc.expression.source.start_with?(':') end if has_colon_separator_pair :colon else :arrow end end
metadata_insertion_point()
click to toggle source
# File lib/transpec/syntax/example_group.rb, line 99 def metadata_insertion_point hash_metadata_node_index = arg_nodes.find_index(&:hash_type?) last_non_hash_arg_node = if hash_metadata_node_index arg_nodes[hash_metadata_node_index - 1] else arg_nodes.last end last_non_hash_arg_node.loc.expression.end end