Sha256: 83852464db2462dfbe22f1bc45ef55b2c3859fbc73d829a6953616e2bb4ac6a9

Contents?: true

Size: 1.44 KB

Versions: 6

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

describe Dotenvious::MismatchedVariableFinder do
  describe '.mismatched_vars' do
    before do
      stub_const('Dotenvious::ENV', {'test' => 'test_value', 'test_2' => 'same'} )
      stub_const('Dotenvious::ENV_EXAMPLE', {'test_2' => 'different', 'test_3' => 'test_value'} )
    end
    context 'without custom configuration' do
      it 'returns array of keys whose values are mismatched ENV & ENV_EXAMPLE' do
        expect(described_class.mismatched_vars).to match_array(['test_2'])
      end
    end

    context 'with custom configuration' do
      before do
        stub_const('Dotenvious::ENV', {'TEST' => 'same', 'TEST_2' => 'some_value'} )
        stub_const('Dotenvious::ENV_EXAMPLE', {'TEST' => 'different', 'TEST_2' => 'different_value'} )
        stub_const('Dotenvious::CONFIG', { custom_variables: ['TEST'] } )
      end

      it 'ignores vars specified in CONFIG[:custom_variables]' do
        expect(described_class.mismatched_vars).to match_array(['TEST_2'])
      end
    end
  end

  describe '.mismatched_vars?' do
    it 'returns true if mismatched_vars are present' do
      expect(described_class).to receive(:mismatched_vars).and_return(['asdf'])

      expect(described_class.mismatched_vars?).to be true
    end

    it 'returns false if mismatched_vars are not present' do
      expect(described_class).to receive(:mismatched_vars).and_return([])

      expect(described_class.mismatched_vars?).to be false
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dotenvious-0.0.7 spec/dotenvious/mismatched_variable_finder_spec.rb
dotenvious-0.0.6 spec/dotenvious/mismatched_variable_finder_spec.rb
dotenvious-0.0.5 spec/dotenvious/mismatched_variable_finder_spec.rb
dotenvious-0.0.4 spec/dotenvious/mismatched_variable_finder_spec.rb
dotenvious-0.0.3 spec/dotenvious/mismatched_variable_finder_spec.rb
dotenvious-0.0.1 spec/dotenvious/mismatched_variable_finder_spec.rb