Class: Transpec::Syntax::Should
- Inherits:
-
Syntax
- Object
- Syntax
- Transpec::Syntax::Should
show all
- Includes:
- Expectizable, Util
- Defined in:
- lib/transpec/syntax/should.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#wrap_subject_in_expect!
#arg_node, #arg_nodes, #arg_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 Util
const_name, here_document?, in_parentheses?, indentation_of_line, proc_literal?
Class Method Details
.target_method_names ⇒ Object
49
50
51
|
# File 'lib/transpec/syntax/should.rb', line 49
def self.target_method_names
[:should, :should_not]
end
|
.target_receiver_node?(node) ⇒ Boolean
45
46
47
|
# File 'lib/transpec/syntax/should.rb', line 45
def self.target_receiver_node?(node)
!node.nil?
end
|
Instance Method Details
#expectize!(negative_form = 'not_to', parenthesize_matcher_arg = true) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/transpec/syntax/should.rb', line 17
def expectize!(negative_form = 'not_to', parenthesize_matcher_arg = true)
unless context.in_example_group?
fail InvalidContextError.new(selector_range, "##{method_name}", '#expect')
end
if proc_literal?(subject_node)
replace_proc_selector_with_expect!
else
wrap_subject_in_expect!
end
replace(should_range, positive? ? 'to' : negative_form)
register_record(negative_form)
matcher.correct_operator!(parenthesize_matcher_arg)
end
|
#matcher ⇒ Object
35
36
37
|
# File 'lib/transpec/syntax/should.rb', line 35
def matcher
@matcher ||= Matcher.new(matcher_node, @source_rewriter, @report)
end
|
#matcher_node ⇒ Object
39
40
41
|
# File 'lib/transpec/syntax/should.rb', line 39
def matcher_node
arg_node || parent_node
end
|
#positive? ⇒ Boolean
13
14
15
|
# File 'lib/transpec/syntax/should.rb', line 13
def positive?
method_name == :should
end
|