Sha256: edd351093f0f899e19dfe5f69139764725208c314562ae05c74a871467985923

Contents?: true

Size: 1.29 KB

Versions: 11

Compression:

Stored size: 1.29 KB

Contents

require "guard/compat/test/helper"

require "guard/rspec/results"

RSpec.describe Guard::RSpec::Results do
  subject do
    described_class.new("foo/bar.txt")
  end

  before do
    allow(File).to receive(:readlines).with("foo/bar.txt").and_return(data)
  end

  context "with valid data" do
    let(:data) do
      [
        "5 examples, 2 failures (3 pending)\n",
        "foo1/bar1_spec.rb\n",
        "foo1/bar2_spec.rb\n",
      ]
    end

    describe "#summary" do
      it "sets a summary" do
        expect(subject.summary).to eq("5 examples, 2 failures (3 pending)")
      end
    end

    describe "#failures" do
      it "sets a list of failures" do
        expect(subject.failed_paths).
          to eq(%w(foo1/bar1_spec.rb foo1/bar2_spec.rb))
      end
    end
  end

  context "with no data" do
    let(:data) do
      []
    end

    it "crashes" do
      expect do
        subject.load
      end.to raise_error(
        Guard::RSpec::Results::InvalidData,
        "Invalid results in: foo/bar.txt, lines:\n[]\n")
    end
  end

  context "with invalid data" do
    let(:data) do
      [""]
    end

    it "crashes" do
      expect do
        subject.load
      end.to raise_error(
        Guard::RSpec::Results::InvalidData,
        "Invalid results in: foo/bar.txt, lines:\n[\"\"]\n")
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/guard-rspec-4.6.4/spec/lib/guard/rspec/results_spec.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/guard-rspec-4.6.4/spec/lib/guard/rspec/results_spec.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/guard-rspec-4.6.4/spec/lib/guard/rspec/results_spec.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/guard-rspec-4.6.4/spec/lib/guard/rspec/results_spec.rb
geminfo-0.1.0 path/gems/guard-rspec-4.6.4/spec/lib/guard/rspec/results_spec.rb
guard-rspec-4.6.4 spec/lib/guard/rspec/results_spec.rb
guard-rspec-4.6.3 spec/lib/guard/rspec/results_spec.rb
guard-rspec-4.6.2 spec/lib/guard/rspec/results_spec.rb
guard-rspec-4.6.1 spec/lib/guard/rspec/results_spec.rb
guard-rspec-4.6.0 spec/lib/guard/rspec/results_spec.rb
guard-rspec-4.5.2 spec/lib/guard/rspec/results_spec.rb