delegate_matcher 0.4.1 → 0.4.2

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
  SHA1:
3
- metadata.gz: 105eec3e18f2ea40bd320dd1d1f74950be80fae3
4
- data.tar.gz: f72c454e7faa63495c2a8938ba5ebd42772d600b
3
+ metadata.gz: 907400f6ff89ecfdf2e5b3d2be559badf3bd5732
4
+ data.tar.gz: 909ebfb8f6134e64fb9fd92166573da8ed41c69b
5
5
  SHA512:
6
- metadata.gz: 89947002c86c4f5986bdcadf6f55abca78cc2f2023f821725895bf891339c204fb569860c93ca43332b3b853ec141f7d59a8e0201baf16592d48dd86faab7cf6
7
- data.tar.gz: 53e80e2d40604ede3836dad8545ed58bb89c9cf8d845faf27915ef413146132a83f0a61a989a4099dc393495a61721335b2ed062aa844228bce34b7b33b9a147
6
+ metadata.gz: e8901ccdeb2ce0543a88c55ada12f76862eec14bbbac6c7854f0f25aa9ae7fe030930d70d4588e588edf1f3c199c10fdc48ebc22940c6394ee8597639bda7ef4
7
+ data.tar.gz: cae4cd06519c5c6983be8cc1fb694715d58a1eba8ad965f7a62a68f889048bd3fc004b5b2f69b99534514a1b14e075e428c163db21e33470533fe4fe51a420ac
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- delegate_matcher (0.4.1)
4
+ delegate_matcher (0.4.2)
5
5
  proc_extensions (~> 0.2)
6
6
 
7
7
  GEM
@@ -1,3 +1,3 @@
1
1
  module DelegateMatcher
2
- VERSION ||= '0.4.1'.freeze
2
+ VERSION ||= '0.4.2'.freeze
3
3
  end
@@ -4,34 +4,33 @@ module RSpec
4
4
  module Matchers
5
5
  module DelegateMatcher
6
6
  describe 'delegation to a class variable' do
7
- # Note that defining Post as an anonymous class caused the class variable @@author to not be available,
8
- # so we create an explicit Post class and remove it after all specs are run
9
- before(:all) do
10
- class Post
7
+ let(:klass) do
8
+ Class.new do
11
9
  include PostMethods
12
10
 
13
- # rubocop:disable Style/ClassVars
14
- @@author = Author.new
11
+ class_variable_set(:@@author, Author.new)
12
+
13
+ def author
14
+ self.class.class_variable_get(:@@author)
15
+ end
15
16
 
16
17
  def name
17
- @@author.name
18
+ author.name
18
19
  end
19
20
 
20
21
  def name_allow_nil
21
- @@author.name if @@author
22
+ author.name if author
22
23
  end
23
24
  end
24
25
  end
25
26
 
26
- subject { Post.new }
27
+ subject { klass.new }
27
28
 
28
29
  let(:receiver) { :@@author }
29
30
 
30
31
  it_behaves_like 'a basic delegator'
31
32
  it_behaves_like 'a delegator without a nil check'
32
33
  it_behaves_like 'a delegator with a nil check'
33
-
34
- after(:all) { DelegateMatcher.module_eval { remove_const :Post } }
35
34
  end
36
35
  end
37
36
  end
@@ -4,33 +4,33 @@ module RSpec
4
4
  module Matchers
5
5
  module DelegateMatcher
6
6
  describe 'class delegation' do
7
- # Note that defining Post as an anonymous class caused the constant AUTHOR to not be available,
8
- # so we create an explicit Post class and remove it after all specs are run
9
- before(:all) do
10
- class Post
7
+ let(:klass) do
8
+ Class.new do
11
9
  include PostMethods
12
10
 
13
- AUTHOR = Author.new
11
+ const_set(:AUTHOR, Author.new)
12
+
13
+ def author
14
+ self.class.const_get(:AUTHOR)
15
+ end
14
16
 
15
17
  def name
16
- AUTHOR.name
18
+ author.name
17
19
  end
18
20
 
19
21
  def name_allow_nil
20
- AUTHOR.name if AUTHOR
22
+ author.name if author
21
23
  end
22
24
  end
23
25
  end
24
26
 
25
- subject { Post.new }
27
+ subject { klass.new }
26
28
 
27
29
  let(:receiver) { :AUTHOR }
28
30
 
29
31
  it_behaves_like 'a basic delegator'
30
32
  it_behaves_like 'a delegator without a nil check'
31
33
  it_behaves_like 'a delegator with a nil check'
32
-
33
- after(:all) { DelegateMatcher.module_eval { remove_const :Post } }
34
34
  end
35
35
  end
36
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delegate_matcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Declan Whelan