BigW Consortium Gitlab

fake_application_settings_spec.rb 972 Bytes
Newer Older
1 2 3
require 'spec_helper'

describe Gitlab::FakeApplicationSettings do
4
  let(:defaults) { { password_authentication_enabled: false, foobar: 'asdf', signup_enabled: true, 'test?' => 123 } }
5 6 7 8

  subject { described_class.new(defaults) }

  it 'wraps OpenStruct variables properly' do
9
    expect(subject.password_authentication_enabled).to be_falsey
10 11 12 13 14
    expect(subject.signup_enabled).to be_truthy
    expect(subject.foobar).to eq('asdf')
  end

  it 'defines predicate methods' do
15
    expect(subject.password_authentication_enabled?).to be_falsey
16 17 18 19
    expect(subject.signup_enabled?).to be_truthy
  end

  it 'predicate method changes when value is updated' do
20
    subject.password_authentication_enabled = true
21

22
    expect(subject.password_authentication_enabled?).to be_truthy
23 24 25 26 27 28 29 30 31 32
  end

  it 'does not define a predicate method' do
    expect(subject.foobar?).to be_nil
  end

  it 'does not override an existing predicate method' do
    expect(subject.test?).to eq(123)
  end
end