fittings 0.2.0 → 0.2.4.RC1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3d284c9153aca2da7768369111eece8dba1689fa
4
- data.tar.gz: 32ceeb38ef5c2ddc8c2878f4c49ea3383de0118d
2
+ SHA256:
3
+ metadata.gz: e5026c63a940c5db219159494e18492b7b581f461db35356ae49c9ddca6539c4
4
+ data.tar.gz: 295435698db4d94c21b6b5f7f0610df7aa38da36be0d803e472131fd9d0543fb
5
5
  SHA512:
6
- metadata.gz: a20d5db9cdc38c55707b843860eae271c47d211ff1220a2c043e8780965c3e3c3dc35de1c358614aaf587b3caddb541e2f8eba130994f0326c87bda4838911a9
7
- data.tar.gz: e2a67f2e123d73f37ecacb303d9a451bca42fef4c7325cbb8c7233c0dbe35532e589943fdac110d88f394bd9c04e86a3c961891dd8782508756f4a941240a47b
6
+ metadata.gz: 0f68a954f93898276c2101dc2983819cca292ea437fa0970b56a9d647359e075de87a556e5d804838c95c2d3d8875a114d04594267ac9aeaefe8f7183ccbdd59
7
+ data.tar.gz: 8b196dfeec05a698eeb9162862494813b55de72cc531fba8df5d4cc90960c77bf90a5e9fd1c10f0af3344103a266fdfdd08be2b3977897923a3c4bdead5db2ee
@@ -0,0 +1,145 @@
1
+ # DO NOT MODIFY - this is managed by Git Reduce in goro and generated from build-matrix.json
2
+ #
3
+ ---
4
+ version: 2
5
+ jobs:
6
+ generate-and-push-docs:
7
+ docker:
8
+ - image: cimg/ruby:3.0.3
9
+ auth:
10
+ username: "$DOCKERHUB_USERNAME"
11
+ password: "$DOCKERHUB_PASSWORD"
12
+ steps:
13
+ - checkout
14
+ - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
15
+ - run: bundle install
16
+ - run:
17
+ name: Generate documentation
18
+ command: ' if [[ $(bundle exec rake -T docs:generate:custom) ]]; then echo
19
+ "Generating docs using rake task docs:generate:custom" ; bundle exec rake
20
+ docs:generate:custom ; elif [[ $(bundle exec rake -T docs:generate) ]];
21
+ then echo "Generating docs using rake task docs:generate" ; bundle exec
22
+ rake docs:generate ; else echo "Skipping doc generation" ; exit 0 ; fi '
23
+ - run:
24
+ name: Push documentation to Unwritten
25
+ command: if [[ $(bundle exec rake -T docs:push) ]]; then bundle exec rake
26
+ docs:push; fi
27
+ release:
28
+ docker:
29
+ - image: cimg/ruby:3.0.3
30
+ auth:
31
+ username: "$DOCKERHUB_USERNAME"
32
+ password: "$DOCKERHUB_PASSWORD"
33
+ steps:
34
+ - checkout
35
+ - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
36
+ - run: bundle install
37
+ - run:
38
+ name: Artifactory login
39
+ command: mkdir -p ~/.gem && curl -u$ARTIFACTORY_USER:$ARTIFACTORY_TOKEN https://stitchfix01.jfrog.io/stitchfix01/api/gems/eng-gems/api/v1/api_key.yaml
40
+ > ~/.gem/credentials && chmod 0600 ~/.gem/credentials
41
+ - run:
42
+ name: Build/release gem to artifactory
43
+ command: bundle exec rake push_artifactory
44
+ ruby-3.0.3:
45
+ docker:
46
+ - image: cimg/ruby:3.0.3
47
+ auth:
48
+ username: "$DOCKERHUB_USERNAME"
49
+ password: "$DOCKERHUB_PASSWORD"
50
+ working_directory: "~/fittings"
51
+ steps:
52
+ - checkout
53
+ - run:
54
+ name: Check for Gemfile.lock presence
55
+ command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see
56
+ https://github.com/stitchfix/eng-wiki/blob/main/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)"
57
+ 1>&2 ; exit 1 ; else exit 0 ; fi '
58
+ - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
59
+ - run: bundle install
60
+ - run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml
61
+ --format=doc
62
+ - run:
63
+ name: Run Additional CI Steps
64
+ command: if [ -e bin/additional-ci-steps ]; then bin/additional-ci-steps;
65
+ fi
66
+ - run:
67
+ name: Notify Pager Duty
68
+ command: bundle exec y-notify "eng-runtime-info"
69
+ when: on_fail
70
+ - store_test_results:
71
+ path: "/tmp/test-results"
72
+ ruby-2.7.5:
73
+ docker:
74
+ - image: cimg/ruby:2.7.5
75
+ auth:
76
+ username: "$DOCKERHUB_USERNAME"
77
+ password: "$DOCKERHUB_PASSWORD"
78
+ working_directory: "~/fittings"
79
+ steps:
80
+ - checkout
81
+ - run:
82
+ name: Check for Gemfile.lock presence
83
+ command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see
84
+ https://github.com/stitchfix/eng-wiki/blob/main/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)"
85
+ 1>&2 ; exit 1 ; else exit 0 ; fi '
86
+ - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
87
+ - run: bundle install
88
+ - run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml
89
+ --format=doc
90
+ - run:
91
+ name: Run Additional CI Steps
92
+ command: if [ -e bin/additional-ci-steps ]; then bin/additional-ci-steps;
93
+ fi
94
+ - run:
95
+ name: Notify Pager Duty
96
+ command: bundle exec y-notify "eng-runtime-info"
97
+ when: on_fail
98
+ - store_test_results:
99
+ path: "/tmp/test-results"
100
+ workflows:
101
+ version: 2
102
+ on-commit:
103
+ jobs:
104
+ - release:
105
+ context: org-global
106
+ requires:
107
+ - ruby-3.0.3
108
+ - ruby-2.7.5
109
+ filters:
110
+ tags:
111
+ only: /^[0-9]+\.[0-9]+\.[0-9]+(\.?(RC|rc)[-\.]?\w*)?$/
112
+ branches:
113
+ ignore: /.*/
114
+ - generate-and-push-docs:
115
+ context: org-global
116
+ requires:
117
+ - release
118
+ filters:
119
+ tags:
120
+ only: /^[0-9]+\.[0-9]+\.[0-9]+(\.?(RC|rc)[-\.]?\w*)?$/
121
+ branches:
122
+ ignore: /.*/
123
+ - ruby-3.0.3:
124
+ context: org-global
125
+ filters:
126
+ tags:
127
+ only: &1 /.*/
128
+ - ruby-2.7.5:
129
+ context: org-global
130
+ filters:
131
+ tags:
132
+ only: *1
133
+ scheduled:
134
+ triggers:
135
+ - schedule:
136
+ cron: 26 18 * * 1,2,3,4,5
137
+ filters:
138
+ branches:
139
+ only:
140
+ - main
141
+ jobs:
142
+ - ruby-3.0.3:
143
+ context: org-global
144
+ - ruby-2.7.5:
145
+ context: org-global
@@ -0,0 +1,4 @@
1
+ # This file uses the GitHub CODEOWNERS convention to assign PR reviewers:
2
+ # https://help.github.com/articles/about-codeowners/
3
+
4
+ * @stitchfix/runtime-infrastructure
@@ -0,0 +1,7 @@
1
+ ## Problem
2
+
3
+ «Brief overview of the problem»
4
+
5
+ ## Solution
6
+
7
+ «Brief description of how you solved the problem»
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ coverage
2
+ html
3
+ pkg
4
+ .idea
5
+ .rvmrc
6
+ Gemfile.lock
7
+
8
+ ## VS Code and extensions
9
+ .history
10
+ .vscode
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ fittings
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.2
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.6
4
+ - 2.7
5
+ - ruby-head
6
+ before_install:
7
+ - gem install bundler
8
+ jobs:
9
+ allow_failures:
10
+ - rvm: ruby-head
@@ -0,0 +1,6 @@
1
+ # Code of Conduct
2
+
3
+ We are committed to keeping our community open and inclusive.
4
+
5
+ **Our Code of Conduct can be found here**:
6
+ http://opensource.stitchfix.com/code-of-conduct.html
data/README.rdoc CHANGED
@@ -1,4 +1,23 @@
1
- = Application Settings Manager
1
+ = fittings
2
+
3
+ This is a fork of ModCloth's mc-settings gem which has gone unmaintained and has deprecation warnings. This modernizes that and will be maintained.
4
+
5
+ == Install
6
+
7
+ Add to your +Gemfile+:
8
+
9
+ gem "fittings"
10
+
11
+ For Rails, create +config/settings/default.yml+ as well as +config/settings/environments/{development,testing,production}.yml+.
12
+
13
+ Then, in +config/environment.rb+, before the call to +initialize!+:
14
+
15
+ Setting.load(path: "#{Rails.root}/config/settings",
16
+ files: ["default.yml", "environments/#{Rails.env}.yml"])
17
+
18
+ === Why is it +Setting+?
19
+
20
+ This is a fork of the mc-settings gem that is intended to be backwards-compatible.
2
21
 
3
22
  == Summary
4
23
 
data/Rakefile CHANGED
@@ -1,14 +1,23 @@
1
- require 'bundler/gem_tasks'
2
- require 'rubygems/package_task'
3
- require 'rspec/core/rake_task'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rubygems/package_task"
4
+ require "rdoc/task"
4
5
 
5
- $: << File.join(File.dirname(__FILE__),'lib')
6
+ $: << File.join(File.dirname(__FILE__),"lib")
6
7
 
7
8
  include Rake::DSL
8
9
 
9
- gemspec = eval(File.read('fittings.gemspec'))
10
+ gemspec = eval(File.read("fittings.gemspec"))
11
+
10
12
  Gem::PackageTask.new(gemspec) {}
13
+
11
14
  RSpec::Core::RakeTask.new(:spec)
12
15
  Bundler::GemHelper.install_tasks
13
16
 
17
+ RDoc::Task.new do |rdoc|
18
+ rdoc.main = "README.rdoc"
19
+ rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
20
+ end
21
+
22
+
14
23
  task :default => :spec
data/bin/rake ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rake' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rake", "rake")
data/bin/rspec ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rspec' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
data/build-matrix.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "build_matrix": {
3
+ }
4
+ }
data/fittings.gemspec CHANGED
@@ -1,13 +1,7 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
1
  Gem::Specification.new do |s|
7
2
  s.name = "fittings"
8
- s.version = "0.2.0"
3
+ s.version = "0.2.4.RC1"
9
4
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
5
  s.authors = ["Edwin Cruz", "Colin Shield"]
12
6
  s.date = %q{2011-09-06}
13
7
  s.description = %q{implement custom keys independently of environment}
@@ -16,35 +10,18 @@ Gem::Specification.new do |s|
16
10
  "LICENSE.txt",
17
11
  "README.rdoc"
18
12
  ]
19
- s.files = [
20
- ".document",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "LICENSE.txt",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "lib/mc-settings.rb",
28
- "lib/setting.rb",
29
- "fittings.gemspec",
30
- "spec/fixtures/joes-colors.yml",
31
- "spec/fixtures/sample.yml",
32
- "spec/fixtures/shipping.yml",
33
- "spec/mc_settings_spec.rb",
34
- "spec/spec_helper.rb",
35
- "spec/support/settings_helper.rb"
36
- ]
37
13
  s.homepage = %q{http://github.com/stitchfix/fittings}
38
14
  s.licenses = ["MIT"]
39
- s.require_paths = ["lib"]
40
15
  s.summary = %q{Manage settings per environment}
41
- s.test_files = [
42
- "spec/mc_settings_spec.rb",
43
- "spec/spec_helper.rb",
44
- "spec/support/settings_helper.rb"
45
- ]
16
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ s.bindir = "exe"
20
+ s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
46
22
 
47
23
  s.add_development_dependency "rspec"
48
24
  s.add_development_dependency "rake"
25
+ s.add_development_dependency "rdoc"
26
+ s.add_development_dependency('rspec_junit_formatter')
49
27
  end
50
-
data/lib/fittings.rb ADDED
@@ -0,0 +1 @@
1
+ require_relative "mc-settings"
data/lib/setting.rb CHANGED
@@ -71,6 +71,11 @@ class Setting
71
71
  end
72
72
  end
73
73
 
74
+ def self.respond_to?(method_name, include_private = false)
75
+ self.instance.available_settings.has_key?(method_name.to_s.sub(/\?\z/, '')) ||
76
+ super
77
+ end
78
+
74
79
  # In [] invocation syntax, we return settings value 'as is' without
75
80
  # Hash conversions.
76
81
  #
@@ -175,7 +180,14 @@ class Setting
175
180
 
176
181
  files.flatten.each do |file|
177
182
  begin
178
- @available_settings.recursive_merge!(YAML::load(ERB.new(IO.read(file)).result) || {}) if File.exists?(file)
183
+ # Ruby versions before 3.0.3 include Psych < 3.3.2, which does not include `unsafe_load`. In those versions,
184
+ # `load` is the behavior we want (in later versions, `load` uses `safe_load`, which doesn't support aliases and
185
+ # requires allowlisting classes used in files.
186
+ if Psych::VERSION < '3.3.2'
187
+ @available_settings.recursive_merge!(YAML::load(ERB.new(IO.read(file)).result) || {}) if File.exists?(file)
188
+ else
189
+ @available_settings.recursive_merge!(YAML::unsafe_load(ERB.new(IO.read(file)).result) || {}) if File.exists?(file)
190
+ end
179
191
  rescue Exception => e
180
192
  raise FileError.new("Error parsing file #{file}, with: #{e.message}")
181
193
  end
data/owners.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "owners": [
3
+ {
4
+ "team": "eng-runtime"
5
+ }
6
+ ]
7
+ }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fittings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.4.RC1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edwin Cruz
8
8
  - Colin Shield
9
- autorequire:
10
- bindir: bin
9
+ autorequire:
10
+ bindir: exe
11
11
  cert_chain: []
12
12
  date: 2011-09-06 00:00:00.000000000 Z
13
13
  dependencies:
@@ -39,6 +39,34 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rdoc
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec_junit_formatter
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
42
70
  description: implement custom keys independently of environment
43
71
  email: eng@stitchfix.com
44
72
  executables: []
@@ -47,27 +75,31 @@ extra_rdoc_files:
47
75
  - LICENSE.txt
48
76
  - README.rdoc
49
77
  files:
50
- - ".document"
78
+ - ".circleci/config.yml"
79
+ - ".github/CODEOWNERS"
80
+ - ".github/PULL_REQUEST_TEMPLATE.md"
81
+ - ".gitignore"
82
+ - ".ruby-gemset"
83
+ - ".ruby-version"
84
+ - ".travis.yml"
85
+ - CODE_OF_CONDUCT.md
51
86
  - Gemfile
52
- - Gemfile.lock
53
87
  - LICENSE.txt
54
88
  - README.rdoc
55
89
  - Rakefile
56
- - VERSION
90
+ - bin/rake
91
+ - bin/rspec
92
+ - build-matrix.json
57
93
  - fittings.gemspec
94
+ - lib/fittings.rb
58
95
  - lib/mc-settings.rb
59
96
  - lib/setting.rb
60
- - spec/fixtures/joes-colors.yml
61
- - spec/fixtures/sample.yml
62
- - spec/fixtures/shipping.yml
63
- - spec/mc_settings_spec.rb
64
- - spec/spec_helper.rb
65
- - spec/support/settings_helper.rb
97
+ - owners.json
66
98
  homepage: http://github.com/stitchfix/fittings
67
99
  licenses:
68
100
  - MIT
69
101
  metadata: {}
70
- post_install_message:
102
+ post_install_message:
71
103
  rdoc_options: []
72
104
  require_paths:
73
105
  - lib
@@ -78,16 +110,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
110
  version: '0'
79
111
  required_rubygems_version: !ruby/object:Gem::Requirement
80
112
  requirements:
81
- - - ">="
113
+ - - ">"
82
114
  - !ruby/object:Gem::Version
83
- version: '0'
115
+ version: 1.3.1
84
116
  requirements: []
85
- rubyforge_project:
86
- rubygems_version: 2.6.13
87
- signing_key:
117
+ rubygems_version: 3.2.5
118
+ signing_key:
88
119
  specification_version: 4
89
120
  summary: Manage settings per environment
90
- test_files:
91
- - spec/mc_settings_spec.rb
92
- - spec/spec_helper.rb
93
- - spec/support/settings_helper.rb
121
+ test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/Gemfile.lock DELETED
@@ -1,34 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- fittings (0.2.0)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- diff-lcs (1.3)
10
- rake (12.1.0)
11
- rspec (3.6.0)
12
- rspec-core (~> 3.6.0)
13
- rspec-expectations (~> 3.6.0)
14
- rspec-mocks (~> 3.6.0)
15
- rspec-core (3.6.0)
16
- rspec-support (~> 3.6.0)
17
- rspec-expectations (3.6.0)
18
- diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.6.0)
20
- rspec-mocks (3.6.0)
21
- diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.6.0)
23
- rspec-support (3.6.0)
24
-
25
- PLATFORMS
26
- ruby
27
-
28
- DEPENDENCIES
29
- fittings!
30
- rake
31
- rspec
32
-
33
- BUNDLED WITH
34
- 1.15.4
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.6
@@ -1,9 +0,0 @@
1
- color:
2
- pants:
3
- favorite:
4
- :orange
5
- shorts:
6
- favorite:
7
- :white
8
- default:
9
- :stripes
@@ -1,35 +0,0 @@
1
- tax:
2
- default: 0.0
3
- california: 7.5
4
- states:
5
- default:
6
- - 'CA'
7
- - 'WA'
8
- - 'NY'
9
- ship_to:
10
- - 'CA'
11
- - 'NY'
12
- boolean_true:
13
- default: 4
14
- boolean_false:
15
- default: false
16
- negated: true
17
- color:
18
- default:
19
- :grey
20
- pants:
21
- default:
22
- :purple
23
- favorite:
24
- :red
25
- school:
26
- :blue
27
- shorts:
28
- default:
29
- :plaid
30
- favorite:
31
- :yellow
32
- school:
33
- :black
34
-
35
-
@@ -1,36 +0,0 @@
1
- shipping_config:
2
- default: <%= 'Defaulted' %>
3
- domestic:
4
- service: MyService
5
- countries:
6
- - "US"
7
- non_shippable_regions:
8
- - "US-AS"
9
- - "US-GU"
10
- - "US-MP"
11
- - "US-PR"
12
- - "US-UM"
13
- - "US-VI"
14
- - "US-AF"
15
- - "US-AA"
16
- - "US-AC"
17
- - "US-AE"
18
- - "US-AM"
19
- - "US-AP"
20
- - "US-FM"
21
- - "US-PW"
22
- - "US-MH"
23
- international:
24
- service: Foo
25
- countries:
26
- - "GU"
27
- - "VI"
28
- - "AS"
29
- - "MP"
30
- - "UM"
31
- - "FR"
32
- - "GR"
33
- - "RU"
34
- shipping_carrier: Bar
35
- number: <%= 5%>
36
- stringified: <%= nil || "stringified"%>
@@ -1,160 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- describe Setting do
3
- subject { Setting }
4
-
5
- context "Test with stubs" do
6
- before :each do
7
- stub_setting_files
8
- subject.reload(
9
- :path => "config/settings",
10
- :files => ["default.yml", "environments/test.yml"],
11
- :local => true)
12
- end
13
-
14
- it 'should return test specific values' do
15
- expect(subject.available_settings['one']).to eq("test")
16
- expect(subject.one).to eq("test")
17
- expect(subject['one']).to eq("test")
18
- end
19
-
20
- it "should handle custom values overriding everything else" do
21
- expect(subject.seven).to eq("seven from custom")
22
- end
23
-
24
- it "handles multiple values" do
25
- expect(subject[:six]).to eq({"default"=>"default value", "extra"=>"recursively overriden", "deep_level"=>{"value"=>"even deeper level"}})
26
- expect(subject.available_settings['six']['default']).to eq("default value")
27
- expect(subject.seven).to eq("seven from custom")
28
- end
29
-
30
- it "handles default key" do
31
- expect(subject.default_setting).to eq(1)
32
- expect(subject['seven']['default']).to eq("seven from custom")
33
- end
34
-
35
- it "should handle empty strings" do
36
- expect(subject.empty).to eq("")
37
- end
38
-
39
- it "should responds to ? mark" do
40
- expect(subject.autologin?).to eq(true)
41
- end
42
-
43
- it "should returns false correctly" do
44
- expect(subject.flag_false).to be(false)
45
- end
46
-
47
- it "should merge keys recursivelly" do
48
- expect(subject.six(:extra)).to eq("recursively overriden")
49
- expect(subject.six(:deep_level, :value)).to eq("even deeper level")
50
- end
51
-
52
- it "should create keys if it does not exist" do
53
- expect(subject.test_specific).to eq("exist")
54
- end
55
-
56
- context "working with arrays" do
57
- it "should replace the whole array instead of appending new values" do
58
- expect(subject.nested_array).to eq(['first', 'four', 'five'])
59
- end
60
- end
61
- end
62
-
63
- context "When running with threads" do
64
- it "should keep its values" do
65
- 3.times do |time|
66
- Thread.new {
67
- subject.available_settings.shoud_not be_empty
68
- }
69
- end
70
- end
71
- end
72
-
73
- context "Test from file" do
74
- before :each do
75
- subject.reload(
76
- :path => File.join(File.dirname(__FILE__)) + '/fixtures',
77
- :files => ['sample.yml']
78
- )
79
- end
80
-
81
- it 'should support [] syntax' do
82
- expect(subject['tax']['default']).to eq(0.0)
83
- expect(subject['tax']).to eq({ 'default' => 0.0, 'california' => 7.5 })
84
- end
85
-
86
- it 'should support method invocation syntax' do
87
- expect(subject.tax).to eq(0.0)
88
-
89
- expect(subject.tax(:default)).to eq(subject.tax)
90
- expect(subject.tax('default')).to eq(subject.tax)
91
- expect(subject.tax(:california)).to eq(7.5)
92
-
93
- expect(subject.states).to eq(['CA', 'WA', 'NY'])
94
- expect(subject.states(:default)).to eq(subject.states)
95
- expect(subject.states(:ship_to)).to eq(['CA', 'NY'])
96
- end
97
-
98
- it 'should correctly process Boolean values' do
99
- expect(subject.boolean_true?).to be(true)
100
- expect(subject.boolean_true).to eq(4)
101
- expect(subject.boolean_false?).to be(false)
102
- expect(subject.boolean_false?(:default)).to be(false)
103
- expect(subject.boolean_false?(:negated)).to be(true)
104
- end
105
- end
106
-
107
- context "Test recursive overrides and nested hashes" do
108
- before :each do
109
- subject.reload(
110
- :path => File.join(File.dirname(__FILE__)) + '/fixtures',
111
- :files => ['sample.yml', 'joes-colors.yml']
112
- )
113
- end
114
-
115
- it 'should override colors with Joes and support nested hashes' do
116
- expect(subject.color).to eq(:grey) # default
117
- expect(subject.color(:pants)).to eq(:purple) # default
118
-
119
- expect(subject.color(:pants, :school)).to eq(:blue) # in sample
120
- expect(subject.color(:pants, :favorite)).to eq(:orange) # joes override
121
-
122
- expect(subject.color(:shorts, :school)).to eq(:black) # in sample
123
- expect(subject.color(:shorts, :favorite)).to eq(:white) # joe's override
124
-
125
- expect(subject.color(:shorts)).to eq(:stripes) # joe's override of default
126
- end
127
-
128
- end
129
- context "Complex nested configs" do
130
- before :each do
131
- subject.reload(
132
- :path => File.join(File.dirname(__FILE__)) + '/fixtures',
133
- :files => ['shipping.yml']
134
- )
135
- end
136
- it "should build correct tree with arrays and default values " do
137
- expect(subject.shipping_config).to eq("Defaulted")
138
- expect(subject.shipping_config(:domestic, :non_shippable_regions).first).to eq("US-AS")
139
- expect(subject.shipping_config(:international, :service)).to eq('Foo')
140
- expect(subject.shipping_config(:international, :countries).size).to be > 0
141
- expect(subject.shipping_config(:international, :shipping_carrier)).to eq('Bar')
142
- #backward compatibility:
143
- expect(subject.shipping_config(:domestic)['non_shippable_regions'].size).to be > 0
144
- end
145
- end
146
-
147
- context "Ruby code inside yml file" do
148
- before :each do
149
- subject.reload(
150
- :path => File.join(File.dirname(__FILE__)) + '/fixtures',
151
- :files => ['shipping.yml']
152
- )
153
- end
154
- it "should interpret ruby code and put correct values" do
155
- expect(subject.shipping_config).to eq("Defaulted")
156
- subject.number == 5
157
- subject.stringified == "stringified"
158
- end
159
- end
160
- end
data/spec/spec_helper.rb DELETED
@@ -1,12 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'rspec'
4
- require 'mc-settings'
5
-
6
- # Requires supporting files with custom matchers and macros, etc,
7
- # in ./support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
-
10
- RSpec.configure do |config|
11
-
12
- end
@@ -1,59 +0,0 @@
1
- def stub_setting_files
2
- defaults = <<-CONTENT
3
- one: default
4
- two:
5
- three: 3
6
- four: "4"
7
- five: "default string"
8
- default_setting: 1
9
- six:
10
- default: "default value"
11
- extra: "extra"
12
- deep_level:
13
- value: "even deeper level"
14
- seven:
15
- default: "seven"
16
- empty:
17
- default:
18
- autologin:
19
- format: int
20
- default: 7
21
- flag_false:
22
- default: false
23
- nested_array:
24
- - first
25
- - second
26
- - third
27
- CONTENT
28
- test = <<-CONTENT
29
- one: test
30
- two:
31
- three: 5
32
- four: "6"
33
- five: "test string"
34
- six:
35
- extra: "recursively overriden"
36
- test_specific: "exist"
37
- nested_array:
38
- - first
39
- - four
40
- - five
41
- CONTENT
42
-
43
- empty = <<-CONTENT
44
- CONTENT
45
-
46
- custom = <<-CONTENT
47
- seven:
48
- default: "seven from custom"
49
- CONTENT
50
-
51
- allow(File).to receive(:exists?).and_return(true)
52
- allow(File).to receive(:exists?).with("config/settings/environments/development.yml").and_return(false)
53
- allow(IO).to receive(:read).with("config/settings/default.yml").and_return(defaults)
54
- allow(IO).to receive(:read).with("config/settings/environments/test.yml").and_return(test)
55
- allow(IO).to receive(:read).with("config/settings/local/custom.yml").and_return(custom)
56
- allow(IO).to receive(:read).with("config/settings/local/empty.yml").and_return(empty)
57
-
58
- allow(Dir).to receive(:glob).and_return(["config/settings/local/empty.yml", "config/settings/local/custom.yml"])
59
- end