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 +4 -4
- data/CHANGELOG.md +5 -0
- data/gemfiles/rails_4.2.gemfile.lock +3 -3
- data/gemfiles/rails_5.0.gemfile.lock +4 -4
- data/gemfiles/rails_5.1.gemfile.lock +4 -4
- data/gemfiles/rails_5.2.gemfile.lock +10 -10
- data/gemfiles/rails_6.0.gemfile.lock +11 -11
- data/gemfiles/rails_6.1.gemfile.lock +11 -11
- data/lib/remockable/active_record/accept_nested_attributes_for.rb +23 -3
- data/lib/remockable/version.rb +1 -1
- data/spec/active_record/accept_nested_attributes_for_spec.rb +5 -2
- data/spec/support/shared/an_active_record_matcher.rb +21 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5492de95e8e21114d1b6e9561bf73137b943dfabcffe4308ad201d92e966405e
|
4
|
+
data.tar.gz: ae94c8bfe61f44b63b85812f3d92527f90fd6f28787e4aa21dbbb549bf6cfee9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6acbc06082392f6ca96362bd9082215fd0fdf38eff2f745bcd44faf09245ce18252e7fbf47643b19d7dd0223a9c3700c7d2f16c493f23df9a24d3f11a738d3fe
|
7
|
+
data.tar.gz: 24325ec462e5250420f8f6b6f1dda50044c36577dfdc48690560b79651c54d96ec9385e853d1b51eea05ab585712564eae18fb3016cd03b7228ce49dd1a1f24c
|
data/CHANGELOG.md
CHANGED
@@ -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.
|
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.
|
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.
|
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.
|
31
|
+
concurrent-ruby (1.1.10)
|
32
32
|
diff-lcs (1.5.0)
|
33
|
-
i18n (1.
|
33
|
+
i18n (1.10.0)
|
34
34
|
concurrent-ruby (~> 1.0)
|
35
|
-
minitest (5.
|
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.
|
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.
|
31
|
+
concurrent-ruby (1.1.10)
|
32
32
|
diff-lcs (1.5.0)
|
33
|
-
i18n (1.
|
33
|
+
i18n (1.10.0)
|
34
34
|
concurrent-ruby (~> 1.0)
|
35
|
-
minitest (5.
|
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.
|
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.
|
16
|
-
activesupport (= 5.2.
|
17
|
-
activerecord (5.2.
|
18
|
-
activemodel (= 5.2.
|
19
|
-
activesupport (= 5.2.
|
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.
|
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.
|
31
|
+
concurrent-ruby (1.1.10)
|
32
32
|
diff-lcs (1.5.0)
|
33
|
-
i18n (1.
|
33
|
+
i18n (1.10.0)
|
34
34
|
concurrent-ruby (~> 1.0)
|
35
|
-
minitest (5.
|
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.
|
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.
|
16
|
-
activesupport (= 6.0.
|
17
|
-
activerecord (6.0.
|
18
|
-
activemodel (= 6.0.
|
19
|
-
activesupport (= 6.0.
|
20
|
-
activesupport (6.0.
|
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.
|
30
|
+
concurrent-ruby (1.1.10)
|
31
31
|
diff-lcs (1.5.0)
|
32
|
-
i18n (1.
|
32
|
+
i18n (1.10.0)
|
33
33
|
concurrent-ruby (~> 1.0)
|
34
|
-
minitest (5.
|
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.
|
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
|
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.
|
30
|
+
concurrent-ruby (1.1.10)
|
31
31
|
diff-lcs (1.5.0)
|
32
|
-
i18n (1.
|
32
|
+
i18n (1.10.0)
|
33
33
|
concurrent-ruby (~> 1.0)
|
34
|
-
minitest (5.
|
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.
|
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
|
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
|
-
|
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
|
-
|
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
|
|
data/lib/remockable/version.rb
CHANGED
@@ -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
|
-
|
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=
|
15
|
+
macro_option=nil,
|
16
|
+
&block
|
16
17
|
)
|
17
18
|
context "with option #{option_name.inspect}" do
|
18
|
-
let(:
|
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.
|
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:
|
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
|
-
|
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.
|