Sha256: 082b4f21c7d974fe0ad0a3af29c60be81f48bb58e0213f428fbc52763dcaf032

Contents?: true

Size: 1.23 KB

Versions: 8

Compression:

Stored size: 1.23 KB

Contents

# encoding: utf-8
require "spec_helper"

describe Hexx::Suit::Metrics::Rubocop, :sandbox, :capture do

  shared_context "without rubocop.yml" do

    let(:options) do
      { "output" => "tmp/rubocop/index.html", "format" => "html" }
    end
  end

  shared_context "with rubocop.yml" do

    let(:options) do
      { "output" => "custom/rubocop.html", "format" => "custom" }
    end

    before { prepare_settings options, "config/metrics/rubocop.yml" }
  end

  shared_examples "environments loader" do

    before { ENV["RUBOCOP_OUTPUT"] = nil }
    before { ENV["RUBOCOP_FORMAT"] = nil }

    it "[sets RUBOCOP_OUTPUT]" do
      expect { subject }
        .to change { ENV["RUBOCOP_OUTPUT"] }
        .to options["output"]
    end

    it "[sets RUBOCOP_FORMAT]" do
      expect { subject }
        .to change { ENV["RUBOCOP_FORMAT"] }
        .to options["format"]
    end
  end

  describe ".load" do

    subject { try_in_sandbox { described_class.load } }

    context "when rubocop.yml is absent" do

      include_context "without rubocop.yml"

      it_behaves_like "environments loader"
    end

    context "when rubocop.yml is present" do

      include_context "with rubocop.yml"

      it_behaves_like "environments loader"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hexx-suit-2.3.2 spec/tests/lib/metrics/rubocop_spec.rb
hexx-suit-2.3.0 spec/tests/lib/metrics/rubocop_spec.rb
hexx-suit-2.2.3 spec/tests/lib/metrics/rubocop_spec.rb
hexx-suit-2.2.2 spec/tests/lib/metrics/rubocop_spec.rb
hexx-suit-2.2.1 spec/tests/lib/metrics/rubocop_spec.rb
hexx-suit-2.2.0 spec/tests/lib/metrics/rubocop_spec.rb
hexx-suit-2.1.0 spec/tests/lib/metrics/rubocop_spec.rb
hexx-suit-2.0.0 spec/tests/lib/metrics/rubocop_spec.rb