Sha256: 181912d3051d15f597d175facf6b3e6ffa136bbdc6a58850d098b0a530088615

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

require 'rails/generators'

module Testing
  module Generators
    class ConfigureGenerator < ::Rails::Generators::Base
      source_root File.expand_path("../templates", __FILE__)
      argument :framework_name, :type => :string, :default => "rspec"

      desc "Sets up a testing framework."

      attr_reader :app_name

      def configure_framework
        case framework_name
          when 'rspec'
            run 'rm -rf test/' # Removing test folder (not needed for RSpec)
            generate 'rspec:install'
            inject_into_file '.rspec', "--format documentation\n", :after => "--color\n"
            tweaks = File.read(find_in_source_paths('application.rb'))
            inject_into_file 'config/application.rb', tweaks + "\n", :after => "Rails::Application\n"
            gsub_file 'spec/spec_helper.rb', /check_pending/, 'maintain_test_schema'
            copy_file 'capybara.rb', 'spec/support/capybara.rb'
            gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures = true/, "config.use_transactional_fixtures = false"
            copy_file 'database_cleaner.rb', 'spec/support/database_cleaner.rb'
            copy_file 'factory_girl.rb', 'spec/support/factory_girl.rb'
            if File.exists?('config/initializers/devise.rb')
              copy_file 'devise.rb', 'spec/support/devise.rb'
            end
          when 'devise'
            copy_file 'devise.rb', 'spec/support/devise.rb'
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_apps_testing-0.2.1 lib/generators/testing/configure/configure_generator.rb
rails_apps_testing-0.2.0 lib/generators/testing/configure/configure_generator.rb