Class: Transpec::Syntax
- Inherits:
-
Object
- Object
- Transpec::Syntax
- 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
Direct Known Subclasses
BeClose, Double, Matcher, MethodStub, RSpecConfigure, RaiseError, Should, ShouldReceive
Defined Under Namespace
Modules: AbleToAllowNoMessage, AbleToTargetAnyInstance, Expectizable, SendNodeSyntax Classes: BeClose, Double, InvalidContextError, Matcher, MethodStub, RSpecConfigure, RaiseError, Should, ShouldReceive
Instance Attribute Summary collapse
-
#ancestor_nodes ⇒ Object
readonly
Returns the value of attribute ancestor_nodes.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#report ⇒ Object
readonly
Returns the value of attribute report.
-
#source_rewriter ⇒ Object
readonly
Returns the value of attribute source_rewriter.
Class Method Summary collapse
Instance Method Summary collapse
- #context ⇒ Object
- #expression_range ⇒ Object
-
#initialize(node, ancestor_nodes, source_rewriter, report = Report.new) ⇒ Syntax
constructor
A new instance of Syntax.
- #parent_node ⇒ Object
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 (readonly)
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 (readonly)
Returns the value of attribute node.
9 10 11 |
# File 'lib/transpec/syntax.rb', line 9 def node @node end |
#report ⇒ Object (readonly)
Returns the value of attribute report.
9 10 11 |
# File 'lib/transpec/syntax.rb', line 9 def report @report end |
#source_rewriter ⇒ Object (readonly)
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_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 |
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 |