Class: Transpec::Syntax::RSpecConfigure::Mocks

Inherits:
Framework
  • Object
show all
Defined in:
lib/transpec/syntax/rspec_configure/mocks.rb

Constant Summary

Constants included from Util

Util::LITERAL_TYPES, Util::WHITESPACES

Instance Attribute Summary

Attributes inherited from Framework

#rspec_configure

Instance Method Summary collapse

Methods inherited from Framework

#add_record, #block_node, #initialize, #source_rewriter

Methods included from Framework::SyntaxConfig

#syntaxes, #syntaxes=

Methods included from ConfigModification

#block_node

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

Constructor Details

This class inherits a constructor from Transpec::Syntax::RSpecConfigure::Framework

Instance Method Details

#block_method_nameObject



9
10
11
# File 'lib/transpec/syntax/rspec_configure/mocks.rb', line 9

def block_method_name
  :mock_with
end

#yield_receiver_to_any_instance_implementation_blocks=(value) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/transpec/syntax/rspec_configure/mocks.rb', line 13

def yield_receiver_to_any_instance_implementation_blocks=(value)
  # Based on the deprecation warning in RSpec 2.99:
  # https://github.com/rspec/rspec-mocks/blob/aab8dc9/lib/rspec/mocks/message_expectation.rb#L478-L491
  comment = <<-END.gsub(/^\s+\|/, '').chomp
    |In RSpec 3, `any_instance` implementation blocks will be yielded the receiving
    |instance as the first block argument to allow the implementation block to use
    |the state of the receiver.
    |In RSpec 2.99, to maintain compatibility with RSpec 3 you need to either set
    |this config option to `false` OR set this to `true` and update your
    |`any_instance` implementation blocks to account for the first block argument
    |being the receiving instance.
  END
  set_config_value!(:yield_receiver_to_any_instance_implementation_blocks, value, comment)
end