Sha256: 3fec08dc058f868d67cfafe6a72c04d7fe01288d9286adbed0c50d3e35a0c768

Contents?: true

Size: 1.28 KB

Versions: 13

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe Gurke::Scenario do
  let(:reporter) { Gurke::Reporters::NullReporter.new }
  let(:runner)   { double 'runner' }
  let(:feature)  { double 'feature' }
  let(:backgrounds) { double('backgrounds') }

  before do
    allow(feature).to receive(:backgrounds).ordered.and_return(backgrounds)
    allow(backgrounds).to receive(:run)
    allow(runner).to receive(:hook) {|_, _, &block| block.call }
  end

  let(:scenario) do
    Gurke::Scenario.new(feature, nil, nil, nil, nil)
  end

  describe '#run' do
    subject { scenario.run(runner, reporter) }

    it 'runs all backgrounds' do
      expect(backgrounds).to receive(:run)
        .with(runner, reporter, scenario, scenario.send(:world))

      subject
    end

    it 'runs hook in scenario world' do
      expect(runner).to receive(:hook) do |scope, world|
        expect(scope).to eq :scenario
        expect(world).to eq scenario.send(:world)
      end

      subject
    end

    it 'runs reporter callbacks in correct order' do
      expect(reporter).to receive(:invoke).exactly(4).times do |*args|
        @scopes ||= []
        @scopes << args.first
      end

      subject

      expect(@scopes).to eq [:before_scenario, :start_scenario,
                             :end_scenario, :after_scenario]
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
gurke-2.4.0 spec/gurke/scenario_spec.rb
gurke-2.3.0 spec/gurke/scenario_spec.rb
gurke-2.2.2 spec/gurke/scenario_spec.rb
gurke-2.2.1 spec/gurke/scenario_spec.rb
gurke-2.1.0 spec/gurke/scenario_spec.rb
gurke-2.0.3 spec/gurke/scenario_spec.rb
gurke-2.0.2 spec/gurke/scenario_spec.rb
gurke-2.0.1 spec/gurke/scenario_spec.rb
gurke-2.0.0 spec/gurke/scenario_spec.rb
gurke-2.0.0.dev.1.b25 spec/gurke/scenario_spec.rb
gurke-2.0.0.dev.1.b24 spec/gurke/scenario_spec.rb
gurke-2.0.0.dev.1.b23 spec/gurke/scenario_spec.rb
gurke-2.0.0.dev.1.b22 spec/gurke/scenario_spec.rb