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.
15 16 17 18 |
# File 'lib/plsql/spec/cli.rb', line 15 def initialize(*) super self.source_paths << File.('../templates', __FILE__) end |
Instance Method Details
#diff(file1, file2) ⇒ Object
103 104 105 106 |
# File 'lib/plsql/spec/cli.rb', line 103 def diff(file1, file2) differ = RSpec::Support::Differ.new say differ.diff_as_string File.read(file2), File.read(file1) end |
#init ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/plsql/spec/cli.rb', line 23 def init empty_directory 'spec/factories' copy_file '.rspec', '.rspec' directory 'spec', 'spec' 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
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 98 99 100 |
# File 'lib/plsql/spec/cli.rb', line 60 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, :capture => [:capture]) else say "Running specs from #{files.join(', ')}", :yellow puts run("#{speccommand} #{files.join(' ')}", :verbose => false, :capture => [:capture]) 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 |