This repository was archived by the owner on Mar 11, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +69
-0
lines changed Expand file tree Collapse file tree 4 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 1
1
pkg
2
2
Gemfile.lock
3
+ .bundle
Original file line number Diff line number Diff line change 1
1
source 'https://rubygems.org'
2
2
gemspec
3
+
4
+ group :development do
5
+ gem 'minitest'
6
+ end
Original file line number Diff line number Diff line change 1
1
require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake ::TestTask . new do |t |
5
+ t . libs << "test"
6
+ t . test_files = FileList [ 'test/test_*.rb' , 'test/**/test_*.rb' ]
7
+ t . verbose = true
8
+ end
Original file line number Diff line number Diff line change
1
+ require 'minitest/autorun'
2
+
3
+ require 'active_support/core_ext/object' # provides .present? && constantize
4
+ require 'scrolls/rails/log_subscriber'
5
+
6
+ class FakeEvent
7
+ attr_accessor :payload
8
+ end
9
+
10
+ # mock Scrolls to something useful for this test
11
+ module Scrolls
12
+ class << self
13
+ def log_exception info , ex
14
+ @@info = info
15
+ @@ex = ex
16
+ end
17
+
18
+ def info
19
+ @@info
20
+ end
21
+
22
+ def exception
23
+ @@ex
24
+ end
25
+ end
26
+ end
27
+
28
+ class ScrollsRailsLogSubscriber < Minitest ::Test
29
+ def setup
30
+ @sub = Scrolls ::Rails ::LogSubscriber . new
31
+ @evt = FakeEvent . new
32
+ end
33
+
34
+ def test_process_action_with_array
35
+ @evt . payload = {
36
+ exception : [ 'Exception' , 'Test array' ]
37
+ }
38
+
39
+ @sub . process_action ( @evt )
40
+
41
+ assert_equal ( { status : 500 } , Scrolls . info )
42
+ assert_kind_of ( Exception , Scrolls . exception )
43
+ assert_equal ( 'Test array' , Scrolls . exception . message )
44
+ end
45
+
46
+ def test_process_action_with_exception
47
+ @evt . payload = {
48
+ exception : Exception . new ( 'Test exception' )
49
+ }
50
+
51
+ @sub . process_action ( @evt )
52
+
53
+ assert_equal ( { status : 500 } , Scrolls . info )
54
+ assert_kind_of ( Exception , Scrolls . exception )
55
+ assert_equal ( 'Test exception' , Scrolls . exception . message )
56
+ end
57
+ end
You can’t perform that action at this time.
0 commit comments