Sha256: 216ea83b7196f9550cfde31d5eb353946f848b41850fc100df14da66cee8ebea

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

require "spec_helper"

describe "Figaro Rake tasks", :rake => true do
  describe "figaro:heroku" do
    before do
      @original_rails_env = ENV["RAILS_ENV"]
      ENV["RAILS_ENV"] = "development"
    end

    after do
      ENV["RAILS_ENV"] = @original_rails_env
      Rails.send(:remove_instance_variable, :@_env)
    end

    it "configures Heroku" do
      Figaro.stub(:env => {"HELLO" => "world", "FOO" => "bar"})
      Kernel.stub(:system).with("heroku config:get RAILS_ENV").and_return("development")
      Kernel.should_receive(:system).once.with("heroku config:add FOO=bar HELLO=world")
      task.invoke
    end

    it "configures a specific Heroku app" do
      Figaro.stub(:env => {"HELLO" => "world", "FOO" => "bar"})
      Kernel.stub(:system).with("heroku config:get RAILS_ENV --app my-app").and_return("development")
      Kernel.should_receive(:system).once.with("heroku config:add FOO=bar HELLO=world --app my-app")
      task.invoke("my-app")
    end

    it "respects the Heroku's remote Rails environment" do
      Figaro.stub(:raw => {"development" => {"HELLO" => "developers"}, "production" => {"HELLO" => "world"}})
      Kernel.stub(:system).with("heroku config:get RAILS_ENV").and_return("production")
      Kernel.should_receive(:system).once.with("heroku config:add HELLO=world")
      task.invoke
    end

    it "defaults to the local Rails environment if not set remotely" do
      Figaro.stub(:raw => {"development" => {"HELLO" => "developers"}, "production" => {"HELLO" => "world"}})
      Kernel.stub(:system).with("heroku config:get RAILS_ENV").and_return("\n")
      Kernel.should_receive(:system).once.with("heroku config:add HELLO=developers")
      task.invoke
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
figaro-0.5.0 spec/figaro/tasks_spec.rb