tablesalt 0.16.3 → 0.17.4

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: bb799d2a43652863d872f250e97cf36972bc919e8364b0ce600408c33025cbd3
4
- data.tar.gz: 969f43abe6f287d09c21e53fdce706a449414ac4dbb68b04f1bf69efb137a35c
3
+ metadata.gz: 89d9dfdedfe2cf7c0d30f0cd8b92fe9ff87dbbddaa7deae8c1a38d7dd5629858
4
+ data.tar.gz: bea38e74fbe8c63ff5d960e48d1e38032b8bc2aa9cb218f31e97c84bf0d88a5d
5
5
  SHA512:
6
- metadata.gz: 4964c1a7c329fa8c009fe607b6a0452d15e306bb72f0229f11add8dfd58d4b82225fb8fe5d73fdd43ad3127a2e89a684c499d82f03f5c74b6d7d913492aa46de
7
- data.tar.gz: 4cf065d716f9a161f2c133cb73905cafa025296db490a24ebd1fe5836d9573fbe45650482f96a7c6e6665932222ee05a0d5dae9530a3e090b6ed2b87df145ee7
6
+ metadata.gz: 5a3858a2ec7eb8d195407f87c6e0f76fddd4a37bf1cfd27bf79e77b3afe9cde278432916cb3d6fa0d36b6e67c12f64fa5bb9e3d5b790d8a64a47ffad59faa586
7
+ data.tar.gz: 1ff9c1a7db57a515993fa6bd465d354d53e5500f5408656ba794bf09cb7e755c0bd09d7cd36d57c5be7a9b3eede72310bbd13287551cff26ce35cae5de997b2f
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/concern"
4
+ require "active_support/core_ext/module/delegation"
5
+
6
+ module Tablesalt
7
+ module Isolation
8
+ extend ActiveSupport::Concern
9
+
10
+ included do
11
+ delegate :isolate, to: :class
12
+ end
13
+
14
+ module ClassMethods
15
+ # Dupes an item if possible. Classes/modules can have unpredictable effects when duped, so they are not.
16
+ def isolate(obj)
17
+ return obj if obj.is_a?(Module)
18
+
19
+ obj.clone
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # RSpec matcher that tests usage of `.argument`
4
+ #
5
+ # class Example
6
+ # include Tablesalt::Isolation
7
+ #
8
+ # THIS_IS_A_CONSTANT = isolate("this is a string").freeze
9
+ # ANOTHER_CONSTANT = isolate ThisIsAClass
10
+ # end
11
+ #
12
+ # RSpec.describe Example do
13
+ # describe "THIS_IS_A_CONSTANT" do
14
+ # subject { described_class::THIS_IS_A_CONSTANT }
15
+ #
16
+ # it { is_expected.to isolate "this is a string" }
17
+ # end
18
+ #
19
+ # describe "ANOTHER_CONSTANT" do
20
+ # subject { described_class::ANOTHER_CONSTANT }
21
+ #
22
+ # it { is_expected.to isolate ThisIsAClass }
23
+ # end
24
+ # end
25
+
26
+ RSpec::Matchers.define :isolate do |argument|
27
+ match do |isolated|
28
+ expect(isolated.frozen?).to eq argument.frozen?
29
+
30
+ if argument.is_a?(Module)
31
+ expect(argument).to equal isolated
32
+ else
33
+ expect(argument).to eq isolated
34
+ expect(argument).not_to equal isolated
35
+ end
36
+ end
37
+
38
+ description { "isolate argument #{argument}" }
39
+ failure_message do
40
+ "expected #{argument} to be isolated"
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "custom_matchers/isolate"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rspec/custom_matchers"
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Tablesalt
4
4
  # This constant is managed by spicerack
5
- VERSION = "0.16.3"
5
+ VERSION = "0.17.4"
6
6
  end
data/lib/tablesalt.rb CHANGED
@@ -6,6 +6,7 @@ require "short_circu_it"
6
6
  require "tablesalt/version"
7
7
 
8
8
  require "tablesalt/dsl_accessor"
9
+ require "tablesalt/isolation"
9
10
  require "tablesalt/stringable_object"
10
11
  require "tablesalt/uses_hash_for_equality"
11
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tablesalt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.3
4
+ version: 0.17.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Minneti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-19 00:00:00.000000000 Z
11
+ date: 2019-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -50,6 +50,10 @@ files:
50
50
  - README.md
51
51
  - lib/tablesalt.rb
52
52
  - lib/tablesalt/dsl_accessor.rb
53
+ - lib/tablesalt/isolation.rb
54
+ - lib/tablesalt/rspec/custom_matchers.rb
55
+ - lib/tablesalt/rspec/custom_matchers/isolate.rb
56
+ - lib/tablesalt/spec_helper.rb
53
57
  - lib/tablesalt/stringable_object.rb
54
58
  - lib/tablesalt/uses_hash_for_equality.rb
55
59
  - lib/tablesalt/version.rb
@@ -75,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
79
  - !ruby/object:Gem::Version
76
80
  version: '0'
77
81
  requirements: []
78
- rubygems_version: 3.0.3
82
+ rubygems_version: 3.0.6
79
83
  signing_key:
80
84
  specification_version: 4
81
85
  summary: Miscellaneous helper modules, POROs, and more, that standardize common behavior