@@ -8,7 +8,7 @@ def setup
8
8
@cleaner = Rails ::BacktraceCleaner . new
9
9
end
10
10
11
- test "should consider traces from irb lines as User code" do
11
+ test "#clean should consider traces from irb lines as User code" do
12
12
backtrace = [ "(irb):1" ,
13
13
"/Path/to/rails/railties/lib/rails/commands/console.rb:77:in `start'" ,
14
14
"bin/rails:4:in `<main>'" ]
@@ -17,7 +17,7 @@ def setup
17
17
assert_equal 1 , result . length
18
18
end
19
19
20
- test "should show relative paths" do
20
+ test "#clean should show relative paths" do
21
21
backtrace = [ "./test/backtrace_cleaner_test.rb:123" ,
22
22
"/Path/to/rails/activesupport/some_testing_file.rb:42:in `test'" ,
23
23
"bin/rails:4:in `<main>'" ]
@@ -26,7 +26,7 @@ def setup
26
26
assert_equal 1 , result . length
27
27
end
28
28
29
- test "can filter for noise" do
29
+ test "#clean can filter for noise" do
30
30
backtrace = [ "(irb):1" ,
31
31
"/Path/to/rails/railties/lib/rails/commands/console.rb:77:in `start'" ,
32
32
"bin/rails:4:in `<main>'" ]
@@ -36,10 +36,35 @@ def setup
36
36
assert_equal 2 , result . length
37
37
end
38
38
39
- test "should omit ActionView template methods names" do
39
+ test "#clean should omit ActionView template methods names" do
40
40
method_name = ActionView ::Template . new ( nil , "app/views/application/index.html.erb" , nil , locals : [ ] ) . send :method_name
41
41
backtrace = [ "app/views/application/index.html.erb:4:in `block in #{ method_name } '" ]
42
42
result = @cleaner . clean ( backtrace , :all )
43
43
assert_equal "app/views/application/index.html.erb:4" , result [ 0 ]
44
44
end
45
+
46
+ test "#clean_frame should consider traces from irb lines as User code" do
47
+ assert_equal "(irb):1" , @cleaner . clean_frame ( "(irb):1" )
48
+ assert_nil @cleaner . clean_frame ( "/Path/to/rails/railties/lib/rails/commands/console.rb:77:in `start'" )
49
+ assert_nil @cleaner . clean_frame ( "bin/rails:4:in `<main>'" )
50
+ end
51
+
52
+ test "#clean_frame should show relative paths" do
53
+ assert_equal "./test/backtrace_cleaner_test.rb:123" , @cleaner . clean_frame ( "./test/backtrace_cleaner_test.rb:123" )
54
+ assert_nil @cleaner . clean_frame ( "/Path/to/rails/railties/lib/rails/commands/console.rb:77:in `start'" )
55
+ assert_nil @cleaner . clean_frame ( "bin/rails:4:in `<main>'" )
56
+ end
57
+
58
+ test "#clean_frame can filter for noise" do
59
+ assert_nil @cleaner . clean_frame ( "(irb):1" , :noise )
60
+ frame = @cleaner . clean_frame ( "/Path/to/rails/railties/lib/rails/commands/console.rb:77:in `start'" , :noise )
61
+ assert_equal "/Path/to/rails/railties/lib/rails/commands/console.rb:77:in `start'" , frame
62
+ assert_equal "bin/rails:4:in `<main>'" , @cleaner . clean_frame ( "bin/rails:4:in `<main>'" , :noise )
63
+ end
64
+
65
+ test "#clean_frame should omit ActionView template methods names" do
66
+ method_name = ActionView ::Template . new ( nil , "app/views/application/index.html.erb" , nil , locals : [ ] ) . send :method_name
67
+ frame = @cleaner . clean_frame ( "app/views/application/index.html.erb:4:in `block in #{ method_name } '" , :all )
68
+ assert_equal "app/views/application/index.html.erb:4" , frame
69
+ end
45
70
end
0 commit comments