<commit_before>require 'spec_helper'

describe Guard::Konacha::Runner do

  let(:rails_env_file) { File.expand_path('../../../dummy/config/environment', __FILE__) }
  let(:runner_options) { { :rails_environment_file => rails_env_file } }
  let(:runner) { Guard::Konacha::Runner.new runner_options }

  before do
    # Silence Ui.info output
    ::Guard::UI.stub :info => true
  end

  describe '#initialize' do
    it 'should have default options and allow overrides' do
      runner.options.should eq(Guard::Konacha::Runner::DEFAULT_OPTIONS.merge(runner_options))
    end

    it 'should set Konacha mode to runner' do
      ::Konacha.mode.should eq(:runner)
    end
  end

  describe '#start' do
    let(:runner_options) { super().merge(:run_all_on_start => true) }
    it 'should run all if :run_all_on_start option set to true' do
      runner.should_receive(:run).with(no_args)
      runner.start
    end
  end

  describe '#run' do
    let(:konacha_runner) { double("konacha runner") }
    let(:konacha_formatter) { double("konacha formatter") }

    before do
      runner.stub(:runner) { konacha_runner }
      runner.stub(:formatter) { konacha_formatter }
    end

    it 'should run each path through runner and format results' do
      konacha_formatter.should_receive(:reset)
      konacha_runner.should_receive(:run).with('/1')
      konacha_runner.should_receive(:run).with('/foo/bar')
      konacha_formatter.should_receive(:write_summary)
      runner.run(['spec/javascripts/1.js', 'spec/javascripts/foo/bar.js'])
    end
  end

end<commit_msg>Add spec for starting Konacha runner with run_all_on_start option set to false.<commit_after>require 'spec_helper'

describe Guard::Konacha::Runner do

  let(:rails_env_file) { File.expand_path('../../../dummy/config/environment', __FILE__) }
  let(:runner_options) { { :rails_environment_file => rails_env_file } }
  let(:runner) { Guard::Konacha::Runner.new runner_options }

  before do
    # Silence Ui.info output
    ::Guard::UI.stub :info => true
  end

  describe '#initialize' do
    it 'should have default options and allow overrides' do
      runner.options.should eq(Guard::Konacha::Runner::DEFAULT_OPTIONS.merge(runner_options))
    end

    it 'should set Konacha mode to runner' do
      ::Konacha.mode.should eq(:runner)
    end
  end

  describe '#start' do
    describe 'with run_all_on_start set to true' do
      let(:runner_options) { super().merge(:run_all_on_start => true) }
      it 'should run all if :run_all_on_start option set to true' do
        runner.should_receive(:run).with(no_args)
        runner.start
      end
    end

    describe 'with run_all_on_start set to false' do
      let(:runner_options) { super().merge(:run_all_on_start => false) }
      it 'should run all if :run_all_on_start option set to true' do
        runner.should_not_receive(:run)
        runner.start
      end
    end
  end

  describe '#run' do
    let(:konacha_runner) { double("konacha runner") }
    let(:konacha_formatter) { double("konacha formatter") }

    before do
      runner.stub(:runner) { konacha_runner }
      runner.stub(:formatter) { konacha_formatter }
    end

    it 'should run each path through runner and format results' do
      konacha_formatter.should_receive(:reset)
      konacha_runner.should_receive(:run).with('/1')
      konacha_runner.should_receive(:run).with('/foo/bar')
      konacha_formatter.should_receive(:write_summary)
      runner.run(['spec/javascripts/1.js', 'spec/javascripts/foo/bar.js'])
    end
  end

end
{'fraction_non_alphanumeric': 0.11838006230529595, 'fraction_numerical': 0.0011328235627301047, 'mean_word_length': 3.5810635538262, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '1344627', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1098, 'n_words': 257}