figaro 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,3 +9,6 @@ rvm:
9
9
  - 1.9.2
10
10
  - 1.9.3
11
11
  - ruby-head
12
+ before_script:
13
+ - unset RAILS_ENV
14
+ - unset RACK_ENV
data/README.md CHANGED
@@ -44,7 +44,7 @@ Pusher.key = ENV["PUSHER_KEY"]
44
44
  Pusher.secret = ENV["PUSHER_SECRET"]
45
45
  ```
46
46
 
47
- If your app requires Rails-environment-specific configuration, you can also namespace your configuration under a key for `Rails.environment`. For instance:
47
+ If your app requires Rails-environment-specific configuration, you can also namespace your configuration under a key for `Rails.env`.
48
48
 
49
49
  ```yaml
50
50
  HELLO: world
data/Rakefile CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env rake
2
2
 
3
3
  require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
4
5
  require "cucumber/rake/task"
5
6
  require "appraisal"
6
7
 
8
+ RSpec::Core::RakeTask.new(:spec)
7
9
  Cucumber::Rake::Task.new(:cucumber)
8
10
 
9
- task :default => :cucumber
11
+ task :default => [:spec, :cucumber]
@@ -45,17 +45,7 @@ Feature: Rails
45
45
  When I run "rake hello"
46
46
  Then the output should be "Hello, world!"
47
47
 
48
- Scenario: Has application.yml with a RAILS_ENV
49
- Given I create "config/application.yml" with:
50
- """
51
- HELLO: world
52
- development:
53
- HELLO: developers
54
- """
55
- When I run "rake hello RAILS_ENV=development"
56
- Then the output should be "Hello, developers!"
57
-
58
- Scenario: Has application.yml without a RAILS_ENV, but has env variables set
48
+ Scenario: Has application.yml with RAILS_ENV defaulting to "development"
59
49
  Given I create "config/application.yml" with:
60
50
  """
61
51
  HELLO: world
@@ -63,9 +53,9 @@ Feature: Rails
63
53
  HELLO: developers
64
54
  """
65
55
  When I run "rake hello"
66
- Then the output should be "Hello, world!"
56
+ Then the output should be "Hello, developers!"
67
57
 
68
- Scenario: Has application.yml with a RAILS_ENV, with multiple envs configured.
58
+ Scenario: Has application.yml with RAILS_ENV set
69
59
  Given I create "config/application.yml" with:
70
60
  """
71
61
  HELLO: world
@@ -74,6 +64,8 @@ Feature: Rails
74
64
  production:
75
65
  HELLO: users
76
66
  """
67
+ When I run "rake hello RAILS_ENV=test"
68
+ Then the output should be "Hello, world!"
77
69
  When I run "rake hello RAILS_ENV=development"
78
70
  Then the output should be "Hello, developers!"
79
71
  When I run "rake hello RAILS_ENV=production"
@@ -90,28 +82,6 @@ Feature: Rails
90
82
  Then "config/application.yml" should exist
91
83
  But ".gitignore" should not exist
92
84
 
93
- Scenario: Rake task attempts to configure Heroku
94
- Given the "heroku" command is:
95
- """
96
- #!/usr/bin/env ruby
97
- puts "Attempted: heroku #{ARGV.join(" ")}"
98
- """
99
- And I create "config/application.yml" with:
100
- """
101
- FOO: bar
102
- """
103
- When I run "rake figaro:heroku"
104
- Then the output should be "Attempted: heroku config:add FOO=bar"
105
-
106
- Scenario: Rake task attempts to configure a specific Heroku app
107
- Given the "heroku" command is:
108
- """
109
- #!/usr/bin/env ruby
110
- puts "Attempted: heroku #{ARGV.join(" ")}"
111
- """
112
- And I create "config/application.yml" with:
113
- """
114
- FOO: bar
115
- """
116
- When I run "rake figaro:heroku[my-app]"
117
- Then the output should be "Attempted: heroku config:add FOO=bar --app my-app"
85
+ Scenario: Includes Heroku Rake task
86
+ When I run "rake --tasks figaro:heroku"
87
+ Then the output should be "rake figaro:heroku[app] # Configure Heroku according to application.yml"
@@ -1,7 +1,3 @@
1
- Given /^the "([^"]+)" command is:$/ do |command, content|
2
- write_command(command, content)
3
- end
4
-
5
1
  When /^I create "([^"]+)" with:$/ do |path, content|
6
2
  write_file(path, content)
7
3
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "figaro"
5
- gem.version = "0.4.0"
5
+ gem.version = "0.4.1"
6
6
 
7
7
  gem.authors = ["Steve Richert"]
8
8
  gem.email = ["steve.richert@gmail.com"]
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.add_development_dependency "aruba", "~> 0.4"
17
17
  gem.add_development_dependency "cucumber", "~> 1.0"
18
18
  gem.add_development_dependency "rake", ">= 0.8.7"
19
+ gem.add_development_dependency "rspec", "~> 2.0"
19
20
 
20
21
  gem.files = `git ls-files`.split($\)
21
22
  gem.test_files = gem.files.grep(/^features\//)
@@ -20,7 +20,7 @@ module Figaro
20
20
  end
21
21
 
22
22
  def environment
23
- ENV["RAILS_ENV"] || ENV["RACK_ENV"]
23
+ Rails.env
24
24
  end
25
25
 
26
26
  private
@@ -8,7 +8,7 @@ module Figaro
8
8
  end
9
9
 
10
10
  rake_tasks do
11
- load "figaro/tasks.rb"
11
+ load "figaro/tasks.rake"
12
12
  end
13
13
  end
14
14
  end
@@ -1,9 +1,9 @@
1
1
  namespace :figaro do
2
2
  desc "Configure Heroku according to application.yml"
3
3
  task :heroku, [:app] => :environment do |_, args|
4
- vars = Figaro.env.map{|k,v| "#{k}=#{v}" }.join(" ")
4
+ vars = Figaro.env.map{|k,v| "#{k}=#{v}" }.sort.join(" ")
5
5
  command = "heroku config:add #{vars}"
6
6
  command << " --app #{args[:app]}" if args[:app]
7
- system(command)
7
+ Kernel.system(command)
8
8
  end
9
9
  end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe "Figaro Rake tasks", :rake => true do
4
+ describe "figaro:heroku" do
5
+ it "configures Heroku" do
6
+ Figaro.stub(:env => {"HELLO" => "world", "FOO" => "bar"})
7
+ Kernel.should_receive(:system).once.with("heroku config:add FOO=bar HELLO=world")
8
+ task.invoke
9
+ end
10
+
11
+ it "configures a specific Heroku app" do
12
+ Figaro.stub(:env => {"HELLO" => "world", "FOO" => "bar"})
13
+ Kernel.should_receive(:system).once.with("heroku config:add FOO=bar HELLO=world --app my-app")
14
+ task.invoke("my-app")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ require "figaro"
2
+ require "pathname"
3
+
4
+ ROOT = Pathname.new(File.expand_path("../..", __FILE__))
5
+
6
+ Dir[ROOT.join("spec/support/**/*.rb")].each{|f| require f }
@@ -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/tasks", [ROOT.to_s], [])
9
+ Rake::Task.define_task(:environment)
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: figaro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-20 00:00:00.000000000 Z
12
+ date: 2012-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -91,6 +91,22 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: 0.8.7
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '2.0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '2.0'
94
110
  description: Simple, Heroku-friendly Rails app configuration using ENV and a single
95
111
  YAML file
96
112
  email:
@@ -111,7 +127,6 @@ files:
111
127
  - features/step_definitions/common_steps.rb
112
128
  - features/step_definitions/rails_steps.rb
113
129
  - features/support/aruba.rb
114
- - features/support/commands.rb
115
130
  - features/support/env.rb
116
131
  - figaro.gemspec
117
132
  - gemfiles/rails30.gemfile
@@ -119,9 +134,12 @@ files:
119
134
  - gemfiles/rails32.gemfile
120
135
  - lib/figaro.rb
121
136
  - lib/figaro/railtie.rb
122
- - lib/figaro/tasks.rb
137
+ - lib/figaro/tasks.rake
123
138
  - lib/generators/figaro/install/install_generator.rb
124
139
  - lib/generators/figaro/install/templates/application.yml
140
+ - spec/figaro/tasks_spec.rb
141
+ - spec/spec_helper.rb
142
+ - spec/support/rake.rb
125
143
  homepage: https://github.com/laserlemon/figaro
126
144
  licenses: []
127
145
  post_install_message:
@@ -152,5 +170,4 @@ test_files:
152
170
  - features/step_definitions/common_steps.rb
153
171
  - features/step_definitions/rails_steps.rb
154
172
  - features/support/aruba.rb
155
- - features/support/commands.rb
156
173
  - features/support/env.rb
@@ -1,30 +0,0 @@
1
- module CommandHelpers
2
- PATH = ROOT.join("tmp/commands")
3
-
4
- def write_command(command, content)
5
- path = PATH.join(command)
6
- File.open(path, "w"){|f| f << content }
7
- FileUtils.chmod(0755, path)
8
- end
9
-
10
- def patch_path
11
- FileUtils.mkdir_p(PATH)
12
- @original_paths = ENV["PATH"] ? ENV["PATH"].split(File::PATH_SEPARATOR) : []
13
- ENV["PATH"] = ([PATH] + @original_paths).join(File::PATH_SEPARATOR)
14
- end
15
-
16
- def restore_path
17
- ENV["PATH"] = @original_paths.join(File::PATH_SEPARATOR)
18
- FileUtils.rm_r(PATH)
19
- end
20
- end
21
-
22
- World(CommandHelpers)
23
-
24
- Before do
25
- patch_path
26
- end
27
-
28
- After do
29
- restore_path
30
- end