Module: RSpecStepwise

Defined in:
lib/rspec-steps/stepwise.rb

Instance Method Summary collapse

Instance Method Details

#run_examples(reporter) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rspec-steps/stepwise.rb', line 17

def run_examples(reporter)
  instance = new
  set_ivars(instance, before_all_ivars)

  suspend_transactional_fixtures do
    filtered_examples.inject(true) do |success, example|
      break if RSpec.wants_to_quit 
      unless success
        reporter.example_started(example)
        example.[:pending] = true
        example.[:execution_result][:pending_message] = "Previous step failed"
        example.[:execution_result][:started_at] = Time.now
        example.instance_eval{ record_finished :pending, :pending_message => "Previous step failed" }
        reporter.example_pending(example)
        next
      end
      succeeded = example.run(instance, reporter)
      RSpec.wants_to_quit = true if fail_fast? && !succeeded
      success && succeeded
    end
  end
end

#suspend_transactional_fixturesObject

TODO: This is hacky and needs a more general solution Something like cloning the current conf and having RSpec::Stepwise::config ?



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rspec-steps/stepwise.rb', line 4

def suspend_transactional_fixtures
  if self.respond_to? :use_transactional_fixtures
    old_val = self.use_transactional_fixtures
    self.use_transactional_fixtures = false

    yield

    self.use_transactional_fixtures = old_val
  else
    yield
  end
end