starting_blocks 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,9 +22,9 @@ module StartingBlocks
22
22
  @light = Blinky.new.light
23
23
  end
24
24
 
25
- def receive_specs_to_run specs
26
- @spec_count = specs.count
27
- return if specs.count == 0
25
+ def receive_files_to_run files
26
+ @spec_count = files.count
27
+ return if files.count == 0
28
28
  change_color_to :yellow
29
29
  end
30
30
 
@@ -14,11 +14,11 @@ module StartingBlocks
14
14
  end
15
15
  end
16
16
 
17
- def publish_specs_to_run specs
17
+ def publish_files_to_run files
18
18
  return unless @subscribers
19
19
  @subscribers.each do |s|
20
20
  begin
21
- s.receive_specs_to_run specs
21
+ s.receive_files_to_run files
22
22
  rescue
23
23
  end
24
24
  end
@@ -7,18 +7,19 @@ module StartingBlocks
7
7
  @verbose = options[:verbose]
8
8
  end
9
9
 
10
- def run_files specs
11
- display "Specs to run: #{specs.inspect}"
12
- StartingBlocks::Publisher.publish_specs_to_run specs
13
- results = execute_these_specs specs
10
+ def run_files files
11
+ display "Files to run: #{files.inspect}"
12
+ StartingBlocks::Publisher.publish_files_to_run files
13
+ results = execute_these_files files
14
14
  StartingBlocks::Publisher.publish_results results
15
15
  puts results
16
+ results
16
17
  end
17
18
 
18
19
  private
19
20
 
20
- def execute_these_specs specs
21
- requires = specs.map { |x| "require '#{x}'" }.join("\n")
21
+ def execute_these_files files
22
+ requires = files.map { |x| "require '#{x}'" }.join("\n")
22
23
  `ruby -e "#{requires}"`
23
24
  end
24
25
  end
@@ -1,3 +1,3 @@
1
1
  module StartingBlocks
2
- VERSION = "0.0.18"
2
+ VERSION = "0.0.19"
3
3
  end
@@ -5,6 +5,8 @@ module StartingBlocks
5
5
 
6
6
  TEST_FILE_CLUES = ["_test", "test_", "_spec"]
7
7
 
8
+ @last_failed_run = nil
9
+
8
10
  include Displayable
9
11
 
10
12
  class << self
@@ -34,7 +36,8 @@ module StartingBlocks
34
36
  def run_it(file_that_changed, all_files, options)
35
37
  specs = get_the_specs_to_run file_that_changed, all_files
36
38
  display "Matches: #{specs.inspect}"
37
- StartingBlocks::Runner.new(options).run_files specs
39
+ results = StartingBlocks::Runner.new(options).run_files specs
40
+ store_the_specs_if_they_failed results, specs
38
41
  end
39
42
 
40
43
  def delete_it(file_that_changed, all_files, options)
@@ -45,11 +48,25 @@ module StartingBlocks
45
48
 
46
49
  private
47
50
 
51
+ def store_the_specs_if_they_failed results, specs
52
+ parsed_results = StartingBlocks::Publisher.result_parser.parse(results)
53
+ if parsed_results[:failures] > 0 || parsed_results[:skips] > 0 || parsed_results[:errors] > 0
54
+ @last_failed_run = specs
55
+ else
56
+ @last_failed_run = nil
57
+ end
58
+ rescue
59
+ end
60
+
48
61
  def get_the_specs_to_run(file_that_changed, all_files)
49
62
  filename = flush_file_name file_that_changed
50
63
  matches = all_files.select { |x| flush_file_name(x).include?(filename) && x != file_that_changed }
51
64
  matches << file_that_changed
65
+
52
66
  specs = matches.select { |x| is_a_test_file?(x) && File.file?(x) }.map { |x| File.expand_path x }
67
+ specs = (@last_failed_run + specs).flatten if @last_failed_run
68
+
69
+ specs
53
70
  end
54
71
 
55
72
  def is_a_test_file?(file)
@@ -5,7 +5,7 @@ describe StartingBlocks::Publisher do
5
5
  let(:results) { Object.new }
6
6
  let(:parsed_results) { Object.new }
7
7
  let(:result_parser) { mock() }
8
- let(:specs) { Object.new }
8
+ let(:files) { Object.new }
9
9
 
10
10
  before do
11
11
  result_parser.stubs(:parse).with(results).returns parsed_results
@@ -60,50 +60,50 @@ describe StartingBlocks::Publisher do
60
60
  end
61
61
  end
62
62
 
63
- describe "#publish_specs_to_run" do
63
+ describe "#publish_files_to_run" do
64
64
  describe "one subscriber" do
65
- it "should pass the specs to the subscriber" do
65
+ it "should pass the files to the subscriber" do
66
66
  subscriber = mock()
67
- subscriber.expects(:receive_specs_to_run).with(specs)
67
+ subscriber.expects(:receive_files_to_run).with(files)
68
68
  StartingBlocks::Publisher.subscribers = [subscriber]
69
- StartingBlocks::Publisher.publish_specs_to_run specs
69
+ StartingBlocks::Publisher.publish_files_to_run files
70
70
  end
71
71
  end
72
72
 
73
73
  describe "two subscribers" do
74
- it "should pass the specs to the subscriber" do
74
+ it "should pass the files to the subscriber" do
75
75
  first_subscriber = mock()
76
- first_subscriber.expects(:receive_specs_to_run).with(specs)
76
+ first_subscriber.expects(:receive_files_to_run).with(files)
77
77
  second_subscriber = mock()
78
- second_subscriber.expects(:receive_specs_to_run).with(specs)
78
+ second_subscriber.expects(:receive_files_to_run).with(files)
79
79
  StartingBlocks::Publisher.subscribers = [first_subscriber, second_subscriber]
80
- StartingBlocks::Publisher.publish_specs_to_run specs
80
+ StartingBlocks::Publisher.publish_files_to_run files
81
81
  end
82
82
  end
83
83
 
84
84
  describe "nil subscribers" do
85
85
  it "should not error" do
86
86
  StartingBlocks::Publisher.subscribers = nil
87
- StartingBlocks::Publisher.publish_specs_to_run specs
87
+ StartingBlocks::Publisher.publish_files_to_run files
88
88
  end
89
89
  end
90
90
 
91
91
  describe "no subscribers" do
92
92
  it "should not error" do
93
93
  StartingBlocks::Publisher.subscribers = []
94
- StartingBlocks::Publisher.publish_specs_to_run specs
94
+ StartingBlocks::Publisher.publish_files_to_run files
95
95
  end
96
96
  end
97
97
 
98
98
  describe "subscriber with no method to receive" do
99
99
  it "should not error" do
100
100
  first_subscriber = mock()
101
- first_subscriber.expects(:receive_specs_to_run).with(specs)
101
+ first_subscriber.expects(:receive_files_to_run).with(files)
102
102
  second_subscriber = Object.new
103
103
  third_subscriber = mock()
104
- third_subscriber.expects(:receive_specs_to_run).with(specs)
104
+ third_subscriber.expects(:receive_files_to_run).with(files)
105
105
  StartingBlocks::Publisher.subscribers = [first_subscriber, second_subscriber, third_subscriber]
106
- StartingBlocks::Publisher.publish_specs_to_run specs
106
+ StartingBlocks::Publisher.publish_files_to_run files
107
107
  end
108
108
  end
109
109
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starting_blocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-04 00:00:00.000000000 Z
12
+ date: 2013-05-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -164,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  segments:
166
166
  - 0
167
- hash: 1338765525331935684
167
+ hash: -2515999654231235318
168
168
  required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  none: false
170
170
  requirements:
@@ -173,10 +173,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  version: '0'
174
174
  segments:
175
175
  - 0
176
- hash: 1338765525331935684
176
+ hash: -2515999654231235318
177
177
  requirements: []
178
178
  rubyforge_project:
179
- rubygems_version: 1.8.24
179
+ rubygems_version: 1.8.25
180
180
  signing_key:
181
181
  specification_version: 3
182
182
  summary: One command to run all tests, test watcher, etc.