Sha256: a62038725ddc2c356c8ad0bf5e0738280c81a9aa7b7af69c8805bf8874246321

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

require 'test_helper'
require 'new_configuration_generator'

# Stub out methods on upgrader class
module Rails
  module Upgrading
    class NewConfigurationGenerator
      attr_writer :environment_code
      
      def has_environment?
        true
      end
      
      def environment_code
        @environment_code
      end
      
      def app_name
        "my_application"
      end
    end
  end
end

class NewConfigurationGeneratorTest < ActiveSupport::TestCase
  FRAME = "# Put this in config/application.rb
require File.expand_path('../boot', __FILE__)

module MyApplication
  class Application < Rails::Application
%s
  end
end"

  CONFIG = "  config.what_have_you = 'thing'
  config.action_controller = 'what'"

  CODE = "require 'w/e'

this_happens_before_the(code)
more_before_the_code!

Rails::Initializer.run do |config|
%s
end

this_is_after_the_code
"

  def test_raises_error_with_no_code
    generator = Rails::Upgrading::NewConfigurationGenerator.new
    generator.environment_code = ""
    
    assert_raises(RuntimeError) { generator.generate_new_application_rb }
  end
  
  def test_generates_with_code
    generator = Rails::Upgrading::NewConfigurationGenerator.new
    generator.environment_code = CODE % [CONFIG]
    
    assert_equal FRAME % [generator.indent(CONFIG)], generator.generate_new_application_rb
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
trusty-layouts-extension-1.0.2 vendor/plugins/rails_upgrade/test/new_configuration_generator_test.rb
trusty-layouts-extension-1.0.1 vendor/plugins/rails_upgrade/test/new_configuration_generator_test.rb
trusty-layouts-extension-1.0.0 vendor/plugins/rails_upgrade/test/new_configuration_generator_test.rb
trusty-cms-1.0.1 vendor/plugins/rails_upgrade/test/new_configuration_generator_test.rb