rspice 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rspice/shared_context/with_class_callbacks.rb +34 -0
- data/lib/rspice/shared_context.rb +1 -0
- data/lib/rspice/shared_examples.rb +0 -1
- data/lib/rspice/version.rb +1 -1
- metadata +3 -3
- data/lib/rspice/shared_examples/a_versioned_spicerack_gem.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1085d58883b6b2bcb1769afd9a3e8e13795b3f07908eb8cb2dedd7f470ab7886
|
4
|
+
data.tar.gz: 31abb0656dc169e0d0f6aeed3dd72e82b9e631282baa598f86cfd63a9ef8c676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 983116dfba530e73f3b0d5dd54811e2a20eb2519675a8514cf8a9d027e8eca4f10fb5dfb0ef06a858c3d002b82cc430eb61f0729f1aa7cfeed86961ebf9d2a47
|
7
|
+
data.tar.gz: 0f4d562ef22ebe74b1fdc67b9c343d17366faa8eef0f78a2fd6f058898adb5990d125fcdccb83aeed2169248556108825c74c2139765ad4b8087050c7a469446
|
data/README.md
CHANGED
@@ -54,13 +54,13 @@ require 'rspice'
|
|
54
54
|
|
55
55
|
* [with_an_example_descendant_class](lib/rspice/shared_context/with_an_example_descendant_class.rb) creates a named descendant of `described_class`
|
56
56
|
* [with_callbacks](lib/rspice/shared_context/with_callbacks.rb) defines callbacks for [ActiveSupport::Callbacks](https://apidock.com/rails/ActiveSupport/Callbacks)
|
57
|
+
* [with_class_callbacks](lib/rspice/shared_context/with_class_callbacks.rb) defines callbacks for [ActiveSupport::Callbacks](https://apidock.com/rails/ActiveSupport/Callbacks)
|
57
58
|
* [with_example_class_having_callback](lib/rspice/shared_context/with_example_class_having_callback.rb) creates a class with
|
58
59
|
|
59
60
|
## Shared Examples
|
60
61
|
|
61
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
|
62
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)
|
63
|
-
* [a_versioned_spicerack_gem](lib/rspice/shared_examples/a_versioned_spicerack_gem.rb) ensures gem compliance with internal standard of [Spicerack](https://github.com/Freshly/spicerack/)
|
64
64
|
* [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
65
|
* [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
66
|
* [an_instrumented_event](lib/rspice/shared_examples/an_instrumented_event.rb) tests usage of [ActiveSupport::Notification](https://apidock.com/rails/ActiveSupport/Notifications)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# RSpec context that defines callbacks for [ActiveSupport::Callbacks](https://apidock.com/rails/ActiveSupport/Callbacks)
|
4
|
+
#
|
5
|
+
# class Klass
|
6
|
+
# include ActiveSupport::Callbacks
|
7
|
+
# define_callbacks :kallback
|
8
|
+
#
|
9
|
+
# def call
|
10
|
+
# run_callbacks(:kallback)
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# RSpec.describe Klass do
|
15
|
+
# it_behaves_like "a class with callback" do
|
16
|
+
# include_context "with callbacks", :kallback
|
17
|
+
#
|
18
|
+
# subject(:callback_runner) { described_class.new.call }
|
19
|
+
#
|
20
|
+
# let(:example_class) { described_class }
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
|
24
|
+
RSpec.shared_context "with class callbacks" do |callback|
|
25
|
+
before do
|
26
|
+
example_class.class_eval { class << self; attr_accessor :before_hook_run, :around_hook_run, :after_hook_run; end }
|
27
|
+
example_class.set_callback(callback, :before) { |obj| obj.class.before_hook_run = true }
|
28
|
+
example_class.set_callback(callback, :after) { |obj| obj.class.after_hook_run = true }
|
29
|
+
example_class.set_callback callback, :around do |obj, block|
|
30
|
+
obj.class.around_hook_run = true
|
31
|
+
block.call
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -2,7 +2,6 @@
|
|
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_versioned_spicerack_gem"
|
6
5
|
require "rspice/shared_examples/an_example_class_with_callbacks"
|
7
6
|
require "rspice/shared_examples/an_inherited_property"
|
8
7
|
require "rspice/shared_examples/an_instrumented_event"
|
data/lib/rspice/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Garside
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -62,11 +62,11 @@ files:
|
|
62
62
|
- lib/rspice/shared_context.rb
|
63
63
|
- lib/rspice/shared_context/with_an_example_descendant_class.rb
|
64
64
|
- lib/rspice/shared_context/with_callbacks.rb
|
65
|
+
- lib/rspice/shared_context/with_class_callbacks.rb
|
65
66
|
- lib/rspice/shared_context/with_example_class_having_callback.rb
|
66
67
|
- lib/rspice/shared_examples.rb
|
67
68
|
- lib/rspice/shared_examples/a_class_pass_method.rb
|
68
69
|
- lib/rspice/shared_examples/a_class_with_callback.rb
|
69
|
-
- lib/rspice/shared_examples/a_versioned_spicerack_gem.rb
|
70
70
|
- lib/rspice/shared_examples/an_example_class_with_callbacks.rb
|
71
71
|
- lib/rspice/shared_examples/an_inherited_property.rb
|
72
72
|
- lib/rspice/shared_examples/an_instrumented_event.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# RSpec example that ensures gem compliance with internal standard of [Spicerack](https://github.com/Freshly/spicerack/)
|
4
|
-
#
|
5
|
-
# RSpice.describe MyAwesomeGem do
|
6
|
-
# it_behaves_like "a versioned spicerack gem"
|
7
|
-
# end
|
8
|
-
|
9
|
-
RSpec.shared_examples_for "a versioned spicerack gem" do
|
10
|
-
it "has a version number" do
|
11
|
-
expect(described_class::VERSION).to be_a String
|
12
|
-
expect(described_class::VERSION).not_to be_blank
|
13
|
-
expect(described_class::VERSION).to eq Spicerack::VERSION
|
14
|
-
end
|
15
|
-
end
|