Sha256: 821aa592e18653ee016b4caaf59d945595ffcb94acdaee915b30d0192da33750

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

if defined?(::Rails)
require 'tempfile'
require 'generators/rack/dev-mark/install_generator'
describe Rack::DevMark::InstallGenerator do
  include_context 'forked spec'

  context "config/application.rb" do
    let(:application_rb) { Tempfile.new('config_application.rb') }
    before do
      application_rb.write <<-EOS
module MyApp
  class Application < Rails::Application
    # ...
  end
end
      EOS
      application_rb.rewind
      allow_any_instance_of(Rack::DevMark::InstallGenerator).to receive(:target_path).and_return(application_rb.path)
    end
    after do
      application_rb.close
      application_rb.unlink
    end

    it 'inserts rack-dev-mark settings' do
      Rails::Generators.invoke("rack:dev-mark:install")
      application_rb.rewind
      expect(application_rb.read).to eq <<-EOS
module MyApp
  class Application < Rails::Application
    # Enable rack-dev-mark
    config.rack_dev_mark.enable = !Rails.env.production?
    # Customize themes if you want to do so
    # config.rack_dev_mark.theme = [:title, :github_fork_ribbon]
    # Customize inserted place of the middleware if necessary.
    # You can use either `insert_before` or `insert_after`
    # config.rack_dev_mark.insert_before SomeOtherMiddleware
    # config.rack_dev_mark.insert_after SomeOtherMiddleware

    # ...
  end
end
      EOS
    end
  end

  describe "#target_path (private)" do
    subject { Rack::DevMark::InstallGenerator.new }
    it "returns 'config/application.rb'" do
      expect(subject.__send__(:target_path)).to eq('config/application.rb')
    end
  end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-dev-mark-0.6.4 spec/generators/rack/dev-mark/install_generator_spec.rb