Sha256: 4122ca7b4890f6be1eb6c75110f658a0976aa25f1f4979080facb392c3c6a25d

Contents?: true

Size: 1.22 KB

Versions: 18

Compression:

Stored size: 1.22 KB

Contents

require "ammeter/rspec/generator/example.rb"
require "ammeter/rspec/generator/matchers.rb"
require "ammeter/init"

module GeneratorSpecHelpers
  TEMPLATE_PATH = File.expand_path("../../app_templates", __FILE__)

  def provide_existing_routes_file
    copy_to_generator_root("config", "routes.rb")
  end

  def provide_existing_initializer
    copy_to_generator_root("config/initializers", "clearance.rb")
  end

  def provide_existing_application_controller
    copy_to_generator_root("app/controllers", "application_controller.rb")
  end

  def provide_existing_user_class
    copy_to_generator_root("app/models", "user.rb")
    allow(File).to receive(:exist?).and_call_original
    allow(File).to receive(:exist?).with("app/models/user.rb").and_return(true)
  end

  private

  def copy_to_generator_root(destination, template)
    template_file = File.join(TEMPLATE_PATH, destination, template)
    destination = File.join(destination_root, destination)

    FileUtils.mkdir_p(destination)
    FileUtils.cp(template_file, destination)
  end
end

RSpec.configure do |config|
  config.include GeneratorSpecHelpers

  config.before(:example, :generator) do
    destination File.expand_path("../../../tmp", __FILE__)
    prepare_destination
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
clearance-2.8.0 spec/support/generator_spec_helpers.rb
clearance-2.7.2 spec/support/generator_spec_helpers.rb
clearance-2.7.0 spec/support/generator_spec_helpers.rb
clearance-2.6.2 spec/support/generator_spec_helpers.rb
clearance-2.6.1 spec/support/generator_spec_helpers.rb
clearance-2.6.0 spec/support/generator_spec_helpers.rb
clearance-2.5.0 spec/support/generator_spec_helpers.rb
clearance-2.4.0 spec/support/generator_spec_helpers.rb
clearance-2.3.1 spec/support/generator_spec_helpers.rb
clearance-2.3.0 spec/support/generator_spec_helpers.rb
clearance-2.2.1 spec/support/generator_spec_helpers.rb
clearance-2.2.0 spec/support/generator_spec_helpers.rb
clearance-2.1.0 spec/support/generator_spec_helpers.rb
clearance-1.14.0 spec/support/generator_spec_helpers.rb
clearance-1.13.0 spec/support/generator_spec_helpers.rb
clearance-1.12.1 spec/support/generator_spec_helpers.rb
clearance-1.12.0 spec/support/generator_spec_helpers.rb
clearance-1.11.0 spec/support/generator_spec_helpers.rb