Class: Transpec::Syntax::Its
Defined Under Namespace
Classes: Attribute, AttributeExpression
Constant Summary
Constants included
from Util
Util::LITERAL_TYPES
Instance Attribute Summary
#node, #report, #runtime_data, #source_rewriter
Class Method Summary
collapse
Instance Method Summary
collapse
#arg_node, #arg_nodes, #arg_range, #args_range, included, #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 Util
const_name, contain_here_document?, here_document?, in_parentheses?, indentation_of_line, literal?, proc_literal?
all_syntaxes, #expression_range, inherited, #initialize, #parent_node, register_request_for_dynamic_analysis, snake_case_name, standalone?, standalone_syntaxes, #static_context_inspector, target_node?
Class Method Details
.target_method?(receiver_node, method_name) ⇒ Boolean
12
13
14
|
# File 'lib/transpec/syntax/its.rb', line 12
def self.target_method?(receiver_node, method_name)
receiver_node.nil? && method_name == :its
end
|
Instance Method Details
#attribute_expression ⇒ Object
34
35
36
|
# File 'lib/transpec/syntax/its.rb', line 34
def attribute_expression
@attribute_expression ||= AttributeExpression.new(attribute_node)
end
|
#attributes ⇒ Object
38
39
40
|
# File 'lib/transpec/syntax/its.rb', line 38
def attributes
attribute_expression.attributes
end
|
#block_node ⇒ Object
44
45
46
|
# File 'lib/transpec/syntax/its.rb', line 44
def block_node
@node.parent_node
end
|
#convert_to_describe_subject_it! ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/transpec/syntax/its.rb', line 22
def convert_to_describe_subject_it!
return if project_requires_its?
front, rear = build_wrapper_codes
insert_before(beginning_of_line_range, front)
replace(expression_range, 'it')
insert_after(block_node.loc.expression, rear)
register_record
end
|
#project_requires_its? ⇒ Boolean
48
49
50
51
|
# File 'lib/transpec/syntax/its.rb', line 48
def project_requires_its?
node_data = runtime_node_data(@node)
node_data && node_data[:project_requires_its?].result
end
|
#register_request_for_dynamic_analysis(rewriter) ⇒ Object
16
17
18
19
20
|
# File 'lib/transpec/syntax/its.rb', line 16
def register_request_for_dynamic_analysis(rewriter)
key = :project_requires_its?
code = 'defined?(RSpec::Its)'
rewriter.register_request(@node, key, code, :context)
end
|