Sha256: 7ea65223100e763aabd7fc4cff786cb3d6d468b56168f257fd3bc4e29220a06d

Contents?: true

Size: 1.4 KB

Versions: 9

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

CLASS = RailsAssist::File::Special

class AppDir
  include CLASS
end

describe RailsAssist::File::Environment do
  # use_helper :directories

  before do
    RailsAssist::Directory.rails_root = fixtures_dir
  end

  before :each do
    file_name = CLASS.environment_filepath
    FileUtils.cp file_name, file_name + '.bak'
  end

  after :each do
    file_name = CLASS.environment_filepath
    FileUtils.mv file_name + '.bak', file_name
  end

  describe '#insert_before_application_init' do
    it "should add code or content BEFORE the application is initialized" do
      CLASS.insert_before_application_init 'config.hello = 2'
      content = CLASS.read_environment_file
      content.should match /config\.hello = 2\n(.*)::Application.initialize!/
    end
  end
  
  describe '#insert_after_application_init' do
    it "should add code or content AFTER the application is initialized" do
      CLASS.insert_after_application_init 'config.hello = 2'
      content = CLASS.read_environment_file
      content.should match /::Application.initialize!\n(.*)config\.hello = 2/
    end
  end
  
  describe '#insert_application_init' do
    it "should add code or content AFTER the application is initialized" do
      CLASS.insert_application_init :after, 'config.hello = 2'
      content = CLASS.read_environment_file
      content.should match /::Application.initialize!\n(.*)config\.hello = 2/
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails_assist-0.5.3 spec/rails_assist/file/environment_spec.rb
rails_assist-0.5.2 spec/rails_assist/file/environment_spec.rb
rails_assist-0.5.1 spec/rails_assist/file/environment_spec.rb
rails_assist-0.5.0 spec/rails_assist/file/environment_spec.rb
rails_assist-0.4.4 spec/rails_assist/file/environment_spec.rb
rails_assist-0.4.3 spec/rails_assist/file/environment_spec.rb
rails_assist-0.4.2 spec/rails_assist/file/environment_spec.rb
rails_assist-0.4.1 spec/rails_assist/file/environment_spec.rb
rails_assist-0.4.0 spec/rails_assist/file/environment_spec.rb