Class: Transpec::Syntax

Inherits:
Object
  • Object
show all
Defined in:
lib/transpec/syntax.rb,
lib/transpec/syntax/its.rb,
lib/transpec/syntax/have.rb,
lib/transpec/syntax/double.rb,
lib/transpec/syntax/expect.rb,
lib/transpec/syntax/should.rb,
lib/transpec/syntax/be_close.rb,
lib/transpec/syntax/be_boolean.rb,
lib/transpec/syntax/mixin/send.rb,
lib/transpec/syntax/method_stub.rb,
lib/transpec/syntax/raise_error.rb,
lib/transpec/syntax/should_receive.rb,
lib/transpec/syntax/rspec_configure.rb,
lib/transpec/syntax/operator_matcher.rb,
lib/transpec/syntax/mixin/any_instance.rb,
lib/transpec/syntax/mixin/expectizable.rb,
lib/transpec/syntax/mixin/have_matcher.rb,
lib/transpec/syntax/mixin/monkey_patch.rb,
lib/transpec/syntax/mixin/allow_no_message.rb

Defined Under Namespace

Modules: Mixin Classes: BeBoolean, BeClose, Double, Expect, Have, InvalidContextError, Its, MethodStub, OperatorMatcher, RSpecConfigure, RaiseError, Should, ShouldReceive

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, source_rewriter = nil, runtime_data = nil, report = nil) ⇒ Syntax

Returns a new instance of Syntax.



41
42
43
44
45
46
# File 'lib/transpec/syntax.rb', line 41

def initialize(node, source_rewriter = nil, runtime_data = nil, report = nil)
  @node = node
  @source_rewriter = source_rewriter
  @runtime_data = runtime_data
  @report = report || Report.new
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



9
10
11
# File 'lib/transpec/syntax.rb', line 9

def node
  @node
end

#reportObject (readonly)

Returns the value of attribute report.



9
10
11
# File 'lib/transpec/syntax.rb', line 9

def report
  @report
end

#runtime_dataObject (readonly)

Returns the value of attribute runtime_data.



9
10
11
# File 'lib/transpec/syntax.rb', line 9

def runtime_data
  @runtime_data
end

#source_rewriterObject (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_syntaxesObject



15
16
17
# File 'lib/transpec/syntax.rb', line 15

def self.all_syntaxes
  @subclasses ||= []
end

.inherited(subclass) ⇒ Object



11
12
13
# File 'lib/transpec/syntax.rb', line 11

def self.inherited(subclass)
  all_syntaxes << subclass
end

.register_request_for_dynamic_analysis(node, rewriter) ⇒ Object



34
35
# File 'lib/transpec/syntax.rb', line 34

def self.register_request_for_dynamic_analysis(node, rewriter)
end

.snake_case_nameObject



27
28
29
30
31
32
# File 'lib/transpec/syntax.rb', line 27

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

.standalone?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/transpec/syntax.rb', line 23

def self.standalone?
  true
end

.standalone_syntaxesObject



19
20
21
# File 'lib/transpec/syntax.rb', line 19

def self.standalone_syntaxes
  @standalone_syntaxes ||= all_syntaxes.select(&:standalone?)
end

.target_node?(node, runtime_data = nil) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/transpec/syntax.rb', line 37

def self.target_node?(node, runtime_data = nil)
  false
end

Instance Method Details

#expression_rangeObject



59
60
61
# File 'lib/transpec/syntax.rb', line 59

def expression_range
  @node.loc.expression
end

#parent_nodeObject



55
56
57
# File 'lib/transpec/syntax.rb', line 55

def parent_node
  @node.parent_node
end

#register_request_for_dynamic_analysis(rewriter) ⇒ Object



48
49
# File 'lib/transpec/syntax.rb', line 48

def register_request_for_dynamic_analysis(rewriter)
end

#static_context_inspectorObject



51
52
53
# File 'lib/transpec/syntax.rb', line 51

def static_context_inspector
  @static_context_inspector ||= StaticContextInspector.new(@node)
end