fuli_the_guard 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/fuli_spec.rb ADDED
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe(Fuli) do
6
+ let!(:logger_mock) { double("Mocked.logger").as_null_object }
7
+ let(:warn_proc) { proc { |error, message| } }
8
+ let(:error_proc) { proc { |error, message| } }
9
+
10
+ before do
11
+ allow(logger_mock).to receive(:warn).and_return(true)
12
+ allow(logger_mock).to receive(:error).and_return(true)
13
+ end
14
+
15
+ let!(:config) do
16
+ Fuli.configure do |config|
17
+ config.logger = logger_mock
18
+ config.warn_notifiers = [warn_proc]
19
+ config.error_notifiers = [error_proc]
20
+ end
21
+ end
22
+
23
+ describe '.notify_warning' do
24
+ let(:error) { StandardError.new('Error message') }
25
+ let(:message) { 'More specific message' }
26
+
27
+ after { Fuli.notify_warning(error, message) }
28
+
29
+ it 'calls logger with correct level' do
30
+ expect(logger_mock).to receive(:warn)
31
+ end
32
+
33
+ it 'calls warn notifiers' do
34
+ expect(warn_proc).to receive(:call).with(error, message)
35
+ end
36
+ end
37
+
38
+ describe '.notify_error' do
39
+ let(:error) { StandardError.new('Error message') }
40
+ let(:message) { 'More specific message' }
41
+
42
+ after { Fuli.notify_error(error, message) }
43
+
44
+ it 'calls logger with correct level' do
45
+ expect(logger_mock).to receive(:error)
46
+ end
47
+
48
+ it 'calls warn notifiers' do
49
+ expect(error_proc).to receive(:call).with(error, message)
50
+ end
51
+ end
52
+
53
+ context 'when no logger defined' do
54
+ it 'raises error' do
55
+ expect { Fuli.configure { |c| c.logger = nil } }.to raise_error(Fuli::Error)
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec'
4
+ require 'fuli'
5
+ require 'fuli/config'
6
+ require 'pry'
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fuli_the_guard
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anton Magids
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-07-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Respond to application errors with configurable notifiers.
14
+ email:
15
+ - evnomadx@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - Gemfile
22
+ - Gemfile.lock
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - fuli.gemspec
27
+ - lib/fuli.rb
28
+ - lib/fuli/config.rb
29
+ - lib/fuli/version.rb
30
+ - rubocop.yml
31
+ - spec/fuli_spec.rb
32
+ - spec/spec_helper.rb
33
+ homepage: https://github.com/restaurant-cheetah/fuli
34
+ licenses:
35
+ - MIT
36
+ metadata: {}
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 2.7.9
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: Respond to application errors with configurable notifiers.
57
+ test_files:
58
+ - spec/fuli_spec.rb
59
+ - spec/spec_helper.rb