spicycode-micronaut 0.1.6.9 → 0.1.6.9.1
Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile
CHANGED
@@ -59,6 +59,33 @@ describe Micronaut::Behaviour do
|
|
59
59
|
Micronaut::Behaviour.describe(Object, nil, 'foo' => 'bar') { }.metadata.should include({ "foo" => 'bar' })
|
60
60
|
end
|
61
61
|
|
62
|
+
it "should add the file_path_with_line_number of the current behaviour to metadata" do
|
63
|
+
Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:file_path_with_line_number].should == "#{__FILE__}:#{__LINE__}"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should add the the file_path of the current behaviour to metadata" do
|
67
|
+
Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:file_path].should == "#{__FILE__}"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should add a reader for file_path to the behaviour for easy access" do
|
71
|
+
Micronaut::Behaviour.describe(Object) { }.file_path.should == "#{__FILE__}"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should add the line_number of the current behavior to metadata" do
|
75
|
+
Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:line_number].should == __LINE__
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should add file path and line number metadata for arbitrarily nested describes" do
|
79
|
+
Micronaut::Behaviour.describe(Object) do
|
80
|
+
Micronaut::Behaviour.describe("foo") do
|
81
|
+
|
82
|
+
Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:file_path_with_line_number].should == "#{__FILE__}:#{__LINE__}"
|
83
|
+
Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:line_number].should == __LINE__
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
62
89
|
end
|
63
90
|
|
64
91
|
describe "adding before and after hooks" do
|
@@ -106,6 +106,12 @@ describe Micronaut::Formatters::BaseFormatter do
|
|
106
106
|
|
107
107
|
describe 'dealing with backtrace' do
|
108
108
|
|
109
|
+
it "should allow displaying the full backtrace with an option", :pending => true do
|
110
|
+
backtrace = ["/tmp/x.rb:1", "foo/vendor/rails/x.rb:1"]
|
111
|
+
result = @formatter.format_backtrace(backtrace, running_example)
|
112
|
+
result.should == backtrace
|
113
|
+
end
|
114
|
+
|
109
115
|
it "should ensure ':' in the first backtrace" do
|
110
116
|
backtrace = ["/tmp/x.rb:1", "/tmp/x.rb:2", "/tmp/x.rb:3"]
|
111
117
|
@formatter.format_backtrace(backtrace, running_example).should == backtrace
|
data/lib/micronaut.rb
CHANGED
@@ -8,6 +8,10 @@ require 'micronaut/example'
|
|
8
8
|
require 'micronaut/behaviour'
|
9
9
|
require 'micronaut/kernel_extensions'
|
10
10
|
require 'micronaut/formatters'
|
11
|
+
begin
|
12
|
+
require 'log_buddy'
|
13
|
+
LogBuddy.init
|
14
|
+
rescue nil; end
|
11
15
|
|
12
16
|
module Micronaut
|
13
17
|
file = if RUBY_VERSION =~ /^1\.9/ then # bt's expanded, but __FILE__ isn't :(
|
data/lib/micronaut/behaviour.rb
CHANGED
@@ -85,7 +85,10 @@ module Micronaut
|
|
85
85
|
@metadata[:behaviour][:description] = args.shift || ''
|
86
86
|
@metadata[:behaviour][:name] = "#{describes} #{description}".strip
|
87
87
|
@metadata[:behaviour][:block] = extra_metadata.delete(:behaviour_block)
|
88
|
-
|
88
|
+
file_path_with_line_num = eval("caller(0)[0]", @metadata[:behaviour][:block].binding)
|
89
|
+
@metadata[:behaviour][:file_path_with_line_number] = file_path_with_line_num
|
90
|
+
@metadata[:behaviour][:file_path] = file_path_with_line_num.split(":")[0].strip
|
91
|
+
@metadata[:behaviour][:line_number] = file_path_with_line_num.split(":")[1].to_i
|
89
92
|
|
90
93
|
extra_metadata.delete(:behaviour) # Remove it if it is present
|
91
94
|
@metadata.update(extra_metadata)
|
@@ -117,6 +120,10 @@ module Micronaut
|
|
117
120
|
def self.description
|
118
121
|
@metadata[:behaviour][:description]
|
119
122
|
end
|
123
|
+
|
124
|
+
def self.file_path
|
125
|
+
@metadata[:behaviour][:file_path]
|
126
|
+
end
|
120
127
|
|
121
128
|
def self.describe(*args, &behaviour_block)
|
122
129
|
raise(ArgumentError, "No arguments given. You must a least supply a type or description") if args.empty?
|
@@ -107,10 +107,9 @@ module Micronaut
|
|
107
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[:behaviour][:file_path].split(':').first.strip
|
111
110
|
|
112
111
|
cleansed = cleansed.select do |line|
|
113
|
-
line.split(':').first.downcase ==
|
112
|
+
line.split(':').first.downcase == example.behaviour.file_path.downcase
|
114
113
|
end
|
115
114
|
|
116
115
|
cleansed.empty? ? backtrace : cleansed
|
@@ -126,7 +125,7 @@ module Micronaut
|
|
126
125
|
end
|
127
126
|
|
128
127
|
def read_failed_line(exception, example)
|
129
|
-
original_file = example.
|
128
|
+
original_file = example.behaviour.file_path.downcase
|
130
129
|
matching_line = exception.backtrace.find do |line|
|
131
130
|
line.split(':').first.downcase == original_file.downcase
|
132
131
|
end
|
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.6.9
|
4
|
+
version: 0.1.6.9.1
|
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-
|
12
|
+
date: 2008-12-26 00:00:00 -08:00
|
13
13
|
default_executable: micronaut
|
14
14
|
dependencies: []
|
15
15
|
|