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, Matcher, MethodStub, NotInExampleGroupContextError, RSpecConfigure, RaiseError, Should, ShouldReceive
Instance Attribute Summary collapse
-
#ancestor_nodes ⇒ Object
readonly
Returns the value of attribute ancestor_nodes.
-
#in_example_group_context ⇒ Object
(also: #in_example_group_context?)
readonly
Returns the value of attribute in_example_group_context.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#source_rewriter ⇒ Object
readonly
Returns the value of attribute source_rewriter.
Class Method Summary collapse
Instance Method Summary collapse
- #expression_range ⇒ Object
-
#initialize(node, ancestor_nodes, in_example_group_context, source_rewriter) ⇒ Syntax
constructor
A new instance of Syntax.
- #parent_node ⇒ Object
Constructor Details
#initialize(node, ancestor_nodes, in_example_group_context, source_rewriter) ⇒ Syntax
Returns a new instance of Syntax.
50 51 52 53 54 55 |
# File 'lib/transpec/syntax.rb', line 50 def initialize(node, ancestor_nodes, in_example_group_context, source_rewriter) @node = node @ancestor_nodes = ancestor_nodes @in_example_group_context = in_example_group_context @source_rewriter = source_rewriter end |
Instance Attribute Details
#ancestor_nodes ⇒ Object (readonly)
Returns the value of attribute ancestor_nodes.
25 26 27 |
# File 'lib/transpec/syntax.rb', line 25 def ancestor_nodes @ancestor_nodes end |
#in_example_group_context ⇒ Object (readonly) Also known as: in_example_group_context?
Returns the value of attribute in_example_group_context.
25 26 27 |
# File 'lib/transpec/syntax.rb', line 25 def in_example_group_context @in_example_group_context end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
25 26 27 |
# File 'lib/transpec/syntax.rb', line 25 def node @node end |
#source_rewriter ⇒ Object (readonly)
Returns the value of attribute source_rewriter.
25 26 27 |
# File 'lib/transpec/syntax.rb', line 25 def source_rewriter @source_rewriter end |
Class Method Details
.all ⇒ Object
28 29 30 |
# File 'lib/transpec/syntax.rb', line 28 def self.all @subclasses ||= [] end |
.inherited(subclass) ⇒ Object
32 33 34 |
# File 'lib/transpec/syntax.rb', line 32 def self.inherited(subclass) all << subclass end |
.snake_case_name ⇒ Object
36 37 38 39 40 41 |
# File 'lib/transpec/syntax.rb', line 36 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
43 44 45 46 47 48 |
# File 'lib/transpec/syntax.rb', line 43 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
#expression_range ⇒ Object
61 62 63 |
# File 'lib/transpec/syntax.rb', line 61 def expression_range @node.loc.expression end |
#parent_node ⇒ Object
57 58 59 |
# File 'lib/transpec/syntax.rb', line 57 def parent_node @ancestor_nodes.last end |