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.rb,
lib/transpec/syntax.rb,
lib/transpec/syntax/its.rb,
lib/transpec/syntax/have.rb,
lib/transpec/syntax/hook.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/example_group.rb,
lib/transpec/syntax/mixin/metadata.rb,
lib/transpec/syntax/should_receive.rb,
lib/transpec/syntax/current_example.rb,
lib/transpec/syntax/mixin/examplish.rb,
lib/transpec/syntax/oneliner_should.rb,
lib/transpec/syntax/rspec_configure.rb,
lib/transpec/syntax/mixin/block_owner.rb,
lib/transpec/syntax/mixin/expect_base.rb,
lib/transpec/syntax/mixin/rspec_rails.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/record_builder.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/context_sensitive.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,
lib/transpec/syntax/rspec_configure/config_modification.rb

Defined Under Namespace

Modules: Collection, Dispatcher, DynamicAnalysis, Mixin, ModuleUtil, Rewritable Classes: Allow, BeBoolean, BeClose, CurrentExample, Double, Example, ExampleGroup, Expect, Have, Hook, 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, mixins, require_all, standalone_syntaxes

Methods included from DynamicAnalysis

#register_dynamic_analysis_request

Constructor Details

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

Returns a new instance of Syntax.



165
166
167
168
169
170
171
# File 'lib/transpec/syntax.rb', line 165

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

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



155
156
157
# File 'lib/transpec/syntax.rb', line 155

def node
  @node
end

#projectObject (readonly)

Returns the value of attribute project.



155
156
157
# File 'lib/transpec/syntax.rb', line 155

def project
  @project
end

#reportObject (readonly)

Returns the value of attribute report.



155
156
157
# File 'lib/transpec/syntax.rb', line 155

def report
  @report
end

#runtime_dataObject (readonly)

Returns the value of attribute runtime_data.



155
156
157
# File 'lib/transpec/syntax.rb', line 155

def runtime_data
  @runtime_data
end

#source_rewriterObject (readonly)

Returns the value of attribute source_rewriter.



155
156
157
# File 'lib/transpec/syntax.rb', line 155

def source_rewriter
  @source_rewriter
end

Class Method Details

.snake_case_nameObject



161
162
163
# File 'lib/transpec/syntax.rb', line 161

def self.snake_case_name
  @snake_cake_name ||= ModuleUtil.snake_case_name(name)
end

.standalone?Boolean

Returns:

  • (Boolean)


157
158
159
# File 'lib/transpec/syntax.rb', line 157

def self.standalone?
  true
end

Instance Method Details

#add_record(*args) ⇒ Object



205
206
207
208
209
210
211
212
213
# File 'lib/transpec/syntax.rb', line 205

def add_record(*args)
  record = if args.first.is_a?(Record)
             args.first
           else
             Record.new(*args)
           end

  report.records << record
end

#conversion_target?Boolean

Returns:

  • (Boolean)


177
178
179
# File 'lib/transpec/syntax.rb', line 177

def conversion_target?
  dynamic_analysis_target?
end

#dependent_syntaxesObject



181
182
183
# File 'lib/transpec/syntax.rb', line 181

def dependent_syntaxes
  @dependent_syntaxes ||= []
end

#dynamic_analysis_target?Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/transpec/syntax.rb', line 173

def dynamic_analysis_target?
  false
end

#expression_rangeObject



193
194
195
# File 'lib/transpec/syntax.rb', line 193

def expression_range
  node.loc.expression
end

#inspectObject



201
202
203
# File 'lib/transpec/syntax.rb', line 201

def inspect
  "#<#{self.class}: #{node.type}>"
end

#parent_nodeObject



189
190
191
# File 'lib/transpec/syntax.rb', line 189

def parent_node
  node.parent
end

#rspec_versionObject



197
198
199
# File 'lib/transpec/syntax.rb', line 197

def rspec_version
  project.rspec_version
end

#static_context_inspectorObject



185
186
187
# File 'lib/transpec/syntax.rb', line 185

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