<commit_before>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, context, world|
        expect(scope).to eq :scenario
        expect(context).to eq scenario
        expect(world).to eq scenario.send(:world)
      end

      subject
    end

    it 'runs reporter callbacks in correct order' do<commit_msg>Drop #ordered from stub<commit_after>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).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, context, world|
        expect(scope).to eq :scenario
        expect(context).to eq scenario
        expect(world).to eq scenario.send(:world)
      end

      subject
    end

    it 'runs reporter callbacks in correct order' do
{'fraction_non_alphanumeric': 0.12568807339449542, 'fraction_numerical': 0.0, 'mean_word_length': 3.3883299798792756, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4198812', 'n_tokens_mistral': 687, 'n_tokens_neox': 662, 'n_words': 174}