Class: Transpec::Syntax
- Inherits:
-
Object
show all
- Defined in:
- lib/transpec/syntax.rb,
lib/transpec/syntax/double.rb,
lib/transpec/syntax/should.rb,
lib/transpec/syntax/matcher.rb,
lib/transpec/syntax/be_close.rb,
lib/transpec/syntax/method_stub.rb,
lib/transpec/syntax/raise_error.rb,
lib/transpec/syntax/expectizable.rb,
lib/transpec/syntax/should_receive.rb,
lib/transpec/syntax/rspec_configure.rb,
lib/transpec/syntax/send_node_syntax.rb,
lib/transpec/syntax/able_to_allow_no_message.rb,
lib/transpec/syntax/able_to_target_any_instance.rb
Defined Under Namespace
Modules: AbleToAllowNoMessage, AbleToTargetAnyInstance, Expectizable, SendNodeSyntax
Classes: BeClose, Double, InvalidContextError, Matcher, MethodStub, RSpecConfigure, RaiseError, Should, ShouldReceive
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(node, ancestor_nodes, source_rewriter, report = Report.new) ⇒ Syntax
Returns a new instance of Syntax.
33
34
35
36
37
38
|
# File 'lib/transpec/syntax.rb', line 33
def initialize(node, ancestor_nodes, source_rewriter, report = Report.new)
@node = node
@ancestor_nodes = ancestor_nodes
@source_rewriter = source_rewriter
@report = report
end
|
Instance Attribute Details
#ancestor_nodes ⇒ Object
Returns the value of attribute ancestor_nodes.
9
10
11
|
# File 'lib/transpec/syntax.rb', line 9
def ancestor_nodes
@ancestor_nodes
end
|
#node ⇒ Object
Returns the value of attribute node.
9
10
11
|
# File 'lib/transpec/syntax.rb', line 9
def node
@node
end
|
#report ⇒ Object
Returns the value of attribute report.
9
10
11
|
# File 'lib/transpec/syntax.rb', line 9
def report
@report
end
|
#source_rewriter ⇒ Object
Returns the value of attribute source_rewriter.
9
10
11
|
# File 'lib/transpec/syntax.rb', line 9
def source_rewriter
@source_rewriter
end
|
Class Method Details
.all ⇒ Object
11
12
13
|
# File 'lib/transpec/syntax.rb', line 11
def self.all
@subclasses ||= []
end
|
.inherited(subclass) ⇒ Object
15
16
17
|
# File 'lib/transpec/syntax.rb', line 15
def self.inherited(subclass)
all << subclass
end
|
.snake_case_name ⇒ Object
19
20
21
22
23
24
|
# File 'lib/transpec/syntax.rb', line 19
def self.snake_case_name
@snake_cake_name ||= begin
class_name = name.split('::').last
class_name.gsub(/([a-z])([A-Z])/, '\1_\2').downcase
end
end
|
.target_method_names ⇒ Object
58
59
60
|
# File 'lib/transpec/syntax.rb', line 58
def self.target_method_names
[]
end
|
.target_node?(node) ⇒ Boolean
26
27
28
29
30
31
|
# File 'lib/transpec/syntax.rb', line 26
def self.target_node?(node)
return false unless node.type == :send
receiver_node, method_name, *_ = *node
return false unless target_receiver_node?(receiver_node)
target_method_names.include?(method_name)
end
|
.target_receiver_node?(node) ⇒ Boolean
54
55
56
|
# File 'lib/transpec/syntax.rb', line 54
def self.target_receiver_node?(node)
false
end
|
Instance Method Details
#context ⇒ Object
40
41
42
|
# File 'lib/transpec/syntax.rb', line 40
def context
@context ||= Context.new(@ancestor_nodes)
end
|
#expression_range ⇒ Object
48
49
50
|
# File 'lib/transpec/syntax.rb', line 48
def expression_range
@node.loc.expression
end
|
#parent_node ⇒ Object
44
45
46
|
# File 'lib/transpec/syntax.rb', line 44
def parent_node
@ancestor_nodes.last
end
|