From 681bc8fa372c4fedf8a6bfc1621614d436e98d66 Mon Sep 17 00:00:00 2001 From: Gabe Berke-Williams Date: Fri, 9 Sep 2011 23:42:27 -0400 Subject: [PATCH] First crack at Kumade::Configuration --- lib/kumade.rb | 5 +++++ lib/kumade/configuration.rb | 14 ++++++++++++ spec/kumade/configuration_spec.rb | 37 +++++++++++++++++++++++++++++++ spec/kumade_spec.rb | 12 ++++++++++ 4 files changed, 68 insertions(+) create mode 100644 lib/kumade/configuration.rb create mode 100644 spec/kumade/configuration_spec.rb create mode 100644 spec/kumade_spec.rb diff --git a/lib/kumade.rb b/lib/kumade.rb index 81a2c71..6e30cf9 100644 --- a/lib/kumade.rb +++ b/lib/kumade.rb @@ -5,4 +5,9 @@ module Kumade autoload :CLI, "kumade/cli" autoload :Railtie, "kumade/railtie" autoload :DeploymentError, "kumade/deployment_error" + autoload :Configuration, "kumade/configuration" + + def self.configuration + @@configuration ||= Kumade::Configuration.new + end end diff --git a/lib/kumade/configuration.rb b/lib/kumade/configuration.rb new file mode 100644 index 0000000..e650bb9 --- /dev/null +++ b/lib/kumade/configuration.rb @@ -0,0 +1,14 @@ +module Kumade + class Configuration + def initialize + @environment = 'staging' + @pretending = false + end + + def pretending? + !!@pretending + end + + attr_accessor :pretending, :environment + end +end diff --git a/spec/kumade/configuration_spec.rb b/spec/kumade/configuration_spec.rb new file mode 100644 index 0000000..27ed72c --- /dev/null +++ b/spec/kumade/configuration_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe Kumade::Configuration do + context "#pretending" do + it "has read/write access for the pretending attribute" do + subject.pretending = true + subject.pretending.should == true + end + end + + context "pretending?" do + it "returns false when not pretending" do + subject.pretending = false + subject.should_not be_pretending + end + + it "returns true when pretending" do + subject.pretending = true + subject.should be_pretending + end + + it "defaults to false" do + subject.pretending.should == false + end + end + + context "#environment" do + it "has read/write access for the environment attribute" do + subject.environment = 'new-environment' + subject.environment.should == 'new-environment' + end + + it "defaults to staging" do + subject.environment.should == 'staging' + end + end +end diff --git a/spec/kumade_spec.rb b/spec/kumade_spec.rb new file mode 100644 index 0000000..609d846 --- /dev/null +++ b/spec/kumade_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe Kumade, ".configuration" do + it "returns a Kumade::Configuration instance" do + Kumade.configuration.should be_a Kumade::Configuration + end + + it "caches the configuration" do + Kumade.configuration.should eq Kumade.configuration + end +end +