Sha256: f7f8a46609b3a17a0913e3ee108315d3b3b2c190319c267c8e5fb49bb08329e7

Contents?: true

Size: 1.61 KB

Versions: 4

Compression:

Stored size: 1.61 KB

Contents

# encoding: utf-8

describe "Rake::Task['check:rubocop:run']", :tasks do

  # The {#commands} variable is defined in the spec/support/config/tasks.rb
  # It collects the list of commands, that has been sent to system by
  # any instance of Hexx::RSpec::System utility.

  let(:task)   { Rake::Task["check:rubocop:run"] }

  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"  => "yml"
      }
    end

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

  shared_examples "metric loader" do

    after { subject }

    it "[loads rubocop]" do
      expect(Hexx::Suit::Metrics::Rubocop).to receive :load
    end
  end

  shared_examples "metric runner" do

    let(:command) do
      %W(
        rubocop
        -f #{ options['format'] }
        -o #{ options['output'] }
        -c config/metrics/rubocop.yml
      ).join(" ")
    end

    it "[runs rubocop]" do
      expect { subject }.to change { commands }.to [command]
    end
  end

  describe ".invoke", :sandbox do

    subject { try_in_sandbox { task.invoke } }

    context "when .metrics.yml is absent" do

      include_context "without rubocop.yml"

      it_behaves_like "metric loader"
      it_behaves_like "metric runner"
    end

    context "when .metrics.yml is present" do

      include_context "with rubocop.yml"

      it_behaves_like "metric loader"
      it_behaves_like "metric runner"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hexx-suit-1.5.0-x86_64-linux spec/tests/tasks/check/rubocop/run_spec.rb
hexx-suit-1.3.0-x86_64-linux spec/tests/tasks/check/rubocop/run_spec.rb
hexx-suit-1.2.0 spec/tests/tasks/check/rubocop/run_spec.rb
hexx-suit-1.0.0 spec/tests/tasks/check/rubocop/run_spec.rb