Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
First crack at Kumade::Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Berke-Williams committed Sep 10, 2011
1 parent ee04efc commit 681bc8f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/kumade.rb
Expand Up @@ -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
14 changes: 14 additions & 0 deletions 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
37 changes: 37 additions & 0 deletions 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
12 changes: 12 additions & 0 deletions 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

0 comments on commit 681bc8f

Please sign in to comment.