Class: Transpec::Syntax

Inherits:
Object
  • Object
show all
Extended by:
Collection
Includes:
DynamicAnalysis, Rewritable
Defined in:
lib/transpec/syntax.rb,
lib/transpec/syntax.rb,
lib/transpec/syntax.rb,
lib/transpec/syntax.rb,
lib/transpec/syntax/its.rb,
lib/transpec/syntax/have.rb,
lib/transpec/syntax/allow.rb,
lib/transpec/syntax/double.rb,
lib/transpec/syntax/expect.rb,
lib/transpec/syntax/should.rb,
lib/transpec/syntax/example.rb,
lib/transpec/syntax/pending.rb,
lib/transpec/syntax/receive.rb,
lib/transpec/syntax/be_close.rb,
lib/transpec/syntax/operator.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/current_example.rb,
lib/transpec/syntax/oneliner_should.rb,
lib/transpec/syntax/rspec_configure.rb,
lib/transpec/syntax/have/have_record.rb,
lib/transpec/syntax/mixin/expect_base.rb,
lib/transpec/syntax/mixin/should_base.rb,
lib/transpec/syntax/matcher_definition.rb,
lib/transpec/syntax/mixin/expectizable.rb,
lib/transpec/syntax/mixin/monkey_patch.rb,
lib/transpec/syntax/have/source_builder.rb,
lib/transpec/syntax/mixin/matcher_owner.rb,
lib/transpec/syntax/mixin/owned_matcher.rb,
lib/transpec/syntax/mixin/messaging_host.rb,
lib/transpec/syntax/have/dynamic_analysis.rb,
lib/transpec/syntax/rspec_configure/mocks.rb,
lib/transpec/syntax/mixin/any_instance_block.rb,
lib/transpec/syntax/mixin/useless_and_return.rb,
lib/transpec/syntax/rspec_configure/framework.rb,
lib/transpec/syntax/mixin/no_message_allowance.rb,
lib/transpec/syntax/rspec_configure/expectations.rb,
lib/transpec/syntax/mixin/monkey_patch_any_instance.rb

Defined Under Namespace

Modules: Collection, DynamicAnalysis, Mixin, Rewritable Classes: Allow, BeBoolean, BeClose, CurrentExample, Double, Example, Expect, Have, Its, MatcherDefinition, MethodStub, OnelinerShould, Operator, Pending, RSpecConfigure, RaiseError, Receive, Should, ShouldReceive

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Collection

all_syntaxes, inherited, require_all, standalone_syntaxes

Methods included from DynamicAnalysis

#register_dynamic_analysis_request

Constructor Details

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

Returns a new instance of Syntax.



101
102
103
104
105
106
# File 'lib/transpec/syntax.rb', line 101

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

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



88
89
90
# File 'lib/transpec/syntax.rb', line 88

def node
  @node
end

#reportObject (readonly)

Returns the value of attribute report.



88
89
90
# File 'lib/transpec/syntax.rb', line 88

def report
  @report
end

#runtime_dataObject (readonly)

Returns the value of attribute runtime_data.



88
89
90
# File 'lib/transpec/syntax.rb', line 88

def runtime_data
  @runtime_data
end

#source_rewriterObject (readonly)

Returns the value of attribute source_rewriter.



88
89
90
# File 'lib/transpec/syntax.rb', line 88

def source_rewriter
  @source_rewriter
end

Class Method Details

.snake_case_nameObject



94
95
96
97
98
99
# File 'lib/transpec/syntax.rb', line 94

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)


90
91
92
# File 'lib/transpec/syntax.rb', line 90

def self.standalone?
  true
end

Instance Method Details

#conversion_target?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/transpec/syntax.rb', line 112

def conversion_target?
  dynamic_analysis_target?
end

#dynamic_analysis_target?Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/transpec/syntax.rb', line 108

def dynamic_analysis_target?
  false
end

#expression_rangeObject



124
125
126
# File 'lib/transpec/syntax.rb', line 124

def expression_range
  node.loc.expression
end

#parent_nodeObject



120
121
122
# File 'lib/transpec/syntax.rb', line 120

def parent_node
  node.parent_node
end

#static_context_inspectorObject



116
117
118
# File 'lib/transpec/syntax.rb', line 116

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