spicycode-micronaut 0.1.4.4 → 0.1.5
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.
- data/Rakefile +1 -1
- data/bin/micronaut +1 -1
- data/examples/lib/micronaut/formatters/progress_formatter_example.rb +3 -3
- data/examples/lib/micronaut/runner_example.rb +36 -0
- data/lib/micronaut/configuration.rb +2 -2
- data/lib/micronaut/formatters/base_formatter.rb +2 -2
- data/lib/micronaut/formatters/base_text_formatter.rb +5 -3
- metadata +1 -1
data/Rakefile
CHANGED
data/bin/micronaut
CHANGED
@@ -57,12 +57,12 @@ describe Micronaut::Formatters::ProgressFormatter do
|
|
57
57
|
@output.string.should == ""
|
58
58
|
end
|
59
59
|
|
60
|
-
it "should ensure
|
60
|
+
it "should ensure ':' in the first backtrace" do
|
61
61
|
backtrace = ["/tmp/x.rb:1", "/tmp/x.rb:2", "/tmp/x.rb:3"]
|
62
|
-
@formatter.format_backtrace(backtrace).should ==
|
62
|
+
@formatter.format_backtrace(backtrace).should == backtrace
|
63
63
|
|
64
64
|
backtrace = ["/tmp/x.rb:1: message", "/tmp/x.rb:2", "/tmp/x.rb:3"]
|
65
|
-
@formatter.format_backtrace(backtrace).should == "/tmp/x.rb:1: message"
|
65
|
+
@formatter.format_backtrace(backtrace).first.should == "/tmp/x.rb:1: message"
|
66
66
|
end
|
67
67
|
|
68
68
|
end
|
@@ -2,4 +2,40 @@ require File.expand_path(File.dirname(__FILE__) + "/../../example_helper")
|
|
2
2
|
|
3
3
|
describe Micronaut::Runner do
|
4
4
|
|
5
|
+
before do
|
6
|
+
@runner = Micronaut::Runner.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#configuration' do
|
10
|
+
|
11
|
+
it "should return Micronaut.configuration" do
|
12
|
+
@runner.configuration.should == Micronaut.configuration
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#formatter' do
|
18
|
+
|
19
|
+
it 'should return the configured formatter' do
|
20
|
+
@runner.formatter.should == Micronaut.configuration.formatter
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'Micronaut::Runner.at_exit' do
|
26
|
+
|
27
|
+
it 'should set an at_exit hook if none is already set' do
|
28
|
+
Micronaut::Runner.stubs(:installed_at_exit?).returns(false)
|
29
|
+
Micronaut::Runner.expects(:at_exit)
|
30
|
+
Micronaut::Runner.autorun
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should not set the at_exit hook if it is already set' do
|
34
|
+
Micronaut::Runner.stubs(:installed_at_exit?).returns(true)
|
35
|
+
Micronaut::Runner.expects(:at_exit).never
|
36
|
+
Micronaut::Runner.autorun
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
5
41
|
end
|
@@ -23,7 +23,7 @@ module Micronaut
|
|
23
23
|
|
24
24
|
|
25
25
|
def initialize
|
26
|
-
@backtrace_clean_patterns = [/\/lib\/ruby\//, /bin\/rcov:/, /vendor\/rails/]
|
26
|
+
@backtrace_clean_patterns = [/\/lib\/ruby\//, /bin\/rcov:/, /vendor\/rails/, /bin\/micronaut/]
|
27
27
|
@profile_examples = false
|
28
28
|
@run_all_when_everything_filtered = true
|
29
29
|
@filter = nil
|
@@ -31,7 +31,7 @@ module Micronaut
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def cleaned_from_backtrace?(line)
|
34
|
-
return true if line
|
34
|
+
return true if line =~ /#{::Micronaut::InstallDirectory}/
|
35
35
|
|
36
36
|
@backtrace_clean_patterns.any? do |pattern|
|
37
37
|
line =~ pattern
|
@@ -107,7 +107,7 @@ module Micronaut
|
|
107
107
|
def format_backtrace(backtrace)
|
108
108
|
return "" if backtrace.nil?
|
109
109
|
cleansed = backtrace.map { |line| backtrace_line(line) }.compact
|
110
|
-
cleansed.empty? ? backtrace
|
110
|
+
cleansed.empty? ? backtrace : cleansed
|
111
111
|
end
|
112
112
|
|
113
113
|
protected
|
@@ -121,7 +121,7 @@ module Micronaut
|
|
121
121
|
|
122
122
|
def read_failed_line(file_path_with_line_number)
|
123
123
|
file_path, line_number = file_path_with_line_number.split(':')
|
124
|
-
open(file_path, 'r') { |f| f.readlines[line_number.to_i
|
124
|
+
open(file_path, 'r') { |f| f.readlines[line_number.to_i - 1] }
|
125
125
|
end
|
126
126
|
|
127
127
|
end
|
@@ -31,9 +31,11 @@ module Micronaut
|
|
31
31
|
example, exception = examples_with_exception.first, examples_with_exception.last
|
32
32
|
padding = ' '
|
33
33
|
output.puts "#{index.next}) #{example}"
|
34
|
-
|
35
|
-
output.puts "#{padding}#{
|
36
|
-
|
34
|
+
output.puts "#{padding}#{colorise(exception.message, exception).strip}\n\n"
|
35
|
+
output.puts "#{padding}failing statement: #{read_failed_line(exception.backtrace[4]).strip}"
|
36
|
+
format_backtrace(exception.backtrace).each do |backtrace_info|
|
37
|
+
output.puts grey("#{padding}# #{backtrace_info}")
|
38
|
+
end
|
37
39
|
output.puts
|
38
40
|
output.flush
|
39
41
|
end
|