<commit_before>require 'spec_helper'

describe 'Heroku' do

  before(:each) do
    Locomotive.config.heroku = {}
    Locomotive::Heroku.connection = nil
    Locomotive::Heroku.app_name = nil
  end

  describe '#connection' do

    it 'raises an exception if no API key has been provided' do
      lambda do
        Locomotive::Heroku.connection
      end.should raise_error(RuntimeError, 'The Heroku API key is mandatory')
    end

    it 'accepts the API key from the locomotive config file' do
      Locomotive.config.heroku = { :api_key => '12345' }
      lambda do
        Locomotive::Heroku.connection
      end.should_not raise_error
    end

    it 'accepts the API key from the ENV variables' do
      ENV['HEROKU_API_KEY'] = '12345'
      lambda do
        Locomotive::Heroku.connection
      end.should_not raise_error
      ENV.delete('HEROKU_API_KEY')
    end

  end

  describe '#application name' do

    it 'raises an exception of no app name has been provided' do
      lambda do
        Locomotive::Heroku.app_name
      end.should raise_error(RuntimeError, 'The Heroku application name is mandatory')
    end

    it 'accepts the name from the locomotive config file' do
      Locomotive.config.heroku = { :app_name => 'locomotive' }
      lambda do
        Locomotive::Heroku.app_name.should == 'locomotive'
      end.should_not raise_error
    end

    it 'accepts the name from the ENV variables' do
      ENV['APP_NAME'] = 'locomotive_new'
      lambda do
        Locomotive::Heroku.app_name.should == 'locomotive_new'
      end.should_not raise_error
      ENV.delete('APP_NAME')
    end

  end

end

# require 'spec_helper'
#
# describe 'Heroku support' do
#
#   before(:each) do
#     ::Heroku::Client.any_instance.stubs(:post).returns(true)
#     ::Heroku::Client.any_instance.stubs(:delete).returns(true)
#   end
#
#   context '#loaded' do
#
#     it 'has method to enable heroku' do
#       Locomotive.respond_to?(:enable_heroku).should be_true
#     end
#
#     it 'tells heroku is disabled' do
#       Locomotive.heroku?.should be_false
#     end
#
#     it 'does not add instance methods to Site' do
#       Site.should_not include_instance_method :add_heroku_domains
#       Site.should_not include_instance_method :remove_heroku_domains
#
#       Site.should_not include_class_method :create_first_one_with_heroku
#     end<commit_msg>remove false positive tests + test the application name<commit_after>require 'spec_helper'

describe 'Heroku' do

  before(:each) do
    Locomotive.config.heroku = {}
    Locomotive::Heroku.connection = nil
    Locomotive::Heroku.app_name = nil
    Locomotive::Heroku.domains = nil
  end

  describe '#connection' do

    it 'raises an exception if no API key has been provided' do
      lambda do
        Locomotive::Heroku.connection
      end.should raise_error(RuntimeError, 'The Heroku API key is mandatory')
    end

    it 'accepts the API key from the locomotive config file' do
      Locomotive.config.heroku = { :api_key => '12345' }
      lambda do
        Locomotive::Heroku.connection
      end.should_not raise_error
    end

    it 'accepts the API key from the ENV variables' do
      ENV['HEROKU_API_KEY'] = '12345'
      lambda do
        Locomotive::Heroku.connection
      end.should_not raise_error
      ENV.delete('HEROKU_API_KEY')
    end

  end

  describe '#application' do

    it 'raises an exception of no app name has been provided' do
      lambda do
        Locomotive::Heroku.app_name
      end.should raise_error(RuntimeError, 'The Heroku application name is mandatory')
    end

    it 'accepts the name from the locomotive config file' do
      Locomotive.config.heroku = { :app_name => 'locomotive' }
      lambda do
        Locomotive::Heroku.app_name.should == 'locomotive'
      end.should_not raise_error
    end

    it 'accepts the name from the ENV variables' do
      ENV['APP_NAME'] = 'locomotive_new'
      lambda do
        Locomotive::Heroku.app_name.should == 'locomotive_new'
      end.should_not raise_error
      ENV.delete('APP_NAME')
    end

  end

  describe '#domains' do

    it 'lists the domains' do
      puts Locomotive::Heroku.domains.inspect
    end

    it 'adds a domain' do

    end

  end

end

# require 'spec_helper'
#
# describe 'Heroku support' do
#
#   before(:each) do
#     ::Heroku::Client.any_instance.stubs(:post).returns(true)
#     ::Heroku::Client.any_instance.stubs(:delete).returns(true)
#   end
#
#   context '#loaded' do
#
#     it 'has method to enable heroku' do
#       Locomotive.respond_to?(:enable_heroku).should be_true
#     end
#
#     it 'tells heroku is disabled' do
#       Locomotive.heroku?.should be_false
#     end
#
#     it 'does not add instance methods to Site' do
#       Site.should_not include_instance_method :add_heroku_domains
#       Site.should_not include_instance_method :remove_heroku_domains
#
#       Site.should_not include_class_method :create_first_one_with_heroku
#     end
{'fraction_non_alphanumeric': 0.08742949234488316, 'fraction_numerical': 0.0040290088638195, 'mean_word_length': 2.9943684633950123, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3727258', 'n_tokens_mistral': 1627, 'n_tokens_neox': 1563, 'n_words': 427}