Sha256: 67a06c1b031f8b85347f086ee6d8a2f396ec205e2c057bce66724e62bcfbede8

Contents?: true

Size: 867 Bytes

Versions: 1

Compression:

Stored size: 867 Bytes

Contents

require 'thor/group'
require 'git'
require 'active_support/inflector'

module WatirInstall
  module Generators
    class Test < Thor::Group
      include Thor::Actions

      argument :klass, type: :string, desc: 'The data object being created'
      argument :form, type: :string, default: '', desc: 'Generates #submit_form'
      argument :specs, required: false, default: [], type: :array, desc: 'Specs for'

      def self.source_root
        "#{File.dirname(__FILE__)}/tests"
      end

      def git
        @git = Git.open('./') if Dir.entries('./').include?('.git')
      end

      def name
        Dir.pwd[/[^\/]*$/]
      end

      def data_files
        file = "#{Dir.pwd}/spec/#{klass.downcase}_spec.rb"
        erb = form == 'true' ? "crud" : "spec"
        template "spec/#{erb}.rb.tt", file
        @git.add(file) if @git
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watir_install-0.3.1 lib/watir_install/generators/test.rb