Sha256: bc28236d3018be33f7209b080be27d36f4381f8157c891d553b3ec78b8de95f8

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require File.expand_path('spec_helper', __dir__)

module Danger
  describe Danger::DangerSpecPostfix do
    it 'is a plugin' do
      expect(described_class.new(nil)).to be_a Danger::Plugin
    end

    describe 'with Dangerfile' do
      let(:file_path) { nil }

      before do
        @spec_postfix = testing_dangerfile.spec_postfix

        allow(@spec_postfix.git).to receive(:added_files).and_return([])
        allow(@spec_postfix.git).to receive(:modified_files).and_return([file_path])
      end

      subject do
        @spec_postfix.lint
        @spec_postfix.status_report[:warnings]
      end

      context 'with _spec' do
        let(:file_path) { 'spec/models/my_test_spec.rb' }

        it { is_expected.to be_empty }
      end

      context 'with no _spec' do
        let(:file_path) { 'spec/models/my_test.rb' }

        it { is_expected.to eq(["Tests should have `_spec` postfix: #{file_path}"]) }
      end

      context 'when is irrelevant (exceptions)' do
        before do
          described_class.configure do |config|
            config.exceptions = 'not_tests/'
          end
        end

        let(:file_path) { 'not_tests/factory.rb' }

        it { is_expected.to be_empty }
      end
    end
  end
end

Version data entries

3 entries across 2 versions & 1 rubygems

Version Path
danger-spec_postfix-0.0.2 spec_postfix_spec.rb
danger-spec_postfix-0.0.1 spec/spec_postfix_spec.rb
danger-spec_postfix-0.0.1 spec_postfix_spec.rb