active_mocker 1.6 → 1.6.1

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: 35f6abbcfa326377ac5fa015a3e1f9b434a9f936
4
- data.tar.gz: 8aad0e3c8158712b9a09790d663854df1f5c96ec
3
+ metadata.gz: 6c70def168943eb0f1f7aace0c823780695c8d3a
4
+ data.tar.gz: 8ff543cc5faba67a25808afa49174fb04153b321
5
5
  SHA512:
6
- metadata.gz: 50d226edfaa35c359327b9ee3eb888bccd395fbe378d943302e368b04f7ed2885609fe6044ea4dffec02364af7fe46f11ced835d874c0acb8a957e61ee2e6ed7
7
- data.tar.gz: ecc81c94d5186bf9a1e9b2e55556a2ec709ad97411df75b0a7806fc12d1491445eb44ba3d9971e7bcf0448837ac78b2ef9cb4d1e451a53cb2aa05850087d514c
6
+ metadata.gz: 420a1302966907ce04dbc02959387f80b27e0c7d84770677b77b8fb82524bc4e1314b842d433883be4d04fb2010d8272d96d4915aa28612ba31fcf79ccb7c4bd
7
+ data.tar.gz: 5bbf9019ff6f490c733b3071415591582771a0987661b7908b93f2ce0402c6615cf72f131e2bc29f5f561e06fd81b9d71036552c011947ce4f3e8b3bdd23a8af
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
+
4
+ ## 1.6.1 - 2014-07-30
5
+
6
+ ### Fix
7
+ - In `experimental` features where variable name should of been a symbol.
8
+ ### Enhancement
9
+ - `experimental` features: When assigning an association the record being associated will now try to either assign a has_many or has_one association onto the inputted record.
10
+
3
11
  ## 1.6 - 2014-07-29
4
12
 
5
13
  ### Enhancement
@@ -15,7 +23,7 @@ All notable changes to this project will be documented in this file.
15
23
  ### Added
16
24
  - Added documentation for many methods.
17
25
  - find_or_create_by/find_or_initialize_by now accessible from any collection.
18
- - Instance methods attribute_names, attribute_present?, has_attribute?
26
+ - Instance methods `attribute_names`, `attribute_present?`, `has_attribute?`
19
27
  - Using `ActiveMocker::Mock.config.experimental = true`. This will turn on features that are not complete and may not work as expected, especially if you have complex relationships. This will activate the following features:
20
28
  - When passing in collection all item in collection will set its foreign key to the parent.
21
29
  - When setting association by object it will set the child association.
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Dependency Status](https://gemnasium.com/zeisler/active_mocker.svg)](https://gemnasium.com/zeisler/active_mocker)
6
6
  [![Gitter chat](https://badges.gitter.im/zeisler/active_mocker.png)](https://gitter.im/zeisler/active_mocker)
7
7
 
8
- ActiveMocker creates mocks classes from ActiveRecord models. Allowing your test suite to run very fast by not loading Rails or hooking to a database. It parses the schema definition and the defined methods on a model then saves a ruby file that can be included within a test. The mock can be run by themselves and run with a partial implementation of ActiveRecord. Mocks are regenerated when the schema is modified so your mocks will not go stale. Preventing the case where your units tests pass but production code is failing.
8
+ ActiveMocker creates mocks classes from ActiveRecord models. Allowing your test suite to run very fast by not loading Rails or hooking to a database. It parses the schema.rb and the defined methods on a model then generates a ruby file that can be included within a test. The mock file can be run by themselves and come with a partial implementation of ActiveRecord. Attributes and associations can be used just the same as in ActiveRecord. Methods will have the correct arguments but raise an Unimplemented error when called. Mocks are regenerated when the schema is modified so your mocks will not go stale; preventing the case where your units tests pass but production code fails.
9
9
 
10
10
  Examples from a real apps
11
11
 
@@ -138,7 +138,7 @@ Running this rake task builds/rebuilds the mocks. It will be ran automatically a
138
138
 
139
139
  person = Person.new( first_name: "Dustin",
140
140
  last_name: "Zeisler",
141
- account: AccountMock.new )
141
+ account: Account.new )
142
142
  => "#<PersonMock id: nil, account_id: nil, first_name: "Dustin", last_name: "Zeisler, address: nil, city: nil>"
143
143
 
144
144
  person.first_name
@@ -263,6 +263,9 @@ Deletes All Records for Loaded Mocks - (Useful in after(:each) to clean up state
263
263
  ActiveMocker::LoadedMocks.delete_all
264
264
 
265
265
  ### ActiveRecord supported methods
266
+
267
+ See [Documentation](http://rdoc.info/github/zeisler/active_mocker/master/ActiveMocker) for a complete list of methods and usage.
268
+
266
269
  **class methods**
267
270
 
268
271
  * new
@@ -271,6 +274,7 @@ Deletes All Records for Loaded Mocks - (Useful in after(:each) to clean up state
271
274
  * delete_all/destroy_all
272
275
 
273
276
  **Query Methods**
277
+
274
278
  * all
275
279
  * find
276
280
  * find_by/find_by!
@@ -316,6 +320,9 @@ Deletes All Records for Loaded Mocks - (Useful in after(:each) to clean up state
316
320
  * new_record?
317
321
  * persisted?
318
322
  * reload
323
+ * attribute_names
324
+ * attribute_present?
325
+ * has_attribute?
319
326
 
320
327
  **has_one/belongs_to/has_many**
321
328
 
@@ -73,7 +73,8 @@ class <%= class_name + @mock_append_name %> < ActiveMocker::Mock::Base
73
73
  @associations[:<%= meth.name %>] = val
74
74
  write_attribute(:<%= meth.foreign_key %>, val.id) if val.respond_to?(:persisted?) && val.persisted?
75
75
  if ActiveMocker::Mock.config.experimental
76
- val.<%= class_name.tableize %> << self if val.respond_to?(:<%= class_name.tableize %>)
76
+ val.<%= class_name.tableize %> << self if val.respond_to?(:<%= class_name.tableize %>=)
77
+ val.<%= class_name.tableize.singularize %> = self if val.respond_to?(:<%= class_name.tableize.singularize %>=)
77
78
  end
78
79
  val
79
80
  end
@@ -104,9 +105,10 @@ class <%= class_name + @mock_append_name %> < ActiveMocker::Mock::Base
104
105
  def <%= meth.name %>=(val)
105
106
  @associations['<%= meth.name %>'] = val
106
107
  if ActiveMocker::Mock.config.experimental
107
- <%= meth.name %>.send(:write_association, <%= class_name.tableize.singularize %>, self) if val.respond_to?(:<%= class_name.tableize.singularize %>=)
108
+ <%= meth.name %>.<%= class_name.tableize %> << self if val.respond_to?(:<%= class_name.tableize %>=)
109
+ <%= meth.name %>.send(:write_association, :<%= class_name.tableize.singularize %>, self) if val.respond_to?(:<%= class_name.tableize.singularize %>=)
108
110
  end
109
- <%= meth.name %>
111
+ val
110
112
  end
111
113
 
112
114
  def build_<%= meth.name %>(attributes={}, &block)
@@ -1,3 +1,3 @@
1
1
  module ActiveMocker
2
- VERSION = "1.6"
2
+ VERSION = "1.6.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_mocker
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.6'
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Zeisler
@@ -206,12 +206,15 @@ dependencies:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0.15'
209
- description: Creates mocks from Active Record models. Allows your test suite to run
210
- very fast by not loading Rails or hooking to a database. It parse the schema definition
211
- and the defined methods on a model then saves a ruby file that can be included with
212
- a test. Mocks are regenerated when the schema is modified so your mocks will not
213
- go stale. This prevents the case where your units tests pass but production code
214
- is failing.
209
+ description: ActiveMocker creates mocks classes from ActiveRecord models. Allowing
210
+ your test suite to run very fast by not loading Rails or hooking to a database.
211
+ It parses the schema.rb and the defined methods on a model then generates a ruby
212
+ file that can be included within a test. The mock file can be run by themselves
213
+ and come with a partial implementation of ActiveRecord. Attributes and associations
214
+ can be used just the same as in ActiveRecord. Methods will have the correct arguments
215
+ but raise an Unimplemented error when called. Mocks are regenerated when the schema
216
+ is modified so your mocks will not go stale; preventing the case where your units
217
+ tests pass but production code fails.
215
218
  email:
216
219
  - dustin@zive.me
217
220
  executables: []