rsanheim-beholder 0.5.10 → 0.5.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -50,6 +50,13 @@ describe Beholder do
50
50
 
51
51
  end
52
52
 
53
+ describe "build_cmd" do
54
+ it "contructs build cmd by requiring all test files" do
55
+ beholder = Beholder.new
56
+ beholder.build_cmd(["test/foo_test.rb"]).should == %[ruby -e "%w[test/foo_test].each { |f| require f }"]
57
+ end
58
+ end
59
+
53
60
  describe "blink" do
54
61
 
55
62
  it "should forget about any interlopers" do
data/lib/beholder.rb CHANGED
@@ -53,9 +53,9 @@ class Beholder
53
53
  exit
54
54
  end
55
55
 
56
- def on_change(treasure)
57
- say "#{treasure} changed" unless treasure.empty?
58
- matches = treasure.map { |t| find_matches(t) }.uniq.compact
56
+ def on_change(paths)
57
+ say "#{paths} changed" unless paths.nil? || paths.empty?
58
+ matches = paths.map { |path| find_matches(path) }.uniq.compact
59
59
  run_tests matches
60
60
  end
61
61
 
@@ -64,6 +64,15 @@ class Beholder
64
64
  all_examples.find_all { |ex| ex =~ regex }
65
65
  end
66
66
 
67
+ def build_cmd(paths)
68
+ classes = paths.collect { |p| p.gsub(".rb", "") }
69
+ puts "\nRunning #{paths.join(', ').inspect}"
70
+ execute = %[-e "%w[#{classes}].each { |f| require f }"]
71
+ cmd = "ruby #{execute}"
72
+ say cmd
73
+ cmd
74
+ end
75
+
67
76
  protected
68
77
 
69
78
  def read_all_maps
@@ -153,25 +162,23 @@ class Beholder
153
162
  end
154
163
  end
155
164
 
156
- puts "Unknown file: #{treasure}"
165
+ puts "Unknown file: #{path}"
157
166
  return []
158
167
  end
159
168
 
160
- def run_tests(coordinates)
161
- coordinates.flatten!
169
+ def run_tests(paths)
170
+ paths.flatten!
162
171
 
163
- coordinates.reject! do |coordinate|
164
- found_treasure = File.exist?(coordinate)
165
- puts "#{coordinate} does not exist." unless found_treasure
172
+ paths.reject! do |path|
173
+ found_treasure = File.exist?(path)
174
+ puts "#{path} does not exist." unless found_treasure
166
175
  end
167
176
 
168
- return if coordinates.empty?
169
-
170
- puts "\nRunning #{coordinates.join(', ').inspect}"
171
- system "ruby #{coordinates.join(' ')}"
177
+ return if paths.empty?
178
+ system build_cmd(paths)
172
179
  blink
173
180
  end
174
-
181
+
175
182
  private
176
183
  def say(msg)
177
184
  puts msg if verbose
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsanheim-beholder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.10
4
+ version: 0.5.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Humphries, Rob Sanheim