Sha256: db7242eb40b214ee0cf4e9227e1d5a875ce990dffdb3e0e4581004332f4b7c15

Contents?: true

Size: 962 Bytes

Versions: 19

Compression:

Stored size: 962 Bytes

Contents

describe Mattock::Configurable do
  class TestSuperStruct
    include Mattock::Configurable

    setting(:three, 3)
    required_field(:four)
  end

  class TestStruct < TestSuperStruct
    settings(:one => 1, :two => nested(:a => "a").required_field(:b))
    nil_field(:five)
  end

  subject do
    TestStruct.new.setup_defaults
  end

  it "should set defaults" do
    subject.one.should == 1
    subject.two.a.should == "a"
    subject.three.should == 3
    subject.five.should be_nil
  end

  it "should complain about unset required fields" do
    expect do
      subject.check_required
    end.to raise_error
  end

  it "should complain about unset nested required fields" do
    subject.four = 4
    expect do
      subject.check_required
    end.to raise_error
  end

  it "should not complain when required fields are set" do
    subject.four = 4
    subject.two.b = "b"
    expect do
      subject.check_required
    end.to_not raise_error
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
mattock-0.2.13 spec/configurable.rb
mattock-0.2.12 spec/configurable.rb
mattock-0.2.11 spec/configurable.rb
mattock-0.2.10 spec/configurable.rb
mattock-0.2.9 spec/configurable.rb
mattock-0.2.8 spec/configurable.rb
mattock-0.2.7 spec/configurable.rb
mattock-0.2.6 spec/configurable.rb
mattock-0.2.5 spec/configurable.rb
mattock-0.2.4 spec/configurable.rb
mattock-0.2.3 spec/configurable.rb
mattock-0.2.2 spec/configurable.rb
mattock-0.2.1 spec/configurable.rb
mattock-0.2.0 spec/configurable.rb
mattock-0.1.3 spec/configurable.rb
mattock-0.1.2 spec/configurable.rb
mattock-0.1.1 spec/configurable.rb
mattock-0.1.0 spec/configurable.rb
mattock-0.0.1 spec/configurable.rb