Sha256: de8bdb97c65f744648b916595b9c42b325366ce1a2be8e4c3920f8ed1d3f8af4

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 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"
            gsub_file '.rspec', /--warnings/, ''
            tweaks = File.read(find_in_source_paths('application.rb'))
            inject_into_file 'config/application.rb', tweaks + "\n", :after => "Rails::Application\n"
            copy_file 'capybara.rb', 'spec/support/capybara.rb'
            gsub_file 'spec/rails_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

1 entries across 1 versions & 1 rubygems

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