active_mocker 2.2.5 → 2.3.0

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: 5c9b8b50a769f0fd124221aefa61ec465b8950b4
4
- data.tar.gz: 1c3a9909ef77657aecc9c1594b20acbd14747c17
3
+ metadata.gz: b6857ef7a6d6e842ef53b64fc87f08f8b7e36c11
4
+ data.tar.gz: 81e5e8273ee2302efae6bf5d2610a77ae9d6704e
5
5
  SHA512:
6
- metadata.gz: 45027e22f496a48bfc8d8653bb6ececf3332e139252ceeba5643cde16eb80bda6725d69ffa4faf54619313b57a48adae270712438ee781335190651535249ef3
7
- data.tar.gz: eb5696f31e0f43c9a685fae05b37c4edf80f1a829ce8e729ed177bec160564a1d794cdf680cb80d4d61c5f05c7baee11bce7f457e70a1714f6f0469f262b780f
6
+ metadata.gz: 441d757202f71f10019f96d4710143d872d97a8a58341e884448e398313a0085de4202745dd535312c0946643a67ef2bf2ffc1b545a0cd532e35f388bd431bdd
7
+ data.tar.gz: efc1a21ff7fb7641c7635196efd4a9e325a919d87b26c6f16695512d7915897a7949b7bd9f58c1dc6ee76ff1997519a3db6ccf4bc5053fc6abbd01a3799a187e
@@ -1,6 +1,27 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 2.3.0 - 2016-08-29
5
+ ### Feature
6
+ - Added `#first_or_create`, `#first_or_create!`, and `#first_or_initialize`
7
+
8
+ ### Enhancement
9
+ - Improved API for registering unknown types and defaults. See https://github.com/zeisler/active_record_schema_scrapper#registering-types
10
+
11
+ ### Deprecation
12
+ - `ActiveRecordSchemaScrapper::Attributes.register_default` gives a deprecation warning if given keys :name and :klass.
13
+ New names are :default and :replacement_default.
14
+
15
+ Example usage:
16
+ ```ruby
17
+ ActiveRecordSchemaScrapper::Attributes.register_default(
18
+ default: "{}",
19
+ replacement_default: [],
20
+ cast_type: -> (c) { c.class.name.include?("Array") }
21
+ )
22
+ ```
23
+ https://github.com/zeisler/active_record_schema_scrapper/blob/master/lib/active_record_schema_scrapper/attributes.rb#L36
24
+
4
25
  ## 2.2.5 - 2016-08-28
5
26
  ### Fix
6
27
  - Ensure '#update' calls save. Addressing the case where an object had not been saved prior would not get persisted.
@@ -37,7 +58,7 @@ All notable changes to this project will be documented in this file.
37
58
  - When an include/extended module is not locally defined, but defined in the same namespace as the mock it was not correctly namespaced
38
59
  - Fix issue NoMethodError in Rails 5.beta when introspection activerecord model.
39
60
 
40
- ## Enhancement
61
+ ### Enhancement
41
62
  - Ignore all non ActiveRecord::Base subclasses
42
63
  - Make rake dependency less strict `>= 10.0`
43
64
 
data/README.md CHANGED
@@ -176,6 +176,19 @@ Person.new(first_name: "Dustin", last_name: "Zeisler")
176
176
  =>#<UnknownAttributeError unknown attribute: first_name >
177
177
  ```
178
178
 
179
+ ### Creating Custom collections
180
+
181
+ If you want to create custom set of record that is not part of the global collection for model. (ie. for stubbing in a test)
182
+
183
+ ```ruby
184
+ User::ScopeRelation.new([User.new, User.new])
185
+ ```
186
+
187
+ This give the full query API (ie. find_by, where, etc).
188
+
189
+ This is not feature available in ActiveRecord as such do not include this where you intend to swap in ActiveRecord.
190
+
191
+
179
192
  ## Mocking Methods
180
193
 
181
194
  #### Rspec 3 Mocks - verify double
@@ -236,6 +236,18 @@ module ActiveMocker
236
236
  find_by(attributes) || new(attributes, &block)
237
237
  end
238
238
 
239
+ def first_or_create(attributes = nil, &block) # :nodoc:
240
+ first || create(attributes, &block)
241
+ end
242
+
243
+ def first_or_create!(attributes = nil, &block) # :nodoc:
244
+ first || create!(attributes, &block)
245
+ end
246
+
247
+ def first_or_initialize(attributes = nil, &block) # :nodoc:
248
+ first || new(attributes, &block)
249
+ end
250
+
239
251
  # Count the records.
240
252
  #
241
253
  # PersonMock.count
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveMocker
3
- VERSION = "2.2.5"
3
+ VERSION = "2.3.0"
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.5
4
+ version: 2.3.0
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-08-28 00:00:00.000000000 Z
11
+ date: 2016-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.2.2
103
+ version: 0.4.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.2.2
110
+ version: 0.4.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: dissociated_introspection
113
113
  requirement: !ruby/object:Gem::Requirement