Class: Transpec::Syntax::RSpecConfigure

Inherits:
Syntax
  • Object
show all
Includes:
Mixin::RSpecRails, Mixin::Send, ConfigModification
Defined in:
lib/transpec/syntax/rspec_configure.rb,
lib/transpec/syntax/rspec_configure/mocks.rb,
lib/transpec/syntax/rspec_configure/framework.rb,
lib/transpec/syntax/rspec_configure/expectations.rb,
lib/transpec/syntax/rspec_configure/config_modification.rb

Defined Under Namespace

Modules: ConfigModification Classes: Expectations, Framework, Mocks

Constant Summary

Constants included from Util

Util::LITERAL_TYPES, Util::WHITESPACES

Instance Method Summary collapse

Methods included from Mixin::Send

#arg_node, #arg_nodes, #arg_range, #args_range, #method_name, #parentheses_range, #range_after_arg, #range_in_between_receiver_and_selector, #range_in_between_selector_and_arg, #receiver_node, #receiver_range, #selector_range

Methods included from Mixin::Send::TargetDetection

#conversion_target?

Methods included from Mixin::RSpecRails

#rspec_rails?

Methods included from ConfigModification::ConfigAddition

#add_config!, #block_node_to_insert_code, #body_indentation, #config_variable_name, #empty_block_body?, #generate_config_lines

Methods included from Util

beginning_of_line_range, block_node_taken_by_method, chainable_source, const_name, contain_here_document?, each_backward_chained_node, each_forward_chained_node, each_line_range, expand_range_to_adjacent_whitespaces, find_consecutive_whitespace_position, first_block_arg_name, here_document?, in_explicit_parentheses?, indentation_of_line, line_range, literal?, proc_literal?, range_from_arg

Instance Method Details

#block_arg_name ⇒ Object



52
53
54
# File 'lib/transpec/syntax/rspec_configure.rb', line 52

def block_arg_name
  first_block_arg_name(block_node)
end

#dynamic_analysis_target? ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
# File 'lib/transpec/syntax/rspec_configure.rb', line 23

def dynamic_analysis_target?
  return false unless super
  const_name(receiver_node) == 'RSpec' && method_name == :configure && parent_node.block_type?
end

#expectations ⇒ Object



42
43
44
# File 'lib/transpec/syntax/rspec_configure.rb', line 42

def expectations
  @expectations ||= Expectations.new(self, source_rewriter)
end

#expose_dsl_globally=(boolean) ⇒ Object



28
29
30
# File 'lib/transpec/syntax/rspec_configure.rb', line 28

def expose_dsl_globally=(boolean)
  set_config!(:expose_dsl_globally, boolean)
end

#infer_spec_type_from_file_location! ⇒ Object



32
33
34
35
36
# File 'lib/transpec/syntax/rspec_configure.rb', line 32

def infer_spec_type_from_file_location!
  return if infer_spec_type_from_file_location?
  return unless rspec_rails?
  add_config!(:infer_spec_type_from_file_location!)
end

#infer_spec_type_from_file_location? ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/transpec/syntax/rspec_configure.rb', line 38

def infer_spec_type_from_file_location?
  !find_config_node(:infer_spec_type_from_file_location!).nil?
end

#mocks ⇒ Object



46
47
48
# File 'lib/transpec/syntax/rspec_configure.rb', line 46

def mocks
  @mocks ||= Mocks.new(self, source_rewriter)
end