active_mocker 2.5.3 → 2.5.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee07a0c316a8e30d793536c32edcb6ffc1ff0d3a
|
4
|
+
data.tar.gz: 2c7938f5ea726a3ddb388e6b65547df17bc5ce2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2909eac242da2763b902c05af8e462e49ee256640cc791716a76bde87d56dc7c2d3e2fb750996d77de865ec4bc0eb2d20d34bdd1c2e0cf343ebdb1f6d9231d71
|
7
|
+
data.tar.gz: 59177e2d5513705962e95ba9c0784c5436299b38736cb3a660bd58d8e265a03d77a5d84e792d78a285d44d229cebdb3c91ad5f052bf755fbae58989450ba6f16
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## 2.5.4 - 2017-11-17
|
5
|
+
### Fix
|
6
|
+
- has_and_belongs_to_many association did not contain scoped methods.
|
7
|
+
|
8
|
+
### Enhancement
|
9
|
+
- Error message when calling stubbed methods show safe_methods syntax along with RSpec syntax.
|
10
|
+
|
4
11
|
## 2.5.3 - 2017-10-01
|
5
12
|
### Fix
|
6
13
|
- Update gem dependency to fix Macro `ActiveMocker.safe_methods` when marking class_methods.
|
@@ -5,13 +5,15 @@ module ActiveMocker
|
|
5
5
|
private
|
6
6
|
|
7
7
|
def __am_raise_not_mocked_error(method:, caller:, type:)
|
8
|
-
variable_name = if is_a?(Relation)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
variable_name, klass, method_type = if is_a?(Relation)
|
9
|
+
klass = self.class.name.underscore.split("/").first
|
10
|
+
["#{klass}_relation", klass.camelize, :scopes]
|
11
|
+
elsif type == "#"
|
12
|
+
klass = self.class.name
|
13
|
+
["#{klass.underscore}_record", klass, :instance_methods]
|
14
|
+
else
|
15
|
+
[name, name, :class_methods]
|
16
|
+
end
|
15
17
|
|
16
18
|
message = <<-ERROR.strip_heredoc
|
17
19
|
Unknown implementation for mock method: #{variable_name}.#{method}
|
@@ -21,6 +23,11 @@ module ActiveMocker
|
|
21
23
|
allow(
|
22
24
|
#{variable_name}
|
23
25
|
).to receive(:#{method}).and_return(:some_expected_result)
|
26
|
+
|
27
|
+
OR Whitelist the method as safe to copy/run in the context of ActiveMocker (requires mock rebuild)
|
28
|
+
# ActiveMocker.safe_methods #{method_type}: [:#{method}]
|
29
|
+
class #{klass.gsub("Mock", "")} < ActiveRecord::Base
|
30
|
+
end
|
24
31
|
ERROR
|
25
32
|
|
26
33
|
raise NotImplementedError, message, caller
|
@@ -71,10 +71,10 @@ end
|
|
71
71
|
|
72
72
|
<% has_and_belongs_to_many.each do |meth| -%>
|
73
73
|
def <%= meth.name %>
|
74
|
-
read_association(:<%= meth.name %>, ->{ ActiveMocker::HasAndBelongsToMany.new([]) })
|
74
|
+
read_association(:<%= meth.name %>, -> { ActiveMocker::HasAndBelongsToMany.new([],foreign_key: '<%= meth.foreign_key %>', foreign_id: self.id, relation_class: classes('<%= meth.class_name %>'), source: '<%= meth.source %>') })
|
75
75
|
end
|
76
76
|
|
77
77
|
def <%= meth.name %>=(val)
|
78
|
-
write_association(:<%= meth.name %>, ActiveMocker::HasAndBelongsToMany.new(val))
|
78
|
+
write_association(:<%= meth.name %>, ActiveMocker::HasAndBelongsToMany.new(val, foreign_key: '<%= meth.foreign_key %>', foreign_id: self.id, relation_class: classes('<%= meth.class_name %>'), source: '<%= meth.source %>'))
|
79
79
|
end
|
80
80
|
<% end -%>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_mocker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Zeisler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|