Sha256: 3ee47d4a2f02f9550f8f264530fd712d364628b8f3e6fcb44356ab807fc37a44

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

module Machinist
  module Generators #:nodoc:
    class InstallGenerator < Rails::Generators::Base #:nodoc:
      source_root File.expand_path('../templates', __FILE__)

      class_option :test_framework, :type => :string, :aliases => "-t", :desc => "Test framework to use Machinist with"
      class_option :cucumber, :type => :boolean, :desc => "Set up access to Machinist from Cucumber"

      def blueprints_file
        if rspec?
          copy_file "blueprints.rb", "spec/support/blueprints.rb" 
        else
          copy_file "blueprints.rb", "test/blueprints.rb"
        end
      end

      def test_helper
        if test_unit?
          inject_into_file("test/test_helper.rb", :after => "require 'rails/test_help'\n") do
            "require File.expand_path(File.dirname(__FILE__) + '/blueprints')\n"
          end
        end
      end

      def cucumber_support
        if cucumber?
          template "machinist.rb.erb", "features/support/machinist.rb"
        end
      end

    private

      def rspec?
        options[:test_framework].to_sym == :rspec
      end

      def test_unit?
        options[:test_framework].to_sym == :test_unit
      end

      def cucumber?
        options[:cucumber]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
machinist-2.0 lib/generators/machinist/install/install_generator.rb
indirect-machinist-2.0.0.beta3 lib/generators/machinist/install/install_generator.rb