remockable 0.3.9 → 0.3.10

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: 4ffc2a8134d4c752ce38d77cec8e266d50ea9f0f14d4d68c039d54983a25786e
4
- data.tar.gz: 695c352b12e802ba5f175dea7bed983ef7051323d11157e52b58924172e8ae4f
3
+ metadata.gz: 5492de95e8e21114d1b6e9561bf73137b943dfabcffe4308ad201d92e966405e
4
+ data.tar.gz: ae94c8bfe61f44b63b85812f3d92527f90fd6f28787e4aa21dbbb549bf6cfee9
5
5
  SHA512:
6
- metadata.gz: 61b0cb9dde668204f1dd5a150e24f299030f3049fb4218bae92c494ea8fb5843740cca45ee65dec6833841c5303b40ba44dfef632da7c60d060c1c4021ae2422
7
- data.tar.gz: bae3c12a4724a77e40c99e3fbc9cc5cb4ad46132d2a7a2071349f8e44c188904679ef8594988cfa7271d27c371402e5dc9856ec1d4a479d7408f6d421bbc43a4
6
+ metadata.gz: 6acbc06082392f6ca96362bd9082215fd0fdf38eff2f745bcd44faf09245ce18252e7fbf47643b19d7dd0223a9c3700c7d2f16c493f23df9a24d3f11a738d3fe
7
+ data.tar.gz: 24325ec462e5250420f8f6b6f1dda50044c36577dfdc48690560b79651c54d96ec9385e853d1b51eea05ab585712564eae18fb3016cd03b7228ce49dd1a1f24c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.10 (2024-02-08)
4
+
5
+ * Support symbol values for `:reject_if` option on
6
+ `accept_nested_attributes_for` ([Tyler Hunt][tylerhunt])
7
+
3
8
  ## 0.3.9 (2022-05-04)
4
9
 
5
10
  * Allow `:required`/`:optional` aliases with `belongs_to`
@@ -30,18 +30,18 @@ GEM
30
30
  thor (>= 0.14.0)
31
31
  arel (6.0.4)
32
32
  builder (3.2.4)
33
- concurrent-ruby (1.1.7)
33
+ concurrent-ruby (1.1.10)
34
34
  diff-lcs (1.5.0)
35
35
  i18n (0.9.5)
36
36
  concurrent-ruby (~> 1.0)
37
- minitest (5.14.3)
37
+ minitest (5.15.0)
38
38
  rake (13.0.3)
39
39
  rspec-core (3.11.0)
40
40
  rspec-support (~> 3.11.0)
41
41
  rspec-expectations (3.11.0)
42
42
  diff-lcs (>= 1.2.0, < 2.0)
43
43
  rspec-support (~> 3.11.0)
44
- rspec-mocks (3.11.0)
44
+ rspec-mocks (3.11.1)
45
45
  diff-lcs (>= 1.2.0, < 2.0)
46
46
  rspec-support (~> 3.11.0)
47
47
  rspec-support (3.11.0)
@@ -28,18 +28,18 @@ GEM
28
28
  rake
29
29
  thor (>= 0.14.0)
30
30
  arel (7.1.4)
31
- concurrent-ruby (1.1.7)
31
+ concurrent-ruby (1.1.10)
32
32
  diff-lcs (1.5.0)
33
- i18n (1.8.7)
33
+ i18n (1.10.0)
34
34
  concurrent-ruby (~> 1.0)
35
- minitest (5.14.3)
35
+ minitest (5.15.0)
36
36
  rake (13.0.3)
37
37
  rspec-core (3.11.0)
38
38
  rspec-support (~> 3.11.0)
39
39
  rspec-expectations (3.11.0)
40
40
  diff-lcs (>= 1.2.0, < 2.0)
41
41
  rspec-support (~> 3.11.0)
42
- rspec-mocks (3.11.0)
42
+ rspec-mocks (3.11.1)
43
43
  diff-lcs (>= 1.2.0, < 2.0)
44
44
  rspec-support (~> 3.11.0)
45
45
  rspec-support (3.11.0)
@@ -28,18 +28,18 @@ GEM
28
28
  rake
29
29
  thor (>= 0.14.0)
30
30
  arel (8.0.0)
31
- concurrent-ruby (1.1.7)
31
+ concurrent-ruby (1.1.10)
32
32
  diff-lcs (1.5.0)
33
- i18n (1.8.7)
33
+ i18n (1.10.0)
34
34
  concurrent-ruby (~> 1.0)
35
- minitest (5.14.3)
35
+ minitest (5.15.0)
36
36
  rake (13.0.3)
37
37
  rspec-core (3.11.0)
38
38
  rspec-support (~> 3.11.0)
39
39
  rspec-expectations (3.11.0)
40
40
  diff-lcs (>= 1.2.0, < 2.0)
41
41
  rspec-support (~> 3.11.0)
42
- rspec-mocks (3.11.0)
42
+ rspec-mocks (3.11.1)
43
43
  diff-lcs (>= 1.2.0, < 2.0)
44
44
  rspec-support (~> 3.11.0)
45
45
  rspec-support (3.11.0)
@@ -12,13 +12,13 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activemodel (5.2.4.4)
16
- activesupport (= 5.2.4.4)
17
- activerecord (5.2.4.4)
18
- activemodel (= 5.2.4.4)
19
- activesupport (= 5.2.4.4)
15
+ activemodel (5.2.7.1)
16
+ activesupport (= 5.2.7.1)
17
+ activerecord (5.2.7.1)
18
+ activemodel (= 5.2.7.1)
19
+ activesupport (= 5.2.7.1)
20
20
  arel (>= 9.0)
21
- activesupport (5.2.4.4)
21
+ activesupport (5.2.7.1)
22
22
  concurrent-ruby (~> 1.0, >= 1.0.2)
23
23
  i18n (>= 0.7, < 2)
24
24
  minitest (~> 5.1)
@@ -28,18 +28,18 @@ GEM
28
28
  rake
29
29
  thor (>= 0.14.0)
30
30
  arel (9.0.0)
31
- concurrent-ruby (1.1.7)
31
+ concurrent-ruby (1.1.10)
32
32
  diff-lcs (1.5.0)
33
- i18n (1.8.7)
33
+ i18n (1.10.0)
34
34
  concurrent-ruby (~> 1.0)
35
- minitest (5.14.3)
35
+ minitest (5.15.0)
36
36
  rake (13.0.3)
37
37
  rspec-core (3.11.0)
38
38
  rspec-support (~> 3.11.0)
39
39
  rspec-expectations (3.11.0)
40
40
  diff-lcs (>= 1.2.0, < 2.0)
41
41
  rspec-support (~> 3.11.0)
42
- rspec-mocks (3.11.0)
42
+ rspec-mocks (3.11.1)
43
43
  diff-lcs (>= 1.2.0, < 2.0)
44
44
  rspec-support (~> 3.11.0)
45
45
  rspec-support (3.11.0)
@@ -12,12 +12,12 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activemodel (6.0.3.4)
16
- activesupport (= 6.0.3.4)
17
- activerecord (6.0.3.4)
18
- activemodel (= 6.0.3.4)
19
- activesupport (= 6.0.3.4)
20
- activesupport (6.0.3.4)
15
+ activemodel (6.0.4.8)
16
+ activesupport (= 6.0.4.8)
17
+ activerecord (6.0.4.8)
18
+ activemodel (= 6.0.4.8)
19
+ activesupport (= 6.0.4.8)
20
+ activesupport (6.0.4.8)
21
21
  concurrent-ruby (~> 1.0, >= 1.0.2)
22
22
  i18n (>= 0.7, < 2)
23
23
  minitest (~> 5.1)
@@ -27,18 +27,18 @@ GEM
27
27
  bundler
28
28
  rake
29
29
  thor (>= 0.14.0)
30
- concurrent-ruby (1.1.7)
30
+ concurrent-ruby (1.1.10)
31
31
  diff-lcs (1.5.0)
32
- i18n (1.8.7)
32
+ i18n (1.10.0)
33
33
  concurrent-ruby (~> 1.0)
34
- minitest (5.14.3)
34
+ minitest (5.15.0)
35
35
  rake (13.0.3)
36
36
  rspec-core (3.11.0)
37
37
  rspec-support (~> 3.11.0)
38
38
  rspec-expectations (3.11.0)
39
39
  diff-lcs (>= 1.2.0, < 2.0)
40
40
  rspec-support (~> 3.11.0)
41
- rspec-mocks (3.11.0)
41
+ rspec-mocks (3.11.1)
42
42
  diff-lcs (>= 1.2.0, < 2.0)
43
43
  rspec-support (~> 3.11.0)
44
44
  rspec-support (3.11.0)
@@ -47,7 +47,7 @@ GEM
47
47
  thread_safe (0.3.6)
48
48
  tzinfo (1.2.9)
49
49
  thread_safe (~> 0.1)
50
- zeitwerk (2.4.2)
50
+ zeitwerk (2.5.4)
51
51
 
52
52
  PLATFORMS
53
53
  ruby
@@ -12,12 +12,12 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activemodel (6.1.1)
16
- activesupport (= 6.1.1)
17
- activerecord (6.1.1)
18
- activemodel (= 6.1.1)
19
- activesupport (= 6.1.1)
20
- activesupport (6.1.1)
15
+ activemodel (6.1.5.1)
16
+ activesupport (= 6.1.5.1)
17
+ activerecord (6.1.5.1)
18
+ activemodel (= 6.1.5.1)
19
+ activesupport (= 6.1.5.1)
20
+ activesupport (6.1.5.1)
21
21
  concurrent-ruby (~> 1.0, >= 1.0.2)
22
22
  i18n (>= 1.6, < 2)
23
23
  minitest (>= 5.1)
@@ -27,18 +27,18 @@ GEM
27
27
  bundler
28
28
  rake
29
29
  thor (>= 0.14.0)
30
- concurrent-ruby (1.1.7)
30
+ concurrent-ruby (1.1.10)
31
31
  diff-lcs (1.5.0)
32
- i18n (1.8.7)
32
+ i18n (1.10.0)
33
33
  concurrent-ruby (~> 1.0)
34
- minitest (5.14.3)
34
+ minitest (5.15.0)
35
35
  rake (13.0.3)
36
36
  rspec-core (3.11.0)
37
37
  rspec-support (~> 3.11.0)
38
38
  rspec-expectations (3.11.0)
39
39
  diff-lcs (>= 1.2.0, < 2.0)
40
40
  rspec-support (~> 3.11.0)
41
- rspec-mocks (3.11.0)
41
+ rspec-mocks (3.11.1)
42
42
  diff-lcs (>= 1.2.0, < 2.0)
43
43
  rspec-support (~> 3.11.0)
44
44
  rspec-support (3.11.0)
@@ -46,7 +46,7 @@ GEM
46
46
  thor (1.0.1)
47
47
  tzinfo (2.0.4)
48
48
  concurrent-ruby (~> 1.0)
49
- zeitwerk (2.4.2)
49
+ zeitwerk (2.5.4)
50
50
 
51
51
  PLATFORMS
52
52
  ruby
@@ -1,12 +1,32 @@
1
+ all_blank_proc =
2
+ ActiveRecord::NestedAttributes::ClassMethods::REJECT_ALL_BLANK_PROC
3
+
1
4
  RSpec::Matchers.define(:accept_nested_attributes_for) do
2
5
  include Remockable::ActiveRecord::Helpers
3
6
 
4
- unsupported_options %w(reject_if)
5
- valid_options %w(allow_destroy limit update_only)
7
+ valid_options %w(allow_destroy limit reject_if update_only)
6
8
 
7
9
  match do |actual|
8
10
  if actual_options = subject.class.nested_attributes_options[attribute]
9
- actual_options.slice(*options.keys) == options
11
+ options_without_reject_if = options.except(:reject_if)
12
+
13
+ reject_if_matches =
14
+ case options[:reject_if]
15
+ when :all_blank
16
+ all_blank_proc == actual_options[:reject_if]
17
+ when Symbol
18
+ options[:reject_if] == actual_options[:reject_if]
19
+ when nil
20
+ true
21
+ else
22
+ raise ArgumentError, 'cannot compare proc values for :reject_if'
23
+ end
24
+
25
+ other_options_match =
26
+ actual_options.slice(*options_without_reject_if.keys) ==
27
+ options_without_reject_if
28
+
29
+ reject_if_matches && other_options_match
10
30
  end
11
31
  end
12
32
 
@@ -1,3 +1,3 @@
1
1
  module Remockable
2
- VERSION = '0.3.9'
2
+ VERSION = '0.3.10'
3
3
  end
@@ -44,8 +44,11 @@ describe :accept_nested_attributes_for do
44
44
 
45
45
  with_option :allow_destroy, true, false
46
46
  with_option :limit, 1, 2
47
- with_option :update_only, true, false
48
47
 
49
- with_unsupported_option :reject_if, :all_blank
48
+ with_option :reject_if, :all_blank, :all_empty do
49
+ raise_on_invalid_value -> {}, /cannot compare proc values/
50
+ end
51
+
52
+ with_option :update_only, true, false
50
53
  end
51
54
  end
@@ -12,10 +12,14 @@ shared_examples_for 'an Active Record matcher' do
12
12
  positive,
13
13
  negative,
14
14
  context={},
15
- macro_option={ option_name => positive }
15
+ macro_option=nil,
16
+ &block
16
17
  )
17
18
  context "with option #{option_name.inspect}" do
18
- let(:options) { context.merge(macro_option) }
19
+ let(:option_name) { option_name }
20
+ let(:value) { positive }
21
+
22
+ let(:options) { context.merge(macro_option || { option_name => value }) }
19
23
 
20
24
  before do
21
25
  model.send macro, :company, **options
@@ -28,6 +32,21 @@ shared_examples_for 'an Active Record matcher' do
28
32
  it 'does not match if the options do not match' do
29
33
  should_not send(matcher_name, :company, option_name => negative)
30
34
  end
35
+
36
+ instance_exec &block if block_given?
37
+ end
38
+ end
39
+
40
+ def self.raise_on_invalid_value(value, error_message)
41
+ value_description = value.is_a?(Proc) ? 'proc' : value.inspect
42
+
43
+ context "with #{value_description} value" do
44
+ let(:value) { value }
45
+
46
+ it 'raises an error' do
47
+ expect { should send(matcher_name, :company, option_name => value) }
48
+ .to raise_error ArgumentError, error_message
49
+ end
31
50
  end
32
51
  end
33
52
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remockable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Hunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-05 00:00:00.000000000 Z
11
+ date: 2024-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -253,7 +253,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
253
  - !ruby/object:Gem::Version
254
254
  version: '0'
255
255
  requirements: []
256
- rubygems_version: 3.3.6
256
+ rubyforge_project:
257
+ rubygems_version: 2.7.6.3
257
258
  signing_key:
258
259
  specification_version: 4
259
260
  summary: A collection of RSpec matchers for web apps.