require 'spec_helper' describe Jumpup::Heroku::Configuration do before do Jumpup::Heroku.configuration = nil end describe ".configure" do describe "without configuration" do before do Jumpup::Heroku.configure do |config| end end subject do Jumpup::Heroku.configuration end its(:app) { should be_nil } its(:staging_app) { should be_nil } its(:production_app) { should be_nil } its(:run_database_tasks) { should be_true } end describe "with configurations" 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 = false end end subject do Jumpup::Heroku.configuration end its(:app) { should eq('myapp') } its(:staging_app) { should eq('myapp-staging')} its(:production_app) { should eq('myapp-production') } its(:run_database_tasks) { should be_false } end end describe "#valid?" do describe "with app" do before do Jumpup::Heroku.configure do |config| config.app = 'myapp' end end it 'be valid' do expect(Jumpup::Heroku.configuration).to be_valid 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 'be valid' do expect(Jumpup::Heroku.configuration).to be_valid end end describe "with app, staging_app and production_app" do before do Jumpup::Heroku.configure do |config| config.app = 'myapp' config.production_app = 'myapp-production' config.staging_app = 'myapp-staging' end end it 'not be valid' do expect(Jumpup::Heroku.configuration).to_not be_valid end end describe "with staging_app" do before do Jumpup::Heroku.configure do |config| config.staging_app = 'myapp-staging' end end it 'not be valid' do expect(Jumpup::Heroku.configuration).to_not be_valid end end describe "with production_app" do before do Jumpup::Heroku.configure do |config| config.production_app = 'myapp-production' end end it 'not be valid' do expect(Jumpup::Heroku.configuration).to_not be_valid end end describe "with app and production_app" do before do Jumpup::Heroku.configure do |config| config.app = 'myapp' config.production_app = 'myapp-production' end end it 'not be valid' do expect(Jumpup::Heroku.configuration).to_not be_valid end end describe "with app and staging_app" do before do Jumpup::Heroku.configure do |config| config.app = 'myapp' config.staging_app = 'myapp-staging' end end it 'not be valid' do expect(Jumpup::Heroku.configuration).to_not be_valid end end describe "with true run_database_tasks" do before do Jumpup::Heroku.configure do |config| config.app = 'myapp' config.run_database_tasks = true end end it 'be valid' do expect(Jumpup::Heroku.configuration).to be_valid end end describe "with false run_database_tasks" do before do Jumpup::Heroku.configure do |config| config.app = 'myapp' config.run_database_tasks = false end end it 'be valid' do expect(Jumpup::Heroku.configuration).to be_valid end end describe "with invalid run_database_tasks" do before do Jumpup::Heroku.configure do |config| config.app = 'myapp' config.run_database_tasks = 'a' end end it 'be valid' do expect(Jumpup::Heroku.configuration).to_not be_valid end end describe "without configuration" do before do Jumpup::Heroku.configure do |config| end end it 'not be valid' do expect(Jumpup::Heroku.configuration).to_not be_valid end end describe "with configuration nil" do before do Jumpup::Heroku.configuration = nil end it 'not be valid' do pending "The bug is raised when have no config/initialier/heroku-deploy.rb file" expect(Jumpup::Heroku.configuration).to_not be_valid end end end end