konfigurator 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -1,22 +1,11 @@
1
- ## MAC OS
2
1
  .DS_Store
3
-
4
- ## TEXTMATE
5
2
  *.tmproj
6
3
  tmtags
7
-
8
- ## EMACS
9
4
  *~
10
5
  \#*
11
6
  .\#*
12
-
13
- ## VIM
14
7
  *.swp
15
-
16
- ## PROJECT::GENERAL
17
8
  coverage
18
9
  rdoc
19
10
  pkg
20
-
21
- ## PROJECT::SPECIFIC
22
11
  *.rdb
@@ -62,38 +62,71 @@ Not there is also possible to use nice-looking DSL syntax provided by
62
62
  <tt>Konfigurator::DSL</tt>. It allow you to configure your apps/classes
63
63
  such like here:
64
64
 
65
- Foo.configure do
66
- host "127.0.0.1"
67
- port 8080
68
- password "secret"
69
- end
65
+ Foo.configure do
66
+ host "127.0.0.1"
67
+ port 8080
68
+ password "secret"
69
+ end
70
70
 
71
71
  But what's important in this kind of configuration, you have to define all possible
72
72
  options first. You can define configuration attributes easy using <tt>#attr_config</tt>
73
73
  (or <tt>#attr_setting</tt> alias).
74
74
 
75
- class Foo
76
- include Konfigurator::DSL
75
+ class Foo
76
+ include Konfigurator::DSL
77
77
 
78
- attr_config :host, :port
79
- attr_config :password
80
- end
78
+ attr_config :host, :port
79
+ attr_config :password
80
+ end
81
81
 
82
82
  Other use cases behave almost the same as with Konfigurator::Simple:
83
83
 
84
- Foo.host # => "127.0.0.1"
85
- Foo.port # => 8080
84
+ Foo.host # => "127.0.0.1"
85
+ Foo.port # => 8080
86
+
87
+ Foo.env :production
88
+ Foo.configure :production do
89
+ host "production.com"
90
+ port 80
91
+ end
86
92
 
87
- Foo.env :production
88
- Foo.configure :production do
89
- host "production.com"
90
- port 80
91
- end
93
+ foo = Foo.new
94
+ foo.settings.host # => "production.com"
95
+ foo.settings.port # => 80
92
96
 
93
- foo = Foo.new
94
- foo.settings.host # => "production.com"
95
- foo.settings.port # => 80
97
+ == Configuring Rails 3 application
98
+
99
+ You can easily mix Konfigurator with your Rails 3 app. Add this line to your <tt>config/application.rb</tt>:
96
100
 
101
+ require 'konfigurator/railtie'
102
+
103
+ ... and now you can set your own configuration, eg:
104
+
105
+ module MyApp
106
+ class Application < Rails::Application
107
+ set :foo, "Foo"
108
+ set :bat, "Bar"
109
+ enable :foobar
110
+
111
+ # ...
112
+ end
113
+ end
114
+
115
+ Now you can use it in controllers...
116
+
117
+ class UsersController
118
+ def index
119
+ if settings.foobar and settings.foo == "Foo"
120
+ # ...
121
+ end
122
+ end
123
+ end
124
+
125
+ ... and views...
126
+
127
+ <h1><%= settings.foo %></h1>
128
+ <p><%= settings.bar %></p>
129
+
97
130
  == Note on Patches/Pull Requests
98
131
 
99
132
  * Fork the project.
data/Rakefile CHANGED
@@ -1,52 +1,40 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ # -*- ruby -*-
3
2
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "konfigurator"
8
- gem.summary = %Q{Small and flexible Configuration toolkit inspired i.a. by Sinatra settings.}
9
- gem.description = <<-DESCR
10
- Konfigurator is a small and flexible configuration toolkit, which allow you
11
- to configure your apps, classes or modules with DSL-style or Sinatra-like settings.
12
- DESCR
13
- gem.email = "kriss.kowalik@gmail.com"
14
- gem.homepage = "http://github.com/nu7hatch/konfigurator"
15
- gem.authors = ["Kriss 'nu7hatch' Kowalik"]
16
- gem.add_development_dependency "contest", ">= 0.1.2"
17
- end
18
- Jeweler::GemcutterTasks.new
19
- rescue LoadError
20
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
- end
3
+ $:.unshift(File.expand_path('../lib', __FILE__))
4
+ require 'konfigurator/version'
5
+ require 'rspec/core/rake_task'
6
+ require 'rake/rdoctask'
22
7
 
23
- require 'rake/testtask'
24
- Rake::TestTask.new(:test) do |test|
25
- test.libs << 'lib' << 'test'
26
- test.pattern = 'test/**/test_*.rb'
27
- test.verbose = true
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.pattern = 'spec/**/*_spec.rb'
10
+ t.rspec_opts = %q[-c -b]
28
11
  end
29
12
 
30
- begin
31
- require 'rcov/rcovtask'
32
- Rcov::RcovTask.new do |test|
33
- test.libs << 'test'
34
- test.pattern = 'test/**/test_*.rb'
35
- test.verbose = true
36
- end
37
- rescue LoadError
38
- task :rcov do
39
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
- end
13
+ RSpec::Core::RakeTask.new(:rcov) do |t|
14
+ t.rcov = true
15
+ t.rspec_opts = %q[-c -b]
16
+ t.rcov_opts = %q[-T -x "spec"]
41
17
  end
42
18
 
43
- task :default => :test
44
-
45
- require 'rake/rdoctask'
46
19
  Rake::RDocTask.new do |rdoc|
47
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
20
  rdoc.rdoc_dir = 'rdoc'
49
- rdoc.title = "Konfigurator #{version}"
21
+ rdoc.title = "Konfigurator #{Konfigurator.version}"
50
22
  rdoc.rdoc_files.include('README*')
51
23
  rdoc.rdoc_files.include('lib/**/*.rb')
52
24
  end
25
+
26
+ task :default => :spec
27
+
28
+ desc "Build current version as a rubygem"
29
+ task :build do
30
+ `gem build konfigurator.gemspec`
31
+ `mv konfigurator-*.gem pkg/`
32
+ end
33
+
34
+ desc "Relase current version to rubygems.org"
35
+ task :release => :build do
36
+ `git tag -am "Version bump to #{Konfigurator.version}" v#{Konfigurator.version}`
37
+ `git push origin master`
38
+ `git push origin master --tags`
39
+ `gem push pkg/konfigurator-#{Konfigurator.version}.gem`
40
+ end
@@ -1,59 +1,19 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
1
+ # -*- ruby -*-
2
+ $:.unshift(File.expand_path('../lib', __FILE__))
3
+ require 'konfigurator/version'
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{konfigurator}
8
- s.version = "0.1.1"
6
+ s.name = 'konfigurator'
7
+ s.version = Konfigurator.version
8
+ s.homepage = 'http://github.com/nu7hatch/konfigurator'
9
+ s.email = ['chris@nu7hat.ch']
10
+ s.authors = ['Chris Kowalik']
11
+ s.summary = %q{Small and flexible Configuration toolkit inspired i.a. by Sinatra settings.}
12
+ s.description = %q{Konfigurator is a small and flexible configuration toolkit, which allow you to configure your apps, classes or modules with DSL-style or Sinatra-like settings.}
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
15
+ s.require_paths = %w[lib]
16
+ s.extra_rdoc_files = %w[LICENSE README.rdoc]
9
17
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Kriss 'nu7hatch' Kowalik"]
12
- s.date = %q{2010-10-29}
13
- s.description = %q{ Konfigurator is a small and flexible configuration toolkit, which allow you
14
- to configure your apps, classes or modules with DSL-style or Sinatra-like settings.
15
- }
16
- s.email = %q{kriss.kowalik@gmail.com}
17
- s.extra_rdoc_files = [
18
- "LICENSE",
19
- "README.rdoc"
20
- ]
21
- s.files = [
22
- ".gitignore",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "konfigurator.gemspec",
28
- "lib/konfigurator.rb",
29
- "lib/konfigurator/dsl.rb",
30
- "lib/konfigurator/simple.rb",
31
- "test/helper.rb",
32
- "test/test_dsl.rb",
33
- "test/test_simple.rb"
34
- ]
35
- s.homepage = %q{http://github.com/nu7hatch/konfigurator}
36
- s.rdoc_options = ["--charset=UTF-8"]
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.3.7}
39
- s.summary = %q{Small and flexible Configuration toolkit inspired i.a. by Sinatra settings.}
40
- s.test_files = [
41
- "test/test_dsl.rb",
42
- "test/test_simple.rb",
43
- "test/helper.rb"
44
- ]
45
-
46
- if s.respond_to? :specification_version then
47
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
- s.specification_version = 3
49
-
50
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
- s.add_development_dependency(%q<contest>, [">= 0.1.2"])
52
- else
53
- s.add_dependency(%q<contest>, [">= 0.1.2"])
54
- end
55
- else
56
- s.add_dependency(%q<contest>, [">= 0.1.2"])
57
- end
18
+ s.add_development_dependency 'contest', [">= 0.1.2"]
58
19
  end
59
-
@@ -51,11 +51,10 @@ module Konfigurator
51
51
  def settings
52
52
  @settings ||= {}
53
53
  end
54
- alias :config :settings
55
54
 
56
55
  # It returns name of current environment.
57
56
  def environment
58
- settings[:environment] ||= settings[:env] || ENV["APP_ENV"] || :development
57
+ settings[:environment] ||= settings[:env] || ENV["RAILS_ENV"] || ENV["APP_ENV"] || :development
59
58
  end
60
59
  alias :env :environment
61
60
  end # ClassMethods
@@ -0,0 +1,20 @@
1
+ require 'rails'
2
+ require 'konfigurator'
3
+
4
+ module Konfigurator
5
+ module Helpers
6
+ module ActionController
7
+ def self.included(base)
8
+ base.send :extend, self
9
+ base.helper_method :settings
10
+ end
11
+
12
+ def settings
13
+ Rails.application.settings
14
+ end
15
+ end # ActionController
16
+ end # Helpers
17
+ end # Konfigurator
18
+
19
+ Rails::Application.send :include, Konfigurator::Simple
20
+ ActionController::Base.send :include, Konfigurator::Helpers::ActionController
@@ -0,0 +1,12 @@
1
+ module Konfigurator
2
+ module Version # :nodoc:
3
+ MAJOR = 0
4
+ MINOR = 2
5
+ PATCH = 0
6
+ STRING = [MAJOR, MINOR, PATCH].join('.')
7
+ end
8
+
9
+ def self.version # :nodoc:
10
+ Version::STRING
11
+ end
12
+ end # Konfigurator
@@ -0,0 +1,53 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "Object configured with Konfigurator::DSL" do
4
+ subject do
5
+ ConfiguredWithDSL
6
+ end
7
+
8
+ it_should_behave_like "configured"
9
+
10
+ it "responds to #attr_config and #attr_setting" do
11
+ subject.should respond_to(:attr_config)
12
+ subject.should respond_to(:attr_setting)
13
+ end
14
+
15
+ it "responds to defined #foo and #bar settings" do
16
+ subject.should respond_to(:foo)
17
+ subject.should respond_to(:bar)
18
+ end
19
+
20
+ it "allows to set config option value with DSL-style syntax" do
21
+ subject.foo :bar
22
+ subject.foo.should == :bar
23
+ end
24
+
25
+ it "allows for quick access to current environment name" do
26
+ subject.environment :production
27
+ subject.environment.should == :production
28
+ end
29
+
30
+ it "allows to load settings from yaml file" do
31
+ with_conf_file do |fname|
32
+ subject.environment :production
33
+ subject.attr_config :bla
34
+ subject.load_settings(fname)
35
+
36
+ subject.bla.should be
37
+ subject.foo.should == "bar"
38
+ end
39
+ end
40
+
41
+ it "allows to define configuration specific for current env" do
42
+ subject.attr_config :prod, :dev, :bar
43
+ subject.environment :development
44
+ subject.prod false
45
+ subject.configure(:production) { prod true }
46
+ subject.configure(:development) { dev true }
47
+ subject.configure(:development, :production) { bar :foo }
48
+
49
+ subject.dev.should be
50
+ subject.prod.should_not be
51
+ subject.bar.should == :foo
52
+ end
53
+ end
@@ -0,0 +1,91 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "Konfigurator::Simple" do
4
+ subject do
5
+ ConfiguredWithSimple
6
+ end
7
+
8
+ it_should_behave_like "configured"
9
+
10
+ it "responds to #set" do
11
+ subject.should respond_to(:set)
12
+ end
13
+
14
+ it "responds to #enable" do
15
+ subject.should respond_to(:enable)
16
+ end
17
+
18
+ it "responds to #disable" do
19
+ subject.should respond_to(:disable)
20
+ end
21
+
22
+ it "allows to set given option" do
23
+ subject.set(:foo, "bar").should == "bar"
24
+ subject.settings[:foo].should == "bar"
25
+ end
26
+
27
+ it "allows to quick disable given option" do
28
+ subject.disable(:foo).should_not be
29
+ subject.foo.should_not be
30
+ end
31
+
32
+ it "allows to quick enable given option" do
33
+ subject.enable(:foo).should be
34
+ subject.foo.should be
35
+ end
36
+
37
+ it "allows for quick access to current environment name" do
38
+ subject.set :environment, :production
39
+ subject.environment.should == :production
40
+ end
41
+
42
+ it "allows to define configuration specific for current env" do
43
+ subject.set :environment, :development
44
+ subject.disable :prod
45
+ subject.configure(:production) { enable :prod }
46
+ subject.configure(:development) { enable :dev }
47
+ subject.configure(:development, :production) { set :bar, :foo }
48
+
49
+ subject.dev.should be
50
+ subject.prod.should_not be
51
+ subject.bar.should == :foo
52
+ end
53
+
54
+ it "allows to load settings from yaml file" do
55
+ with_conf_file do |fname|
56
+ subject.set :environment, :production
57
+ subject.load_settings(fname)
58
+
59
+ subject.bla.should be
60
+ subject.foo.should == "bar"
61
+ end
62
+ end
63
+
64
+ it "not uses envs when use_envs is false" do
65
+ with_conf_file do |fname|
66
+ subject.set :environment, :production
67
+ subject.load_settings(fname, false)
68
+
69
+ subject.production.should be_kind_of(Hash)
70
+ subject.production['foo'].should == "bar"
71
+ end
72
+ end
73
+ end
74
+
75
+ describe "Object configured with Konfigurator::Simple" do
76
+ subject do
77
+ ConfiguredWithSimple
78
+ end
79
+
80
+ it "responds to #settings and #config" do
81
+ @configured = subject.new
82
+ @configured.should respond_to(:settings)
83
+ @configured.should respond_to(:config)
84
+ end
85
+
86
+ it "#settings works properly" do
87
+ subject.set(:fooo, :bar)
88
+ @configured = subject.new
89
+ @configured.settings.fooo.should == :bar
90
+ end
91
+ end
@@ -1,36 +1,38 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
2
 
4
- require "rubygems"
5
- require "test/unit"
6
- require "contest"
3
+ require "rspec"
4
+ require "mocha"
7
5
  require "fileutils"
8
6
  require "konfigurator"
9
7
 
10
- COMMON_TESTS = <<-EVAL
11
- should "respond to #environment and #env" do
12
- assert subject.respond_to?(:environment)
13
- assert subject.respond_to?(:env)
14
- end
15
-
16
- should "respond to #settings and #config" do
17
- assert subject.respond_to?(:settings)
18
- assert subject.respond_to?(:config)
19
- end
20
-
21
- should "respond to #configure" do
22
- assert subject.respond_to?(:configure)
23
- end
24
- EVAL
8
+ RSpec.configure do |conf|
9
+ conf.mock_with :mocha
10
+ end
25
11
 
26
- CONFIG_FILE_CONTENT = <<-CONTENT
12
+ CONFIG_FILE_CONTENT = <<-YAML
27
13
  production:
28
14
  foo: bar
29
15
  bla: true
30
16
  development:
31
17
  foo: bla
32
18
  bla: false
33
- CONTENT
19
+ YAML
20
+
21
+ shared_examples_for "configured" do
22
+ it "responds to #environment and #env" do
23
+ subject.should respond_to(:environment)
24
+ subject.should respond_to(:env)
25
+ end
26
+
27
+ it "responds to #settings and #config" do
28
+ subject.should respond_to(:settings)
29
+ subject.should respond_to(:config)
30
+ end
31
+
32
+ it "responds to #configure" do
33
+ subject.should respond_to(:configure)
34
+ end
35
+ end
34
36
 
35
37
  class ConfiguredWithSimple
36
38
  include Konfigurator::Simple
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: konfigurator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
- - Kriss 'nu7hatch' Kowalik
13
+ - Chris Kowalik
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-29 00:00:00 +02:00
18
+ date: 2011-01-24 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -34,8 +34,9 @@ dependencies:
34
34
  version: 0.1.2
35
35
  type: :development
36
36
  version_requirements: *id001
37
- description: " Konfigurator is a small and flexible configuration toolkit, which allow you \n to configure your apps, classes or modules with DSL-style or Sinatra-like settings.\n"
38
- email: kriss.kowalik@gmail.com
37
+ description: Konfigurator is a small and flexible configuration toolkit, which allow you to configure your apps, classes or modules with DSL-style or Sinatra-like settings.
38
+ email:
39
+ - chris@nu7hat.ch
39
40
  executables: []
40
41
 
41
42
  extensions: []
@@ -48,21 +49,22 @@ files:
48
49
  - LICENSE
49
50
  - README.rdoc
50
51
  - Rakefile
51
- - VERSION
52
52
  - konfigurator.gemspec
53
53
  - lib/konfigurator.rb
54
54
  - lib/konfigurator/dsl.rb
55
+ - lib/konfigurator/railtie.rb
55
56
  - lib/konfigurator/simple.rb
56
- - test/helper.rb
57
- - test/test_dsl.rb
58
- - test/test_simple.rb
57
+ - lib/konfigurator/version.rb
58
+ - spec/dsl_spec.rb
59
+ - spec/simple_spec.rb
60
+ - spec/spec_helper.rb
59
61
  has_rdoc: true
60
62
  homepage: http://github.com/nu7hatch/konfigurator
61
63
  licenses: []
62
64
 
63
65
  post_install_message:
64
- rdoc_options:
65
- - --charset=UTF-8
66
+ rdoc_options: []
67
+
66
68
  require_paths:
67
69
  - lib
68
70
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -90,7 +92,5 @@ rubygems_version: 1.3.7
90
92
  signing_key:
91
93
  specification_version: 3
92
94
  summary: Small and flexible Configuration toolkit inspired i.a. by Sinatra settings.
93
- test_files:
94
- - test/test_dsl.rb
95
- - test/test_simple.rb
96
- - test/helper.rb
95
+ test_files: []
96
+
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.1
@@ -1,53 +0,0 @@
1
- require "helper"
2
-
3
- class TestDSL < Test::Unit::TestCase
4
- describe "Object configured with Konfigurator::DSL" do
5
- def subject
6
- ConfiguredWithDSL
7
- end
8
-
9
- instance_eval COMMON_TESTS
10
-
11
- should "respond to #attr_config and #attr_setting" do
12
- assert subject.respond_to?(:attr_config)
13
- assert subject.respond_to?(:attr_setting)
14
- end
15
-
16
- should "respond to defined #foo and #bar settings" do
17
- assert subject.respond_to?(:foo)
18
- assert subject.respond_to?(:bar)
19
- end
20
-
21
- should "allow to set config option value with DSL-style syntax" do
22
- subject.foo :bar
23
- assert_equal :bar, subject.foo
24
- end
25
-
26
- should "allow for quick access to current environment name" do
27
- subject.environment :production
28
- assert_equal :production, subject.environment
29
- end
30
-
31
- should "allow to load settings from yaml file" do
32
- with_conf_file do |fname|
33
- subject.environment :production
34
- subject.attr_config :bla
35
- subject.load_settings(fname)
36
- assert subject.bla
37
- assert_equal "bar", subject.foo
38
- end
39
- end
40
-
41
- should "allow to define configuration specific for current env" do
42
- subject.attr_config :prod, :dev, :bar
43
- subject.environment :development
44
- subject.prod false
45
- subject.configure(:production) { prod true }
46
- subject.configure(:development) { dev true }
47
- subject.configure(:development, :production) { bar :foo }
48
- assert subject.dev
49
- assert !subject.prod
50
- assert_equal :foo, subject.bar
51
- end
52
- end
53
- end
@@ -1,93 +0,0 @@
1
- require "helper"
2
-
3
- class TestSimple < Test::Unit::TestCase
4
- describe "Konfigurator::Simple" do
5
- def subject
6
- ConfiguredWithSimple
7
- end
8
-
9
- instance_eval COMMON_TESTS
10
-
11
- should "respond to #set" do
12
- assert subject.respond_to?(:set)
13
- end
14
-
15
- should "respond to #enable" do
16
- assert subject.respond_to?(:enable)
17
- end
18
-
19
- should "respond to #disable" do
20
- assert subject.respond_to?(:disable)
21
- end
22
-
23
- should "allow to set given option" do
24
- assert_equal "bar", subject.set(:foo, "bar")
25
- assert_equal "bar", subject.settings[:foo]
26
- end
27
-
28
- should "allow to quick disable given option" do
29
- assert !subject.disable(:foo)
30
- assert !subject.foo
31
- end
32
-
33
- should "allow to quick enable given option" do
34
- assert subject.enable(:foo)
35
- assert subject.foo
36
- end
37
-
38
- should "allow for quick access to current environment name" do
39
- subject.set :environment, :production
40
- assert_equal :production, subject.environment
41
- end
42
-
43
- should "allow to define configuration specific for current env" do
44
- subject.set :environment, :development
45
- subject.disable :prod
46
- subject.configure(:production) { enable :prod }
47
- subject.configure(:development) { enable :dev }
48
- subject.configure(:development, :production) { set :bar, :foo }
49
- assert subject.dev
50
- assert !subject.prod
51
- assert_equal :foo, subject.bar
52
- end
53
-
54
- should "allow to load settings from yaml file" do
55
- with_conf_file do |fname|
56
- subject.set :environment, :production
57
- subject.load_settings(fname)
58
- assert subject.bla
59
- assert_equal "bar", subject.foo
60
- end
61
- end
62
-
63
- should "not use envs when use_envs is false" do
64
- with_conf_file do |fname|
65
- subject.set :environment, :production
66
- subject.load_settings(fname, false)
67
- assert subject.production
68
- assert_equal "bar", subject.production['foo']
69
- end
70
- end
71
- end
72
-
73
- describe "Object configured with Konfigurator::Simple" do
74
- def subject
75
- ConfiguredWithSimple
76
- end
77
-
78
- setup do
79
- @configured = subject.new
80
- end
81
-
82
- should "respond to #settings and #config" do
83
- assert @configured.respond_to?(:settings)
84
- assert @configured.respond_to?(:config)
85
- end
86
-
87
- should "#settings works properly" do
88
- subject.set(:fooo, :bar)
89
- @configured = subject.new
90
- assert_equal :bar, @configured.settings.fooo
91
- end
92
- end
93
- end