active_mocker 2.5.3 → 2.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39450a85ddf3388cbecfa4aa0fdb0fcc88fd2c50
4
- data.tar.gz: 8360812d1b7dacd4175bd7fd353e793e0ca9e26d
3
+ metadata.gz: ee07a0c316a8e30d793536c32edcb6ffc1ff0d3a
4
+ data.tar.gz: 2c7938f5ea726a3ddb388e6b65547df17bc5ce2f
5
5
  SHA512:
6
- metadata.gz: bf6d0277dac3ea3dcdff50ab09e3959f9009f97263996f3f79d9835d04f8481028603f2a9798d84162b2301fead4075f87a9f4b249779ac2499652ba5da0b4c3
7
- data.tar.gz: fdcbc2e172d15da3b9ed57208c394e2390c46b87bc60ffe34ee0916d4ee65a06d0621b8e899d0958c2458f812834c0aa7538439a85a2a3cd1d0ce5081616ffff
6
+ metadata.gz: 2909eac242da2763b902c05af8e462e49ee256640cc791716a76bde87d56dc7c2d3e2fb750996d77de865ec4bc0eb2d20d34bdd1c2e0cf343ebdb1f6d9231d71
7
+ data.tar.gz: 59177e2d5513705962e95ba9c0784c5436299b38736cb3a660bd58d8e265a03d77a5d84e792d78a285d44d229cebdb3c91ad5f052bf755fbae58989450ba6f16
@@ -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
- "#{self.class.name.underscore.split("/").first}_relation"
10
- elsif type == "#"
11
- "#{self.class.name.underscore}_record"
12
- else
13
- name
14
- end
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 -%>
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveMocker
3
- VERSION = "2.5.3"
3
+ VERSION = "2.5.4"
4
4
  module Mock
5
5
  VERSION = "2" # This increments when breaking changes happen in the generated mocks
6
6
  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.3
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-10-02 00:00:00.000000000 Z
11
+ date: 2017-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport