spicycode-micronaut 0.1.5 → 0.1.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
3
3
  require 'rubygems/specification'
4
4
 
5
5
  GEM = "micronaut"
6
- GEM_VERSION = "0.1.5"
6
+ GEM_VERSION = "0.1.5.2"
7
7
  AUTHOR = "Chad Humphries"
8
8
  EMAIL = "chad@spicycode.com"
9
9
  HOMEPAGE = "http://spicycode.com"
@@ -100,8 +100,20 @@ describe Micronaut::Formatters::BaseFormatter do
100
100
  @formatter.should have_interface_for(:dump_pending).with(0).arguments
101
101
  end
102
102
 
103
- it "should have close as an interface with zero arguments" do
103
+ it "should have close as an interface with zero arguments" do
104
104
  @formatter.should have_interface_for(:close).with(0).arguments
105
105
  end
106
106
 
107
+ describe 'dealing with backtrace' do
108
+
109
+ it "should ensure ':' in the first backtrace" do
110
+ backtrace = ["/tmp/x.rb:1", "/tmp/x.rb:2", "/tmp/x.rb:3"]
111
+ @formatter.format_backtrace(backtrace).should == backtrace
112
+
113
+ backtrace = ["/tmp/x.rb:1: message", "/tmp/x.rb:2", "/tmp/x.rb:3"]
114
+ @formatter.format_backtrace(backtrace).first.should == "/tmp/x.rb:1: message"
115
+ end
116
+
117
+ end
118
+
107
119
  end
@@ -57,12 +57,4 @@ describe Micronaut::Formatters::ProgressFormatter do
57
57
  @output.string.should == ""
58
58
  end
59
59
 
60
- it "should ensure ':' in the first backtrace" do
61
- backtrace = ["/tmp/x.rb:1", "/tmp/x.rb:2", "/tmp/x.rb:3"]
62
- @formatter.format_backtrace(backtrace).should == backtrace
63
-
64
- backtrace = ["/tmp/x.rb:1: message", "/tmp/x.rb:2", "/tmp/x.rb:3"]
65
- @formatter.format_backtrace(backtrace).first.should == "/tmp/x.rb:1: message"
66
- end
67
-
68
60
  end
@@ -67,7 +67,8 @@ module Micronaut
67
67
  metadata[:described_type] = args.first.is_a?(String) ? self.superclass.described_type : args.shift
68
68
  metadata[:description] = args.shift || ''
69
69
  metadata[:name] = "#{metadata[:described_type]} #{metadata[:description]}".strip
70
-
70
+ metadata[:describe_block] = metadata[:options].delete(:describe_block)
71
+ metadata[:file_path] = eval("caller(0)[0]", metadata[:describe_block].binding)
71
72
  Micronaut.configuration.find_modules(self).each do |include_or_extend, mod, opts|
72
73
  if include_or_extend == :extend
73
74
  send(:extend, mod) unless extended_modules.include?(mod)
@@ -100,6 +101,8 @@ module Micronaut
100
101
  def self.describe(*args, &describe_block)
101
102
  raise ArgumentError if args.empty? || describe_block.nil?
102
103
  subclass('NestedLevel') do
104
+ args << {} unless args.last.is_a?(Hash)
105
+ args.last.update(:describe_block => describe_block)
103
106
  set_it_up(*args)
104
107
  module_eval(&describe_block)
105
108
  end
@@ -104,9 +104,15 @@ module Micronaut
104
104
  def close
105
105
  end
106
106
 
107
- def format_backtrace(backtrace)
107
+ def format_backtrace(backtrace, example)
108
108
  return "" if backtrace.nil?
109
109
  cleansed = backtrace.map { |line| backtrace_line(line) }.compact
110
+ original_file = example.behaviour.metadata[:file_path].split(':').first.strip
111
+ # cleansed = cleansed.select do |line|
112
+ # line.split(':').first.downcase == original_file.downcase
113
+ # end
114
+ # we really just want it to remove the last line if there are more than 1 lines, as it is always
115
+ # junk
110
116
  cleansed.empty? ? backtrace : cleansed
111
117
  end
112
118
 
@@ -119,8 +125,14 @@ module Micronaut
119
125
  line
120
126
  end
121
127
 
122
- def read_failed_line(file_path_with_line_number)
123
- file_path, line_number = file_path_with_line_number.split(':')
128
+ def read_failed_line(exception, example)
129
+ original_file = example.options[:caller].split(':').first.strip
130
+ matching_line = exception.backtrace.find do |line|
131
+ line.split(':').first.downcase == original_file.downcase
132
+ end
133
+ return "Unable to find matching line from backtrace" if matching_line.nil?
134
+
135
+ file_path, line_number = matching_line.split(':')
124
136
  open(file_path, 'r') { |f| f.readlines[line_number.to_i - 1] }
125
137
  end
126
138
 
@@ -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
- 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|
34
+ output.puts "#{padding}Failure/Error: #{read_failed_line(exception, example).strip}"
35
+ exception.message.split("\n").each do |line|
36
+ output.puts "#{padding}#{colorise(line, exception).strip}"
37
+ end
38
+ format_backtrace(exception.backtrace, example).each do |backtrace_info|
37
39
  output.puts grey("#{padding}# #{backtrace_info}")
38
40
  end
39
41
  output.puts
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spicycode-micronaut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Humphries
@@ -9,7 +9,7 @@ autorequire: micronaut
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-20 00:00:00 -08:00
12
+ date: 2008-12-22 00:00:00 -08:00
13
13
  default_executable: micronaut
14
14
  dependencies: []
15
15