Class: Test::Right::CLI
- Inherits:
-
Object
- Object
- Test::Right::CLI
- Defined in:
- lib/test/right/cli.rb
Constant Summary collapse
- RUBY_FILE =
/^[^.].+.rb$/
Instance Method Summary collapse
- #config ⇒ Object
- #features ⇒ Object
- #load_and_run_tests ⇒ Object
- #load_config ⇒ Object
- #load_features ⇒ Object
- #load_widgets ⇒ Object
- #run_setup ⇒ Object
- #start(argument_list) ⇒ Object
- #widgets ⇒ Object
Instance Method Details
#config ⇒ Object
82 83 84 |
# File 'lib/test/right/cli.rb', line 82 def config @config end |
#features ⇒ Object
100 101 102 |
# File 'lib/test/right/cli.rb', line 100 def features Feature.subclasses || [] end |
#load_and_run_tests ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/test/right/cli.rb', line 18 def load_and_run_tests run_setup subdir = false if File.directory? "test/right" Dir.chdir("test/right") subdir = true end load_config load_features Dir.chdir("../..") if subdir puts "Running #{features.size} features" runner = Runner.new(config, , features) if runner.run puts "Passed!" else at_exit { exit(1) } puts "Failed:" runner.results.each do |feature, feature_result| puts " #{feature}" feature_result.each do |method, result| if result.is_a? Exception if result.is_a? WidgetActionNotImplemented puts " #{method} => #{result}" else puts " #{method} => #{result.class} - #{result}" result.backtrace.each do |trace| puts " #{trace}" end end else puts " #{method} => #{result}" end end end end end |
#load_config ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/test/right/cli.rb', line 74 def load_config = {} if File.exists? "config.yml" = YAML.load(open("config.yml")) end @config = Config.new() end |
#load_features ⇒ Object
95 96 97 98 |
# File 'lib/test/right/cli.rb', line 95 def load_features raise ConfigurationError, "no features/ directory" unless File.directory? "features" load_ruby_in_dir("features") end |
#load_widgets ⇒ Object
86 87 88 89 |
# File 'lib/test/right/cli.rb', line 86 def raise ConfigurationError, "no widgets/ directory" unless File.directory? "widgets" load_ruby_in_dir("widgets") end |
#run_setup ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/test/right/cli.rb', line 62 def run_setup if File.exists? "setup.rb" unless system("./setup.rb") raise ConfigurationError, "Setup failed" end elsif File.exists? "test/right/setup.rb" unless system("test/right/setup.rb") raise ConfigurationError, "Setup failed" end end end |
#start(argument_list) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/test/right/cli.rb', line 9 def start(argument_list) if argument_list.first == "install" Generator.new(argument_list[1..-1]).generate return else load_and_run_tests end end |
#widgets ⇒ Object
91 92 93 |
# File 'lib/test/right/cli.rb', line 91 def Widget.subclasses || [] end |