Sha256: cfdb5d14b8f10248b27dead481df30a4374c77baaa8cf296c90f33545fd8f921

Contents?: true

Size: 1.62 KB

Versions: 2

Compression:

Stored size: 1.62 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::Suit::Utils::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

2 entries across 2 versions & 1 rubygems

Version Path
hexx-suit-0.1.0 spec/tests/tasks/check/rubocop/run_spec.rb
hexx-suit-0.0.1 spec/tests/tasks/check/rubocop/run_spec.rb