rsanheim-beholder 0.5.7 → 0.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,8 @@ require 'beholder'
5
5
  require 'rubygems'
6
6
  require 'micronaut'
7
7
  gem :rr, '=0.7.0'
8
+ require 'log_buddy'
9
+ LogBuddy.init
8
10
 
9
11
  def not_in_editor?
10
12
  ['TM_MODE', 'EMACS', 'VIM'].all? { |k| !ENV.has_key?(k) }
@@ -14,4 +16,5 @@ Micronaut.configure do |c|
14
16
  c.formatter = :documentation
15
17
  c.mock_with :rr
16
18
  c.color_enabled = not_in_editor?
19
+ c.filter_run :focused => true
17
20
  end
@@ -48,13 +48,6 @@ describe Beholder do
48
48
  beholder.on_change files
49
49
  end
50
50
 
51
- it "should match stuff" do
52
- files = ['widgets']
53
- beholder = Beholder.new
54
- stub(beholder).find_matches('widgets') { 'widgets_example' }
55
- mock(beholder).run_tests(['widgets_example'])
56
- beholder.on_change files
57
- end
58
51
  end
59
52
 
60
53
  describe "blink" do
@@ -120,4 +113,13 @@ describe Beholder do
120
113
  end
121
114
  end
122
115
 
116
+ describe "examples_matching" do
117
+
118
+ it "finds a fuzzy match from all_examples" do
119
+ beholder = Beholder.new
120
+ stub(beholder).all_examples { ["examples/unit/foo_example.rb", "examples/slow/foo_example.rb", "src/foo_system_example.rb", "examples/some/deeper/dir/foo_example.rb"] }
121
+ beholder.examples_matching("foo").should == ["examples/unit/foo_example.rb", "examples/slow/foo_example.rb", "examples/some/deeper/dir/foo_example.rb"]
122
+ end
123
+ end
124
+
123
125
  end
data/lib/beholder.rb CHANGED
@@ -58,6 +58,11 @@ class Beholder
58
58
  matches = treasure.map { |t| find_matches(t) }.uniq.compact
59
59
  run_tests matches
60
60
  end
61
+
62
+ def examples_matching(name, suffix = "example")
63
+ regex = %r%.*#{name}_#{suffix}\.rb$%
64
+ all_examples.find_all { |ex| ex =~ regex }
65
+ end
61
66
 
62
67
  protected
63
68
 
@@ -109,13 +114,13 @@ class Beholder
109
114
  Dir["examples/**/*_example.rb"]
110
115
  end
111
116
 
112
- m.add_mapping %r%lib/(.*)\.rb% do |file|
113
- ["examples/lib/#{match[1]}_example.rb"]
117
+ m.add_mapping %r%lib/(.*)\.rb% do |match|
118
+ examples_matching match[1]
114
119
  end
115
120
 
116
121
  end
117
122
  end
118
-
123
+
119
124
  def clear_maps
120
125
  @treasure_maps = {}
121
126
  end
@@ -138,12 +143,12 @@ class Beholder
138
143
  @sent_an_int = false
139
144
  end
140
145
 
141
- def find_matches(treasure)
142
- treasure_maps.each do |name, treasure_locations|
143
- treasure_locations.each do |stolen_by_enemy, spell|
144
- if spell_components = treasure.match(stolen_by_enemy)
145
- say "Found the stolen treasure using the #{name} map "
146
- return spell.call(spell_components)
146
+ def find_matches(path)
147
+ treasure_maps.each do |name, map|
148
+ map.each do |pattern, blk|
149
+ if match = path.match(pattern)
150
+ say "Found the match for #{path} using the #{name} map "
151
+ return blk.call(match)
147
152
  end
148
153
  end
149
154
  end
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.7
4
+ version: 0.5.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Humphries, Rob Sanheim
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-03 00:00:00 -08:00
12
+ date: 2009-03-04 00:00:00 -08:00
13
13
  default_executable: beholder
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency