require 'spec_helper' describe Jumpup::Heroku::Env do before do Jumpup::Heroku.configuration = nil end describe "with app" do before do Jumpup::Heroku.configure do |config| config.app = 'myapp' end end it "have correct env info" do expect(Jumpup::Heroku::Env.all).to eq({ app: 'myapp', run_database_tasks: true, host: 'heroku.com' }) end end describe "with staging_app and production_app" do before do Jumpup::Heroku.configure do |config| config.production_app = 'myapp-production' config.staging_app = 'myapp-staging' end end it "have correct env info" do result = { production_app: 'myapp-production', staging_app: 'myapp-staging', run_database_tasks: true, host: 'heroku.com' } expect(Jumpup::Heroku::Env.all).to eq(result) end end describe "with run_database_tasks" do before do Jumpup::Heroku.configure do |config| config.app = 'myapp' config.run_database_tasks = false end end it "have correct env info" do result = { app: 'myapp', run_database_tasks: false, host: 'heroku.com' } expect(Jumpup::Heroku::Env.all).to eq(result) end end describe "with a invalid config env" do before do Jumpup::Heroku.configure do |config| config.app = 'myapp' config.production_app = 'myapp-production' config.staging_app = 'myapp-staging' config.run_database_tasks = 'a' end end it 'raise error' do expect do Jumpup::Heroku::Env.all end.to raise_error(Jumpup::Heroku::ConfigurationError, %r{/config/initializers/jumpup-heroku.rb}) end end end