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
106 107 108 109 |
# File 'lib/plsql/spec/cli.rb', line 106 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 38 39 40 |
# File 'lib/plsql/spec/cli.rb', line 23 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 "\nPlease update spec/database.yml file and specify your database connection parameters.\n\nCreate tests in spec/ directory (or in subdirectories of it) in *_spec.rb files.\n\nRun created tests with \"plsql-spec run\".\nRun tests with \"plsql-spec run --coverage\" to generate code coverage report in coverage/ directory.\nRun tests with \"plsql-spec run --html\" to generate RSpec report to test-results.html file.\n", :red end |
#run_tests(*files) ⇒ Object
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 101 102 103 |
# File 'lib/plsql/spec/cli.rb', line 63 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 #{options[:coverage]}/index.html" end unless $?.exitstatus == 0 say "Failing tests!", :red exit 1 end end |
#version ⇒ Object
112 113 114 115 116 |
# File 'lib/plsql/spec/cli.rb', line 112 def version say "ruby-plsql-spec #{PLSQL::Spec::VERSION}" say "ruby-plsql #{PLSQL::VERSION}" say "rspec #{::RSpec::Version::STRING}" end |