Class: PLSQL::Spec::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/plsql/spec/cli.rb

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



9
10
11
12
# File 'lib/plsql/spec/cli.rb', line 9

def initialize(*)
  super
  self.source_paths << File.expand_path('../templates', __FILE__)
end

Instance Method Details

#initObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/plsql/spec/cli.rb', line 17

def init
  empty_directory 'spec'
  %w(spec_helper.rb database.yml).each do |file|
    copy_file file, "spec/#{file}"
  end
  directory 'helpers', 'spec/helpers'
  empty_directory 'spec/factories'
  say <<-EOS, :red

Please update spec/database.yml file and specify your database connection parameters.

Create tests in spec/ directory (or in subdirectories of it) in *_spec.rb files.

Run created tests with "plsql-spec run".
Run tests with "plsql-spec run --coverage" to generate code coverage report in coverage/ directory.
EOS
end

#run_tests(*files) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/plsql/spec/cli.rb', line 49

def run_tests(*files)
  unless File.directory?('spec')
    say "No spec subdirectory in current directory", :red
    exit 1
  end
  ENV['PLSQL_DBMS_OUTPUT'] = 'true' if options[:"dbms-output"]
  ENV['PLSQL_COVERAGE'] = options[:coverage] if options[:coverage]
  ENV['PLSQL_COVERAGE_IGNORE_SCHEMAS'] = options[:"ignore-schemas"].join(',') if options[:"ignore-schemas"]
  ENV['PLSQL_COVERAGE_LIKE'] = options[:like].join(',') if options[:like]
  if files.empty?
    say "Running all specs from spec/", :yellow
    puts run('spec spec', :verbose => false)
  else
    say "Running specs from #{files.join(', ')}", :yellow
    puts run("spec #{files.join(' ')}", :verbose => false)
  end
  unless $?.exitstatus == 0
    say "Failing tests!", :red
    exit 1
  end
end

#versionObject



72
73
74
75
76
# File 'lib/plsql/spec/cli.rb', line 72

def version
  say "ruby-plsql-spec #{PLSQL::Spec::VERSION}"
  say "ruby-plsql      #{PLSQL::VERSION}"
  say "rspec           #{::Spec::VERSION::STRING}"
end