rspice 0.13.0 → 0.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/rspice/shared_examples.rb +1 -0
- data/lib/rspice/shared_examples/a_handler_for_the_callback.rb +50 -0
- data/lib/rspice/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35137f9f1bd9affd5ded00827e43d78aab1f9fa43359d09c0bd21c2ba65079a3
|
4
|
+
data.tar.gz: 6992920c96bf9d2c19422d5d286cc014e19ebd93a9c7f1cf61b223ad24070ba1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f0cf117647b5ae3a1be0feac38d0007431b7dbc87cb8a341c97995be231eb51b1d8d915cc69421517ea8bf9497e9c356433ee95639403b226258ca3a4206029
|
7
|
+
data.tar.gz: 87585abd994be193d0f5c6a61fda560e48152be01cf7ccd8022becaf89a666934bc5160afc44fa51da59738076afea3c928d190633c9a9a869899cca04ecb771
|
data/README.md
CHANGED
@@ -61,6 +61,7 @@ require 'rspice'
|
|
61
61
|
|
62
62
|
* [a_class_pass_method](lib/rspice/shared_examples/a_class_pass_method.rb) tests class methods which take arguments that instantiate and call instance method of the same name
|
63
63
|
* [a_class_with_callback](lib/rspice/shared_examples/a_class_with_callback.rb) tests usage of [ActiveSupport::Callbacks](https://apidock.com/rails/ActiveSupport/Callbacks)
|
64
|
+
* [a_handler_for_the_callback](lib/rspice/shared_examples/a_handler_for_the_callback.rb) tests [ActiveSupport::Callbacks](https://apidock.com/rails/ActiveSupport/Callbacks) handler methods
|
64
65
|
* [an_example_class_with_callbacks](lib/rspice/shared_examples/an_example_class_with_callbacks.rb) tests for defined [ActiveSupport::Callbacks](https://apidock.com/rails/ActiveSupport/Callbacks)
|
65
66
|
* [an_inherited_property](lib/rspice/shared_examples/an_inherited_property.rb) tests usages of inherited [Class.class_attributes](https://apidock.com/rails/Class/class_attribute)
|
66
67
|
* [an_instrumented_event](lib/rspice/shared_examples/an_instrumented_event.rb) tests usage of [ActiveSupport::Notification](https://apidock.com/rails/ActiveSupport/Notifications)
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "rspice/shared_examples/a_class_pass_method"
|
4
4
|
require "rspice/shared_examples/a_class_with_callback"
|
5
|
+
require "rspice/shared_examples/a_handler_for_the_callback"
|
5
6
|
require "rspice/shared_examples/an_example_class_with_callbacks"
|
6
7
|
require "rspice/shared_examples/an_inherited_property"
|
7
8
|
require "rspice/shared_examples/an_instrumented_event"
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# RSpec example that tests [ActiveSupport::Callbacks](https://apidock.com/rails/ActiveSupport/Callbacks) handler methods
|
4
|
+
#
|
5
|
+
# class Klass
|
6
|
+
# include ActiveSupport::Callbacks
|
7
|
+
#
|
8
|
+
# define_callback :kallback
|
9
|
+
#
|
10
|
+
# def self.on_kallback(&block)
|
11
|
+
# set_callback(:kallback, :after, &block)
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# def self.before_kallback(&block)
|
15
|
+
# set_callback(:kallback, :before, &block)
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# RSpec.describe Klass do
|
20
|
+
# include_context "with example class having callback", :kallback
|
21
|
+
#
|
22
|
+
# subject(:instance) { Class.new(described_class).new }
|
23
|
+
#
|
24
|
+
# it_behaves_like "a handler for the callback" do
|
25
|
+
# let(:callback) { :kallback }
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# it_behaves_like "a handler for the callback" do
|
29
|
+
# let(:callback) { :kallback }
|
30
|
+
# let(:method) { :before_kallback }
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
|
34
|
+
RSpec.shared_examples_for "a handler for the callback" do
|
35
|
+
subject(:run) { instance.run_callbacks(callback) }
|
36
|
+
|
37
|
+
let(:method) { "on_#{callback}".to_sym }
|
38
|
+
|
39
|
+
let(:instance) { test_class.new }
|
40
|
+
let(:test_class) do
|
41
|
+
Class.new(example_class).tap do |klass|
|
42
|
+
klass.attr_accessor(:event_hook_run)
|
43
|
+
klass.public_send(method) { self.event_hook_run = true }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it "runs callback" do
|
48
|
+
expect { run }.to change { instance.event_hook_run }.from(nil).to(true)
|
49
|
+
end
|
50
|
+
end
|
data/lib/rspice/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Garside
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/rspice/shared_examples.rb
|
68
68
|
- lib/rspice/shared_examples/a_class_pass_method.rb
|
69
69
|
- lib/rspice/shared_examples/a_class_with_callback.rb
|
70
|
+
- lib/rspice/shared_examples/a_handler_for_the_callback.rb
|
70
71
|
- lib/rspice/shared_examples/an_example_class_with_callbacks.rb
|
71
72
|
- lib/rspice/shared_examples/an_inherited_property.rb
|
72
73
|
- lib/rspice/shared_examples/an_instrumented_event.rb
|