mguymon-figaro 0.7.0.1

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.
@@ -0,0 +1,43 @@
1
+ require "spec_helper"
2
+
3
+ module Figaro
4
+ module Rails
5
+ describe Application do
6
+ describe "#default_path" do
7
+ let!(:application) { Application.new }
8
+
9
+ it "defaults to config/application.yml in Rails.root" do
10
+ ::Rails.stub(root: Pathname.new("/path/to/app"))
11
+
12
+ expect {
13
+ ::Rails.stub(root: Pathname.new("/app"))
14
+ }.to change {
15
+ application.send(:default_path).to_s
16
+ }.from("/path/to/app/config/application.yml").to("/app/config/application.yml")
17
+ end
18
+
19
+ it "raises an error when Rails.root isn't set yet" do
20
+ ::Rails.stub(root: nil)
21
+
22
+ expect {
23
+ application.send(:default_path)
24
+ }.to raise_error(RailsNotInitialized)
25
+ end
26
+ end
27
+
28
+ describe "#default_environment" do
29
+ let!(:application) { Application.new }
30
+
31
+ it "defaults to Rails.env" do
32
+ ::Rails.stub(env: "development")
33
+
34
+ expect {
35
+ ::Rails.stub(env: "test")
36
+ }.to change {
37
+ application.send(:default_environment).to_s
38
+ }.from("development").to("test")
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,71 @@
1
+ require "spec_helper"
2
+
3
+ module Figaro::Tasks
4
+ describe Heroku do
5
+ subject(:heroku) { Heroku.new }
6
+
7
+ describe "#invoke" do
8
+ it "configures Heroku" do
9
+ heroku.stub(vars: "FOO=bar")
10
+
11
+ heroku.should_receive(:heroku).once.with("config:set FOO=bar")
12
+
13
+ heroku.invoke
14
+ end
15
+ end
16
+
17
+ describe "#vars" do
18
+ it "returns Figaro's vars for Heroku's environment" do
19
+ heroku.stub(environment: "staging")
20
+ Figaro.stub(:vars).with("staging").and_return("FOO=bar")
21
+
22
+ expect(heroku.vars).to eq("FOO=bar")
23
+ end
24
+ end
25
+
26
+ describe "#environment" do
27
+ it "returns Heroku's environment" do
28
+ heroku.stub(:heroku).with("run 'echo $RAILS_ENV'").and_return(<<-OUT)
29
+ Running `echo $RAILS_ENV` attached to terminal... up, run.1234
30
+ staging
31
+ OUT
32
+
33
+ expect(heroku.environment).to eq("staging")
34
+ end
35
+ end
36
+
37
+ describe "#heroku" do
38
+ it "runs a command on Heroku" do
39
+ heroku.should_receive(:`).once.with("heroku info")
40
+
41
+ heroku.heroku("info")
42
+ end
43
+
44
+ it "runs a command on a specific Heroku app" do
45
+ heroku = Heroku.new("my-app")
46
+
47
+ heroku.should_receive(:`).once.with("heroku info --app my-app")
48
+
49
+ heroku.heroku("info")
50
+ end
51
+ end
52
+ end
53
+
54
+ describe "figaro:heroku", rake: true do
55
+ subject(:heroku) { double(:heroku) }
56
+
57
+ it "configures Heroku" do
58
+ Figaro::Tasks::Heroku.stub(:new).with(nil).and_return(heroku)
59
+ heroku.should_receive(:invoke).once
60
+
61
+ task.invoke
62
+ end
63
+
64
+ it "configures a specific Heroku app" do
65
+ Figaro::Tasks::Heroku.stub(:new).with("my-app").and_return(heroku)
66
+ heroku.should_receive(:invoke).once
67
+
68
+ task.invoke("my-app")
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,62 @@
1
+ require "spec_helper"
2
+
3
+ describe Figaro do
4
+ describe ".env" do
5
+ it "falls through to Figaro::ENV" do
6
+ expect(Figaro.env).to eq(Figaro::ENV)
7
+ end
8
+ end
9
+
10
+ describe ".backend" do
11
+ let(:backend) { double(:backend) }
12
+
13
+ it "defaults to the Rails application backend" do
14
+ expect(Figaro.backend).to eq(Figaro::Rails::Application)
15
+ end
16
+
17
+ it "is configurable" do
18
+ expect {
19
+ Figaro.backend = backend
20
+ }.to change {
21
+ Figaro.backend
22
+ }.from(Figaro::Rails::Application).to(backend)
23
+ end
24
+ end
25
+
26
+ describe ".application" do
27
+ let(:backend) { double(:backend) }
28
+ let(:application) { double(:application) }
29
+ let(:custom_application) { double(:custom_application) }
30
+
31
+ before do
32
+ Figaro.stub(:backend) { backend }
33
+ backend.stub(:new).with(no_args) { application }
34
+ end
35
+
36
+ it "defaults to a new backend application" do
37
+ expect(Figaro.application).to eq(application)
38
+ end
39
+
40
+ it "is configurable" do
41
+ expect {
42
+ Figaro.application = custom_application
43
+ }.to change {
44
+ Figaro.application
45
+ }.from(application).to(custom_application)
46
+ end
47
+ end
48
+
49
+ describe ".load" do
50
+ let(:application) { double(:application) }
51
+
52
+ before do
53
+ Figaro.stub(:application) { application }
54
+ end
55
+
56
+ it "loads the application configuration" do
57
+ expect(application).to receive(:load).once.with(no_args)
58
+
59
+ Figaro.load
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,67 @@
1
+ require "spec_helper"
2
+
3
+ describe Figaro::Rails do
4
+ before do
5
+ run_simple(<<-CMD)
6
+ bundle exec rails new example \
7
+ --skip-gemfile \
8
+ --skip-bundle \
9
+ --skip-keeps \
10
+ --skip-sprockets \
11
+ --skip-javascript \
12
+ --skip-test-unit \
13
+ --no-rc \
14
+ --quiet
15
+ CMD
16
+ cd("example")
17
+ write_file("Gemfile", <<-EOF)
18
+ gem "rails"
19
+ gem "sqlite3"
20
+ gem "figaro", path: "#{ROOT}"
21
+ EOF
22
+ run_simple("bundle install")
23
+ end
24
+
25
+ describe "initialization" do
26
+ it "loads application.yml" do
27
+ write_file("config/application.yml", "HELLO: world")
28
+ run_simple("bundle exec rails runner 'puts Figaro.env.hello'")
29
+
30
+ assert_partial_output("world", all_stdout)
31
+ end
32
+
33
+ it "happens before database initialization" do
34
+ write_file("config/database.yml", <<-EOF)
35
+ development:
36
+ adapter: sqlite3
37
+ database: db/<%= ENV["FOO"] %>.sqlite3
38
+ EOF
39
+ write_file("config/application.yml", "FOO: bar")
40
+ run_simple("bundle exec rake db:migrate")
41
+
42
+ check_file_presence(["db/bar.sqlite3"], true)
43
+ end
44
+ end
45
+
46
+ describe "rails generate figaro:install" do
47
+ it "generates application.yml" do
48
+ run_simple("bundle exec rails generate figaro:install")
49
+
50
+ check_file_presence(["config/application.yml"], true)
51
+ end
52
+
53
+ it "ignores application.yml" do
54
+ run_simple("bundle exec rails generate figaro:install")
55
+
56
+ check_file_content(".gitignore", %r(^/config/application\.yml$), true)
57
+ end
58
+ end
59
+
60
+ describe "rake figaro:heroku" do
61
+ it "is included" do
62
+ run_simple("bundle exec rake --tasks figaro:heroku")
63
+
64
+ assert_partial_output("rake figaro:heroku[app] # Configure Heroku according to application.yml", all_stdout)
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,14 @@
1
+ if ENV["COVERAGE"]
2
+ require "coveralls"
3
+ Coveralls.wear!
4
+ end
5
+
6
+ require "figaro"
7
+
8
+ require "bundler"
9
+ Bundler.require(:test)
10
+
11
+ require "pathname"
12
+ ROOT = Pathname.new(File.expand_path("../..", __FILE__))
13
+
14
+ Dir[ROOT.join("spec/support/**/*.rb")].each { |f| require f }
@@ -0,0 +1,10 @@
1
+ require "aruba/api"
2
+
3
+ RSpec.configure do |config|
4
+ config.include(Aruba::Api)
5
+
6
+ config.before do
7
+ @aruba_timeout_seconds = 60
8
+ FileUtils.rm_rf(current_dir)
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ require "rake"
2
+
3
+ shared_context "rake", rake: true do
4
+ let(:rake) { Rake.application = Rake::Application.new }
5
+ let(:task) { rake[self.class.description] }
6
+
7
+ before do
8
+ rake.rake_require("lib/figaro/rails/tasks", [ROOT.to_s], [])
9
+ Rake::Task.define_task(:environment)
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ RSpec.configure do |config|
2
+ config.before do
3
+ Figaro.backend = nil
4
+ Figaro.application = nil
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mguymon-figaro
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Steve Richert
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-12-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '3'
38
+ - - <
39
+ - !ruby/object:Gem::Version
40
+ version: '5'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '3'
49
+ - - <
50
+ - !ruby/object:Gem::Version
51
+ version: '5'
52
+ description: Simple, Heroku-friendly Rails app configuration using ENV and a single
53
+ YAML file
54
+ email: steve.richert@gmail.com
55
+ executables: []
56
+ extensions: []
57
+ extra_rdoc_files: []
58
+ files:
59
+ - .gitignore
60
+ - .travis.yml
61
+ - Gemfile
62
+ - LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - figaro.gemspec
66
+ - gemfiles/rails30.gemfile
67
+ - gemfiles/rails31.gemfile
68
+ - gemfiles/rails32.gemfile
69
+ - gemfiles/rails40.gemfile
70
+ - lib/figaro.rb
71
+ - lib/figaro/application.rb
72
+ - lib/figaro/env.rb
73
+ - lib/figaro/error.rb
74
+ - lib/figaro/rails.rb
75
+ - lib/figaro/rails/application.rb
76
+ - lib/figaro/rails/railtie.rb
77
+ - lib/figaro/rails/tasks.rake
78
+ - lib/figaro/tasks.rb
79
+ - lib/generators/figaro/install/install_generator.rb
80
+ - lib/generators/figaro/install/templates/application.yml
81
+ - spec/figaro/application_spec.rb
82
+ - spec/figaro/env_spec.rb
83
+ - spec/figaro/rails/application_spec.rb
84
+ - spec/figaro/tasks_spec.rb
85
+ - spec/figaro_spec.rb
86
+ - spec/rails_spec.rb
87
+ - spec/spec_helper.rb
88
+ - spec/support/aruba.rb
89
+ - spec/support/rake.rb
90
+ - spec/support/reset.rb
91
+ homepage: https://github.com/laserlemon/figaro
92
+ licenses:
93
+ - MIT
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 1.8.23
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: Simple Rails app configuration
116
+ test_files:
117
+ - spec/figaro/application_spec.rb
118
+ - spec/figaro/env_spec.rb
119
+ - spec/figaro/rails/application_spec.rb
120
+ - spec/figaro/tasks_spec.rb
121
+ - spec/figaro_spec.rb
122
+ - spec/rails_spec.rb
123
+ - spec/spec_helper.rb
124
+ - spec/support/aruba.rb
125
+ - spec/support/rake.rb
126
+ - spec/support/reset.rb
127
+ has_rdoc: