spec/unit/settings/definition_spec.rb in r10k-2.2.2 vs spec/unit/settings/definition_spec.rb in r10k-2.3.0
- old
+ new
@@ -1,22 +1,26 @@
require 'spec_helper'
require 'r10k/settings/definition'
+require 'r10k/settings/collection'
+require 'r10k/settings/list'
describe R10K::Settings::Definition do
+ subject { described_class.new(:setting) }
+
+ it_behaves_like "a setting with ancestors"
+
describe "#evaluate" do
it "assigns a value, validates it, and resolves a final value" do
- subject = described_class.new(:setting)
expect(subject).to receive(:assign).with("myvalue")
expect(subject).to receive(:validate)
expect(subject).to receive(:resolve)
subject.evaluate("myvalue")
end
end
describe "#assign" do
it 'stores the provided value' do
- subject = described_class.new(:setting)
subject.assign("I'm the value")
expect(subject.value).to eq "I'm the value"
end
it "normalizes the stored value when a normalize hook is set" do
@@ -31,11 +35,10 @@
subject = described_class.new(:setting, :validate => lambda { |_| raise "Shouldn't be called" })
subject.validate
end
it "does nothing if a validate hook has not been assigned" do
- subject = described_class.new(:setting)
subject.assign("I'm the value")
subject.validate
end
it "raises up errors raised from the validate hook" do
@@ -53,11 +56,10 @@
end
end
describe "#resolve" do
it "returns the value when the value has been given" do
- subject = described_class.new(:setting)
subject.assign("Mun")
expect(subject.resolve).to eq "Mun"
end
it "resolves the default when the default is a proc" do
@@ -69,10 +71,9 @@
subject = described_class.new(:setting, :default => "Ike")
expect(subject.resolve).to eq "Ike"
end
it "returns nil when there is no value nor default" do
- subject = described_class.new(:setting)
expect(subject.resolve).to be_nil
end
end
end