hub_kernel 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b68695ef96166801769081d8d607907cc32e6d215f798b6404dc8b13a1faab2
4
- data.tar.gz: 2fb12e7fa8b2cf1e8246eea5204ae7b38f61c6b41e668e07c753e7f55f899bf1
3
+ metadata.gz: 8117d21e5e81d6489c16ee5315f636623eafbab7aa0bc9ebe3e25b66fd139cef
4
+ data.tar.gz: 82f9add4dde24ed15db4be6b649f39b9e9c047292760479b8da9fc8891d72ff5
5
5
  SHA512:
6
- metadata.gz: 4cecfcff2e7565d73b3c047ff191cc57a1f1f73056727a644a82bcc6f07517678d370c8876abb7c6c97e10197d663d2f0fa046a1430939e38583a5e89dda7f7f
7
- data.tar.gz: 7a83ad99b5cc838650469b8e436d6a8a7f3d70e2ac37685206e1a1094f98c987dde0b29044b52dc5def44b2392e2b3eb045332819bbe160581c028c27ae7df36
6
+ metadata.gz: 7bc2bfa185995e9773224c2d5570e7f7c9d7ed520409524289a40da34132331dfc03546d4c74036f03bad13dfe5d586a9fceac389e00cef0d0ba6456eca0396d
7
+ data.tar.gz: 7f6465796e50d486e907c0d0d682ca97c1fb69dd0a264ba44d54bb99e133cc78d062b316b4771912d68ca41b7696ad87b78984997ca93acec24392a2ff27aa80
data/README.md CHANGED
@@ -44,6 +44,23 @@ It raises `HubKernel::UnwiredPortError` naming every unfilled port with its hub,
44
44
  line. Running it inside `to_prepare` checks again after every code reload, and a hub
45
45
  declared again on a reload stays on the list once.
46
46
 
47
+ ### The hub check
48
+ A hub's own test can check that the app filled every one of its ports, so a missing
49
+ fill shows in the suite rather than on the next start:
50
+
51
+ ```ruby
52
+ require "hub_kernel/conformance/hub"
53
+
54
+ class SuppliesHubTest < ActiveSupport::TestCase
55
+ include HubKernel::Conformance::Hub
56
+
57
+ hub { Supplies }
58
+ end
59
+ ```
60
+
61
+ The test fails and names each port the app left unfilled, and each port filled with
62
+ something that cannot be called.
63
+
47
64
  ## Installation
48
65
  Add this line to your application's Gemfile:
49
66
 
@@ -0,0 +1,22 @@
1
+ require "active_support/concern"
2
+
3
+ module HubKernel
4
+ module Conformance
5
+ module Hub
6
+ extend ActiveSupport::Concern
7
+
8
+ class_methods do
9
+ def hub(&block)
10
+ define_method(:the_hub, &block)
11
+ end
12
+ end
13
+
14
+ included do
15
+ test "every port of the hub is filled with something that can be called" do
16
+ problems = the_hub.unwired_ports + the_hub.uncallable_ports
17
+ flunk problems.join("\n") if problems.any?
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -17,6 +17,11 @@ module HubKernel
17
17
  declared_ports.reject { |name| instance_variable_get(:"@#{name}") }.map { |name| unwired_message(name) }
18
18
  end
19
19
 
20
+ def uncallable_ports
21
+ declared_ports.select { |name| instance_variable_get(:"@#{name}")&.respond_to?(:call) == false }
22
+ .map { |name| "#{hub_name} #{name.to_s.tr("_", " ")} is filled with something that cannot be called" }
23
+ end
24
+
20
25
  private
21
26
 
22
27
  def declared_ports = @declared_ports ||= []
@@ -1,3 +1,3 @@
1
1
  module HubKernel
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hub_kernel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
@@ -41,6 +41,7 @@ files:
41
41
  - lib/hub_kernel/answer.rb
42
42
  - lib/hub_kernel/authz.rb
43
43
  - lib/hub_kernel/conformance/action.rb
44
+ - lib/hub_kernel/conformance/hub.rb
44
45
  - lib/hub_kernel/conformance/partial.rb
45
46
  - lib/hub_kernel/context.rb
46
47
  - lib/hub_kernel/engine.rb