active_mocker 2.2.5 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -1
- data/README.md +13 -0
- data/lib/active_mocker/mock/queries.rb +12 -0
- data/lib/active_mocker/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6857ef7a6d6e842ef53b64fc87f08f8b7e36c11
|
4
|
+
data.tar.gz: 81e5e8273ee2302efae6bf5d2610a77ae9d6704e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 441d757202f71f10019f96d4710143d872d97a8a58341e884448e398313a0085de4202745dd535312c0946643a67ef2bf2ffc1b545a0cd532e35f388bd431bdd
|
7
|
+
data.tar.gz: efc1a21ff7fb7641c7635196efd4a9e325a919d87b26c6f16695512d7915897a7949b7bd9f58c1dc6ee76ff1997519a3db6ccf4bc5053fc6abbd01a3799a187e
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
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
|
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.
|
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-
|
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.
|
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.
|
110
|
+
version: 0.4.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: dissociated_introspection
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|