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.
26 27 28 29 30 |
# File 'lib/uberspec.rb', line 26 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.
23 24 25 |
# File 'lib/uberspec.rb', line 23 def config @config end |
#matches ⇒ Object (readonly)
Returns the value of attribute matches.
22 23 24 |
# File 'lib/uberspec.rb', line 22 def matches @matches end |
#notifier ⇒ Object (readonly)
Returns the value of attribute notifier.
24 25 26 |
# File 'lib/uberspec.rb', line 24 def notifier @notifier end |
#watchr ⇒ Object (readonly)
Returns the value of attribute watchr.
21 22 23 |
# File 'lib/uberspec.rb', line 21 def watchr @watchr end |
Class Method Details
.run_all ⇒ Object
16 17 18 |
# File 'lib/uberspec.rb', line 16 def run_all ObjectSpace.each_object(self) { |o| o.run_all } end |
Instance Method Details
#all_paths ⇒ Object
53 54 55 |
# File 'lib/uberspec.rb', line 53 def all_paths (@config.spec_paths + @config.code_paths).uniq end |
#all_test_files ⇒ Object
57 58 59 |
# File 'lib/uberspec.rb', line 57 def all_test_files raise "'all_test_files' Must be defined in test suite specific implimentation" end |
#clear ⇒ Object
70 71 72 |
# File 'lib/uberspec.rb', line 70 def clear system("clear") end |
#command ⇒ Object
61 62 63 |
# File 'lib/uberspec.rb', line 61 def command raise "'command' Must be defined in test suite specific implimentation" end |
#find_and_run_match(thing_to_match) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/uberspec.rb', line 44 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
79 80 81 |
# File 'lib/uberspec.rb', line 79 def parse_results(results) raise "'parse_results' Must be defined in test suit specific implimentation" end |
#run ⇒ Object
74 75 76 77 |
# File 'lib/uberspec.rb', line 74 def run clear system_with_notify("#{command} #{matches.join(' ')}") end |
#run_all ⇒ Object
65 66 67 68 |
# File 'lib/uberspec.rb', line 65 def run_all @matches = all_test_files run end |
#set_notifier ⇒ Object
32 33 34 35 36 |
# File 'lib/uberspec.rb', line 32 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
38 39 40 41 42 |
# File 'lib/uberspec.rb', line 38 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
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/uberspec.rb', line 83 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 |