Class: Synthesis::RSpecAdapter

Inherits:
Adapter show all
Defined in:
lib/synthesis/adapter/rspec.rb

Instance Method Summary collapse

Methods inherited from Adapter

#fail_unless, #ignore_instances_of, inherited, #initialize, load

Methods included from Logging

#silence!, #speak!

Constructor Details

This class inherits a constructor from Synthesis::Adapter

Instance Method Details

#collect_expectationsObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/synthesis/adapter/rspec.rb', line 24

def collect_expectations
  ignore_instances_of Spec::Mocks::Mock
  Spec::Mocks::Methods.extend(ExpectationRecorder)
  Spec::Mocks::Methods.record_expectations_on(:should_receive)
  Spec::Mocks::MessageExpectation.extend(ExpectationInterceptor)
  Spec::Mocks::MessageExpectation.intercept_test_subject_on(:invoke)
  Spec::Mocks::MessageExpectation.intercept_expected_arguments_on(:with)
  Spec::Mocks::MessageExpectation.intercept_expected_return_values_on(:and_return)
  Spec::Mocks::MessageExpectation.intercept_expected_return_values_on(:and_raise)
  Spec::Mocks::MessageExpectation.remove_expectation_on(:never)
end

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/synthesis/adapter/rspec.rb', line 9

def run
  fail_unless do
    rspec_opts = begin
      Spec::Runner.options
    rescue
      rspec_options
    end
    
    rspec_opts.files.clear
    rspec_opts.instance_variable_set(:@formatters, nil)
    rspec_opts.run_examples
    # Synthesis.rspec_runner_options.instance_variable_set(:@format_options, [["profile", STDOUT]])
  end
end

#stop_collecting_expectationsObject



36
37
38
39
# File 'lib/synthesis/adapter/rspec.rb', line 36

def stop_collecting_expectations
  Spec::Mocks::MessageExpectation.stop_intercepting!
  Spec::Mocks::Methods.stop_recording!
end