active_mocker 2.2.3 → 2.2.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: 4daac0cc1807887b124c87e1b99c2dd18c8200f4
4
- data.tar.gz: 055f5ad3ecbc226db9a1f922fe17ad860f8a2c6c
3
+ metadata.gz: 9be1a4a8a33f8e58e8733ed44ebec8d7a96a41aa
4
+ data.tar.gz: 911a0d874d5679fc5e5e85271228ed50844009c4
5
5
  SHA512:
6
- metadata.gz: b384f744eb831ef0523a00e7dc98cf81e79338a1b669b2e97a995a05c67c40e266a7e9315f756cc34708a7939711435fa8877c9f0fa44ea929b4e8da291bbdca
7
- data.tar.gz: 35f13e27556125d9df82dd831692a27dc5435f7312b5b716428d1daae17ab7305d44abbcf231971142c27c2439bf1d17f37a4c8aab096096ed4d055917ad9ee3
6
+ metadata.gz: 2043c2a02be22bff409c691d395255bb73cbcd218fa7f1ceab4b609f55b179734394a0f4a0aa7803b3b61674bad0ab062804ce68c19e187bb7a609f41c7bd77d
7
+ data.tar.gz: dab8ebc81628445fafaea0693c9eb5d7791a5336a6b720be72fc3b842b8b1a261fc9060e0b9528df49dc78650e55819bb12bc31057b2ad3092a24a40d718a57b
@@ -1,7 +1,11 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## 2.2.2 - 2016-06-27
4
+ ## 2.2.4 - 2016-06-27
5
+ ### Fix
6
+ - `BigDecimal`, `Date`, `DateTime`, and `Time` when used as defaults in the schema caused mock generation failures.
7
+
8
+ ## 2.2.3 - 2016-06-27
5
9
  ### Fix
6
10
  - Constant values assigned to non sudo primitives objects causing issues. https://github.com/zeisler/active_mocker/issues/72
7
11
 
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ require "active_mocker/inspectable/bigdecimal"
3
+ require "active_mocker/inspectable/date"
4
+ require "active_mocker/inspectable/dir"
5
+ require "active_mocker/inspectable/file"
6
+ require "active_mocker/inspectable/pathname"
7
+ require "active_mocker/inspectable/struct"
8
+ require "active_mocker/inspectable/time"
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module ActiveMocker
3
+ module Inspectable
4
+ refine BigDecimal do
5
+ def inspect
6
+ "BigDecimal(\"%s\")" % to_s('F')
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ module ActiveMocker
3
+ module Inspectable
4
+ refine Date do
5
+ def inspect
6
+ "Date.new(%s, %s, %s)" % [year, month, day]
7
+ end
8
+ end
9
+
10
+ refine DateTime do
11
+ def inspect
12
+ strftime("DateTime.new(%Y, %-m, %-d, %-H, %-M, %-S, \"%:z\")")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module ActiveMocker
3
+ module Inspectable
4
+ refine Dir do
5
+ def inspect
6
+ "Dir.new(#{path.inspect})"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module ActiveMocker
3
+ module Inspectable
4
+ refine Dir do
5
+ def File
6
+ "File.new(#{path.inspect})"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module ActiveMocker
3
+ module Inspectable
4
+ refine Pathname do
5
+ def inspect
6
+ "Pathname(#{to_s.inspect})"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module ActiveMocker
3
+ module Inspectable
4
+ refine Struct do
5
+ def inspect
6
+ "%s.new(%s)" % [self.class.name, values.map(&:inspectable).join(", ")]
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module ActiveMocker
3
+ module Inspectable
4
+ refine Time do
5
+ def inspect
6
+ strftime("Time.new(%Y, %-m, %-d, %-H, %-M, %-S, \"%:z\")")
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,6 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
3
+ require "active_mocker/inspectable"
4
+
2
5
  module ActiveMocker
3
6
  class MockCreator
7
+
8
+ using ActiveMocker::Inspectable
4
9
  def initialize(file:,
5
10
  file_out:,
6
11
  schema_scrapper:,
@@ -1,7 +1,7 @@
1
1
  #_class_methods.erb
2
2
  class << self
3
3
  def attributes
4
- @attributes ||= HashWithIndifferentAccess.new(<%= attributes_with_defaults %>).merge(super)
4
+ @attributes ||= HashWithIndifferentAccess.new(<%= attributes_with_defaults.map {|key,value| %Q[#{key}: #{value.inspect}]}.join(", ") %>).merge(super)
5
5
  end
6
6
 
7
7
  def types
@@ -23,7 +23,7 @@
23
23
  private :mocked_class
24
24
 
25
25
  def attribute_names
26
- @attribute_names ||= <%= attribute_names %> | super
26
+ @attribute_names ||= attributes.stringify_keys.keys
27
27
  end
28
28
 
29
29
  def primary_key
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveMocker
3
- VERSION = "2.2.3"
3
+ VERSION = "2.2.4"
4
4
  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.2.3
4
+ version: 2.2.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: 2016-06-27 00:00:00.000000000 Z
11
+ date: 2016-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -193,6 +193,14 @@ files:
193
193
  - lib/active_mocker/file_writer.rb
194
194
  - lib/active_mocker/generate.rb
195
195
  - lib/active_mocker/hash_new_style.rb
196
+ - lib/active_mocker/inspectable.rb
197
+ - lib/active_mocker/inspectable/bigdecimal.rb
198
+ - lib/active_mocker/inspectable/date.rb
199
+ - lib/active_mocker/inspectable/dir.rb
200
+ - lib/active_mocker/inspectable/file.rb
201
+ - lib/active_mocker/inspectable/pathname.rb
202
+ - lib/active_mocker/inspectable/struct.rb
203
+ - lib/active_mocker/inspectable/time.rb
196
204
  - lib/active_mocker/loaded_mocks.rb
197
205
  - lib/active_mocker/mock.rb
198
206
  - lib/active_mocker/mock/alias_attribute.rb
@@ -259,3 +267,4 @@ specification_version: 4
259
267
  summary: Creates mocks from Active Record models. Allows your test suite to run very
260
268
  fast by not loading Rails or a database.
261
269
  test_files: []
270
+ has_rdoc: