Sha256: 831a1cec719871694923118e37c79dd8f5494bcf7003b6860229365835330be3

Contents?: true

Size: 1.76 KB

Versions: 6

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'

RSpec.describe PolishGeeks::DevTools::Config do
  subject { described_class.new }

  described_class::COMMANDS.each do |attribute|
    describe "#{attribute}=" do
      let(:value) { rand }
      before { subject.public_send(:"#{attribute}=", value) }

      it 'should assign a given value' do
        expect(subject.public_send(attribute)).to eq value
      end
    end

    describe "#{attribute}?" do
      let(:value) { rand(2) == 0 }
      before { subject.public_send(:"#{attribute}=", value) }

      it 'should assign a given value' do
        expect(subject.public_send(:"#{attribute}?")).to eq value
      end
    end
  end

  describe '.setup' do
    subject { described_class }
    let(:instance) { described_class.new }
    let(:block) { -> {} }

    before do
      instance

      expect(subject)
        .to receive(:new)
        .and_return(instance)

      expect(block)
        .to receive(:call)
        .with(instance)

      expect(instance)
        .to receive(:freeze)
    end

    it { subject.setup(&block) }
  end

  describe '#detect_framework' do
    before do
      subject. detect_framework
    end

    describe '#rails?' do
      context 'when Rails is not defined' do
        it { expect(subject.rails?).to eq false }
      end
    end

    describe '#sinatra?' do
      context 'when Sinatra is not defined' do
        it { expect(subject.sinatra?).to eq false }
      end
    end
  end

  describe '#initialize' do
    described_class::COMMANDS.each do |attribute|
      it "should have #{attribute} command turned on by default" do
        expect(subject.public_send(attribute)).to eq true
      end
    end

    it 'should have simplecov_threshold set to 100 by default' do
      expect(subject.simplecov_threshold).to eq 100
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
polishgeeks-dev-tools-1.2.0 spec/lib/polishgeeks/dev-tools/config_spec.rb
polishgeeks-dev-tools-1.1.3 spec/lib/polishgeeks/dev-tools/config_spec.rb
polishgeeks-dev-tools-1.1.2 spec/lib/polishgeeks/dev-tools/config_spec.rb
polishgeeks-dev-tools-1.1.1 spec/lib/polishgeeks/dev-tools/config_spec.rb
polishgeeks-dev-tools-1.1.0 spec/lib/polishgeeks/dev-tools/config_spec.rb
polishgeeks-dev-tools-1.0.0 spec/lib/polishgeeks/dev-tools/config_spec.rb