Class: MinitestToRspec::Input::Subprocessors::Call

Inherits:
Base
  • Object
show all
Defined in:
lib/minitest_to_rspec/input/subprocessors/call.rb

Overview

Processes ‘s(:call, ..)` expressions.

Constant Summary collapse

MOCHA_METHODS =

Mocha methods will only be processed if ‘–mocha` flag was given, i.e. `mocha` argument in constructor is true.

%i[
  expects
  once
  returns
  stub
  stubs
  stub_everything
  twice
].freeze

Instance Method Summary collapse

Methods inherited from Base

#allow_to, #expect, #expect_to, #expect_to_not, #expectation_target, #expectation_target_eager, #expectation_target_lazy, #full_process, #matcher

Methods included from SexpAssertions

#assert_sexp_type, #assert_sexp_type_array, #sexp_type?

Constructor Details

#initialize(sexp, rails, mocha) ⇒ Call

Returns a new instance of Call.



28
29
30
31
32
# File 'lib/minitest_to_rspec/input/subprocessors/call.rb', line 28

def initialize(sexp, rails, mocha)
  super(rails, mocha)
  @exp = Model::Call.new(sexp)
  sexp.clear
end

Instance Method Details

#processObject

Given a ‘Model::Call`, returns a `Sexp`



35
36
37
38
39
40
41
# File 'lib/minitest_to_rspec/input/subprocessors/call.rb', line 35

def process
  if process?
    send(name_of_processing_method)
  else
    @exp.original
  end
end

#process?Boolean

Returns:

  • (Boolean)


43
44
45
46
# File 'lib/minitest_to_rspec/input/subprocessors/call.rb', line 43

def process?
  respond_to?(name_of_processing_method, true) &&
    (@mocha || !MOCHA_METHODS.include?(@exp.method_name))
end