Class: PLSQL::Spec::CLI
- Inherits:
-
Thor
- Object
- Thor
- PLSQL::Spec::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/plsql/spec/cli.rb
Instance Method Summary collapse
- #diff(file1, file2) ⇒ Object
- #init ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #run_tests(*files) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
13 14 15 16 |
# File 'lib/plsql/spec/cli.rb', line 13 def initialize(*) super self.source_paths << File.('../templates', __FILE__) end |
Instance Method Details
#diff(file1, file2) ⇒ Object
100 101 102 103 |
# File 'lib/plsql/spec/cli.rb', line 100 def diff(file1, file2) differ = RSpec::Expectations::Differ.new say differ.diff_as_string File.read(file2), File.read(file1) end |
#init ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/plsql/spec/cli.rb', line 21 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. Run tests with "plsql-spec run --html" to generate RSpec report to test-results.html file. EOS end |
#run_tests(*files) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/plsql/spec/cli.rb', line 57 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 [:"dbms-output"] ENV['PLSQL_HTML'] = [:html] if [:html] ENV['PLSQL_COVERAGE'] = [:coverage] if [:coverage] ENV['PLSQL_COVERAGE_IGNORE_SCHEMAS'] = [:"ignore-schemas"].join(',') if [:"ignore-schemas"] ENV['PLSQL_COVERAGE_LIKE'] = [:like].join(',') if [:like] if [:html] # if there is no filename given, the options[:html] == "html" spec_output_filename = [:html] == 'html' ? 'test-results.html' : [:html] speccommand = "rspec --format html --out #{spec_output_filename}" else speccommand = "rspec" end if files.empty? say "Running all specs from spec/", :yellow puts run("#{speccommand} spec", :verbose => false) else say "Running specs from #{files.join(', ')}", :yellow puts run("#{speccommand} #{files.join(' ')}", :verbose => false) end if [:html] say "Test results in #{spec_output_filename}" end if [:coverage] say "Coverage report in #{[:coverage]}/index.html" end unless $?.exitstatus == 0 say "Failing tests!", :red exit 1 end end |