Sha256: 9491637bd4559bc374f64a94da60f884dea9704e48bea19674c6dba5811ea683

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

RSpec.describe Owners::CLI do
  subject { capture { command } }

  let(:command) { described_class.start(args) }

  def capture
    stdout = $stdout
    $stdout = StringIO.new
    yield
    $stdout.string
  ensure
    $stdout = stdout
  end

  describe "for" do
    let(:args) { ["for", "example/app/controllers/users_controller.rb"] }

    context "without a specified file" do
      it "parses owners correctly" do
        expect(subject).to eq("@org/auth\n@org/blog\n")
      end
    end

    context "with a specified file" do
      before { args << "--file" << "SOMETHING_ELSE" }

      it "overrides the default OWNERS filename" do
        begin
          expect(subject).to eq("")
        ensure
          Owners.file = nil
        end
      end
    end
  end

  describe "for_diff" do
    let(:args) { ["for_diff", "0757297", "d0e67df"] }

    context "without a specified file" do
      it "parses owners correctly" do
        expect(subject).to eq("@org/blog\n@whitespace\ndata@example.com\n")
      end
    end

    context "with a specified file" do
      before { args << "--file" << "SOMETHING_ELSE" }

      it "overrides the default OWNERS filename" do
        begin
          expect(subject).to eq("")
        ensure
          Owners.file = nil
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
owners-0.0.7 spec/owners_cli_spec.rb
owners-0.0.6 spec/owners_cli_spec.rb
owners-0.0.5 spec/owners_cli_spec.rb
owners-0.0.4 spec/owners_cli_spec.rb