Sha256: 6a90bfcdcb9f075ef306f5ad1a3ada7327503883887c0adabe0410c3def07699

Contents?: true

Size: 1.38 KB

Versions: 9

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'
require 'launchy'

describe Guard::RSpec::Command do
  let(:options) { { } }
  let(:paths) { %w[path1 path2] }
  let(:command) { Guard::RSpec::Command.new(paths, options) }

  describe '.initialize' do

    it "sets paths at the end" do
      expect(command).to match /path1 path2$/
    end

    it "sets custom failure exit code" do
      expect(command).to match /--failure-exit-code 2/
    end

    it "sets formatter" do
      expect(command).to match %r{-r .*/lib/guard/rspec/formatter.rb -f Guard::RSpec::Formatter}
    end

    context "with custom cmd" do
      let(:options) { { cmd: 'rspec -t ~slow' } }

      it "uses custom cmd" do
        expect(command).to match  /^rspec -t ~slow/
      end
    end

    context "with RSpec defined formatter" do
      let(:formatters) { [['doc','output']] }
      before { allow(RSpec::Core::ConfigurationOptions).to receive(:new) { double(options: { formatters: formatters }) } }

      it "uses them" do
        expect(command).to match %r{-f doc -o output}
      end
    end

    context "with no RSpec defined formatter" do
      it "sets default progress formatter" do
        expect(command).to match %r{-f progress}
      end
    end

    context "with formatter in cmd" do
      let(:options) { { cmd: 'rspec -f doc' } }

      it "sets no other formatters" do
        expect(command).to match %r{-f doc}
      end
    end
  end

end

Version data entries

9 entries across 7 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/guard-rspec-4.3.1/spec/lib/guard/rspec/command_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/guard-rspec-4.3.1/spec/lib/guard/rspec/command_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/guard-rspec-4.3.1/spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.3.1 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.3.0 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.2.10 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.2.9 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.2.8 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.2.7 spec/lib/guard/rspec/command_spec.rb