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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1085d58883b6b2bcb1769afd9a3e8e13795b3f07908eb8cb2dedd7f470ab7886
4
- data.tar.gz: 31abb0656dc169e0d0f6aeed3dd72e82b9e631282baa598f86cfd63a9ef8c676
3
+ metadata.gz: 35137f9f1bd9affd5ded00827e43d78aab1f9fa43359d09c0bd21c2ba65079a3
4
+ data.tar.gz: 6992920c96bf9d2c19422d5d286cc014e19ebd93a9c7f1cf61b223ad24070ba1
5
5
  SHA512:
6
- metadata.gz: 983116dfba530e73f3b0d5dd54811e2a20eb2519675a8514cf8a9d027e8eca4f10fb5dfb0ef06a858c3d002b82cc430eb61f0729f1aa7cfeed86961ebf9d2a47
7
- data.tar.gz: 0f4d562ef22ebe74b1fdc67b9c343d17366faa8eef0f78a2fd6f058898adb5990d125fcdccb83aeed2169248556108825c74c2139765ad4b8087050c7a469446
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Rspice
4
4
  # This constant is managed by spicerack
5
- VERSION = "0.13.0"
5
+ VERSION = "0.13.1"
6
6
  end
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.0
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