Class: Uberspec::Base
- Inherits:
-
Object
- Object
- Uberspec::Base
- Defined in:
- lib/uberspec.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#matches ⇒ Object
readonly
Returns the value of attribute matches.
-
#notifier ⇒ Object
readonly
Returns the value of attribute notifier.
-
#watchr ⇒ Object
readonly
Returns the value of attribute watchr.
Class Method Summary collapse
Instance Method Summary collapse
- #all_paths ⇒ Object
- #all_test_files ⇒ Object
- #clear ⇒ Object
- #command ⇒ Object
- #find_and_run_match(thing_to_match) ⇒ Object
-
#initialize(watchr_script, config) ⇒ Base
constructor
A new instance of Base.
- #parse_results(results) ⇒ Object
- #run ⇒ Object
- #run_all ⇒ Object
- #set_notifier ⇒ Object
- #start_watching ⇒ Object
- #system_with_notify(command) ⇒ Object
Constructor Details
#initialize(watchr_script, config) ⇒ Base
Returns a new instance of Base.
25 26 27 28 29 |
# File 'lib/uberspec.rb', line 25 def initialize(watchr_script,config) @watchr = watchr_script @config = config @notifier = set_notifier end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
22 23 24 |
# File 'lib/uberspec.rb', line 22 def config @config end |
#matches ⇒ Object (readonly)
Returns the value of attribute matches.
21 22 23 |
# File 'lib/uberspec.rb', line 21 def matches @matches end |
#notifier ⇒ Object (readonly)
Returns the value of attribute notifier.
23 24 25 |
# File 'lib/uberspec.rb', line 23 def notifier @notifier end |
#watchr ⇒ Object (readonly)
Returns the value of attribute watchr.
20 21 22 |
# File 'lib/uberspec.rb', line 20 def watchr @watchr end |
Class Method Details
.run_all ⇒ Object
15 16 17 |
# File 'lib/uberspec.rb', line 15 def run_all ObjectSpace.each_object(self) { |o| o.run_all } end |
Instance Method Details
#all_paths ⇒ Object
52 53 54 |
# File 'lib/uberspec.rb', line 52 def all_paths (@config.spec_paths + @config.code_paths).uniq end |
#all_test_files ⇒ Object
56 57 58 |
# File 'lib/uberspec.rb', line 56 def all_test_files raise "'all_test_files' Must be defined in test suite specific implimentation" end |
#clear ⇒ Object
69 70 71 |
# File 'lib/uberspec.rb', line 69 def clear system("clear") end |
#command ⇒ Object
60 61 62 |
# File 'lib/uberspec.rb', line 60 def command raise "'command' Must be defined in test suite specific implimentation" end |
#find_and_run_match(thing_to_match) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/uberspec.rb', line 43 def find_and_run_match(thing_to_match) @matches = all_test_files.grep(/#{thing_to_match}/i) if matches.empty? puts "No matches found for #{thing_to_match}" else run end end |
#parse_results(results) ⇒ Object
78 79 80 |
# File 'lib/uberspec.rb', line 78 def parse_results(results) raise "'parse_results' Must be defined in test suit specific implimentation" end |
#run ⇒ Object
73 74 75 76 |
# File 'lib/uberspec.rb', line 73 def run clear system_with_notify("#{command} #{matches.join(' ')}") end |
#run_all ⇒ Object
64 65 66 67 |
# File 'lib/uberspec.rb', line 64 def run_all @matches = all_test_files run end |
#set_notifier ⇒ Object
31 32 33 34 35 |
# File 'lib/uberspec.rb', line 31 def set_notifier return false if config.notify == false raise "Unsupported Notification library (try 'LibNotify' or 'Growl')." unless ['LibNotify', 'Growl'].include? config.notify eval("Uberspec::Notify::#{config.notify}").new(config.passed_image,config.failed_image) end |
#start_watching ⇒ Object
37 38 39 40 41 |
# File 'lib/uberspec.rb', line 37 def start_watching all_paths.each do |path| watchr.watch(path) {|m| find_and_run_match(m[1]) } end end |
#system_with_notify(command) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/uberspec.rb', line 82 def system_with_notify(command) #my_io = MyIO.new($stdout) #$stdout = my_io #system(command) #$stdout = my_io.old_io #results = my_io.captured if notifier results = %x{#{command}} notifier.notify(parse_results(results)) puts results else system(command) end end |