active_mocker 1.2 → 1.2.3
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 +4 -4
- data/.gitignore +1 -0
- data/README.md +61 -25
- data/Rakefile +1 -1
- data/active_mocker.gemspec +3 -3
- data/lib/active_hash/init.rb +13 -22
- data/lib/active_mocker.rb +1 -0
- data/lib/active_mocker/active_record/unknown_class_method.rb +1 -1
- data/lib/active_mocker/active_record/unknown_module.rb +3 -3
- data/lib/active_mocker/collection_association.rb +19 -20
- data/lib/active_mocker/config.rb +7 -4
- data/lib/active_mocker/field.rb +4 -4
- data/lib/active_mocker/generate.rb +75 -18
- data/lib/active_mocker/logger.rb +10 -1
- data/lib/active_mocker/mock_class_methods.rb +12 -2
- data/lib/active_mocker/mock_instance_methods.rb +3 -2
- data/lib/active_mocker/mock_requires.rb +2 -1
- data/lib/active_mocker/mock_template.erb +25 -22
- data/lib/active_mocker/public_methods.rb +6 -2
- data/lib/active_mocker/version.rb +1 -1
- data/sample_app_rails_4/app/models/micropost.rb +0 -2
- data/sample_app_rails_4/bin/rspec +16 -0
- data/sample_app_rails_4/config/application.rb +0 -3
- data/sample_app_rails_4/config/database.yml +5 -6
- data/sample_app_rails_4/config/environments/development.rb +0 -2
- data/sample_app_rails_4/config/environments/test.rb +0 -1
- data/sample_app_rails_4/config/initializers/active_mocker.rb +7 -5
- data/sample_app_rails_4/db/migrate/20130311191400_create_users.rb +1 -1
- data/sample_app_rails_4/db/migrate/20130315015932_add_admin_to_users.rb +1 -1
- data/sample_app_rails_4/db/schema.rb +4 -3
- data/sample_app_rails_4/lib/tasks/{mocks.rake → active_mocker.rake} +5 -5
- data/sample_app_rails_4/lib/unit_logger.rb +22 -0
- data/sample_app_rails_4/spec/compare_mocker_and_record_spec.rb +110 -4
- data/sample_app_rails_4/spec/mocks/micropost_mock.rb +31 -27
- data/sample_app_rails_4/spec/mocks/relationship_mock.rb +29 -24
- data/sample_app_rails_4/spec/mocks/user_mock.rb +69 -58
- data/sample_app_rails_4/spec/spec_helper.rb +6 -7
- data/sample_app_rails_4/spec/user_mock_spec.rb +14 -7
- data/spec/lib/active_mocker/collection_association_spec.rb +17 -3
- data/spec/lib/active_mocker/generate_spec.rb +8 -6
- data/spec/lib/active_mocker/model_reader_spec.rb +5 -0
- data/spec/lib/active_mocker/schema_reader_spec.rb +1 -1
- data/spec/lib/readme_spec.rb +199 -205
- data/spec/unit_logger.rb +24 -0
- metadata +22 -32
- data/mocks/micropost_mock.rb +0 -108
- data/mocks/relationship_mock.rb +0 -109
- data/mocks/user_mock.rb +0 -199
- data/plan_mock.rb +0 -2323
- data/sample_app_rails_4/config/cucumber.yml +0 -8
- data/sample_app_rails_4/db/development.sqlite3 +0 -0
- data/sample_app_rails_4/db/test.sqlite3 +0 -0
- data/spec/lib/active_mocker/performance/base_spec.rb +0 -454
- data/spec/lib/active_mocker/performance/large_schema.rb +0 -3576
- data/spec/lib/active_mocker/performance/migration/20140327205359_migration.rb +0 -0
- data/spec/lib/active_mocker/performance/schema_reader_spec.rb +0 -96
- data/spec/lib/compare_mocker_and_record_spec.rb +0 -133
data/spec/unit_logger.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'logger'
|
2
|
+
class UnitLogger
|
3
|
+
|
4
|
+
def self.method_missing(meth, *args, &block)
|
5
|
+
return Rails.logger.send(meth, *args, &block) if defined? Rails
|
6
|
+
return unit.send(meth, *args, &block)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.unit
|
10
|
+
return @logger unless @logger.nil?
|
11
|
+
FileUtils::mkdir_p 'log' unless File.directory? 'log'
|
12
|
+
File.open('log/test.log', 'w').close unless File.exist? 'log/test.log'
|
13
|
+
@logger = Logger.new('log/test.log')
|
14
|
+
@logger.formatter = proc do |severity, datetime, progname, msg|
|
15
|
+
msg
|
16
|
+
end
|
17
|
+
@logger.level = Logger::DEBUG
|
18
|
+
@logger
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_mocker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Zeisler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
@@ -25,33 +25,33 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: active_hash
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: virtus
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
54
|
+
version: '1.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,9 +150,12 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '1.3'
|
153
|
-
description:
|
154
|
-
|
155
|
-
|
153
|
+
description: Creates mocks from Active Record models. Allows your test suite to run
|
154
|
+
very fast by not loading Rails or hooking to a database. It parse the schema definition
|
155
|
+
and the definded methods on a model then saves a ruby file that can be included
|
156
|
+
with a test. Mocks are regenerated when the schema is modified so your mocks will
|
157
|
+
not go stale. This prevents the case where your units tests pass but production
|
158
|
+
code is failing.
|
156
159
|
email:
|
157
160
|
- dustin@zive.me
|
158
161
|
executables: []
|
@@ -204,10 +207,6 @@ files:
|
|
204
207
|
- lib/active_record/db/schema.rb
|
205
208
|
- lib/file_reader.rb
|
206
209
|
- lib/string_reader.rb
|
207
|
-
- mocks/micropost_mock.rb
|
208
|
-
- mocks/relationship_mock.rb
|
209
|
-
- mocks/user_mock.rb
|
210
|
-
- plan_mock.rb
|
211
210
|
- sample_app_rails_4/.idea/.generators
|
212
211
|
- sample_app_rails_4/.idea/.name
|
213
212
|
- sample_app_rails_4/.idea/.rakeTasks
|
@@ -293,10 +292,10 @@ files:
|
|
293
292
|
- sample_app_rails_4/bin/bundle
|
294
293
|
- sample_app_rails_4/bin/rails
|
295
294
|
- sample_app_rails_4/bin/rake
|
295
|
+
- sample_app_rails_4/bin/rspec
|
296
296
|
- sample_app_rails_4/config.ru
|
297
297
|
- sample_app_rails_4/config/application.rb
|
298
298
|
- sample_app_rails_4/config/boot.rb
|
299
|
-
- sample_app_rails_4/config/cucumber.yml
|
300
299
|
- sample_app_rails_4/config/database.yml
|
301
300
|
- sample_app_rails_4/config/environment.rb
|
302
301
|
- sample_app_rails_4/config/environments/development.rb
|
@@ -312,7 +311,6 @@ files:
|
|
312
311
|
- sample_app_rails_4/config/initializers/wrap_parameters.rb
|
313
312
|
- sample_app_rails_4/config/locales/en.yml
|
314
313
|
- sample_app_rails_4/config/routes.rb
|
315
|
-
- sample_app_rails_4/db/development.sqlite3
|
316
314
|
- sample_app_rails_4/db/migrate/20130311191400_create_users.rb
|
317
315
|
- sample_app_rails_4/db/migrate/20130311194153_add_index_to_users_email.rb
|
318
316
|
- sample_app_rails_4/db/migrate/20130311201841_add_password_digest_to_users.rb
|
@@ -322,15 +320,15 @@ files:
|
|
322
320
|
- sample_app_rails_4/db/migrate/20130315230445_create_relationships.rb
|
323
321
|
- sample_app_rails_4/db/schema.rb
|
324
322
|
- sample_app_rails_4/db/seeds.rb
|
325
|
-
- sample_app_rails_4/db/test.sqlite3
|
326
323
|
- sample_app_rails_4/features/signing_in.feature
|
327
324
|
- sample_app_rails_4/features/step_definitions/authentication_steps.rb
|
328
325
|
- sample_app_rails_4/features/support/env.rb
|
329
326
|
- sample_app_rails_4/lib/assets/.keep
|
330
327
|
- sample_app_rails_4/lib/tasks/.keep
|
328
|
+
- sample_app_rails_4/lib/tasks/active_mocker.rake
|
331
329
|
- sample_app_rails_4/lib/tasks/cucumber.rake
|
332
|
-
- sample_app_rails_4/lib/tasks/mocks.rake
|
333
330
|
- sample_app_rails_4/lib/tasks/sample_data.rake
|
331
|
+
- sample_app_rails_4/lib/unit_logger.rb
|
334
332
|
- sample_app_rails_4/log/.keep
|
335
333
|
- sample_app_rails_4/log/development.log
|
336
334
|
- sample_app_rails_4/public/404.html
|
@@ -359,16 +357,12 @@ files:
|
|
359
357
|
- spec/lib/active_mocker/collection_association_spec.rb
|
360
358
|
- spec/lib/active_mocker/generate_spec.rb
|
361
359
|
- spec/lib/active_mocker/model_reader_spec.rb
|
362
|
-
- spec/lib/active_mocker/performance/base_spec.rb
|
363
|
-
- spec/lib/active_mocker/performance/large_schema.rb
|
364
|
-
- spec/lib/active_mocker/performance/migration/20140327205359_migration.rb
|
365
|
-
- spec/lib/active_mocker/performance/schema_reader_spec.rb
|
366
360
|
- spec/lib/active_mocker/schema_reader_spec.rb
|
367
|
-
- spec/lib/compare_mocker_and_record_spec.rb
|
368
361
|
- spec/lib/model.rb
|
369
362
|
- spec/lib/person.rb
|
370
363
|
- spec/lib/readme_spec.rb
|
371
364
|
- spec/lib/schema.rb
|
365
|
+
- spec/unit_logger.rb
|
372
366
|
homepage: https://github.com/zeisler/active_mocker
|
373
367
|
licenses:
|
374
368
|
- MIT
|
@@ -392,19 +386,15 @@ rubyforge_project:
|
|
392
386
|
rubygems_version: 2.2.2
|
393
387
|
signing_key:
|
394
388
|
specification_version: 4
|
395
|
-
summary:
|
396
|
-
a database.
|
389
|
+
summary: Creates mocks from Active Record models. Allows your test suite to run very
|
390
|
+
fast by not loading Rails or hooking to a database.
|
397
391
|
test_files:
|
398
392
|
- spec/lib/active_mocker/collection_association_spec.rb
|
399
393
|
- spec/lib/active_mocker/generate_spec.rb
|
400
394
|
- spec/lib/active_mocker/model_reader_spec.rb
|
401
|
-
- spec/lib/active_mocker/performance/base_spec.rb
|
402
|
-
- spec/lib/active_mocker/performance/large_schema.rb
|
403
|
-
- spec/lib/active_mocker/performance/migration/20140327205359_migration.rb
|
404
|
-
- spec/lib/active_mocker/performance/schema_reader_spec.rb
|
405
395
|
- spec/lib/active_mocker/schema_reader_spec.rb
|
406
|
-
- spec/lib/compare_mocker_and_record_spec.rb
|
407
396
|
- spec/lib/model.rb
|
408
397
|
- spec/lib/person.rb
|
409
398
|
- spec/lib/readme_spec.rb
|
410
399
|
- spec/lib/schema.rb
|
400
|
+
- spec/unit_logger.rb
|
data/mocks/micropost_mock.rb
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
require 'active_mocker/mock_requires'
|
2
|
-
Object.send(:remove_const, "MicropostMock") if ActiveMocker.class_exists?("MicropostMock")
|
3
|
-
|
4
|
-
class MicropostMock < ::ActiveHash::Base
|
5
|
-
include ActiveMocker::ActiveHash::ARApi
|
6
|
-
include ActiveMocker::MockInstanceMethods
|
7
|
-
extend ActiveMocker::MockClassMethods
|
8
|
-
|
9
|
-
def self.column_names
|
10
|
-
["id", "content", "user_id", "created_at", "updated_at"]
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.attribute_names
|
14
|
-
@attribute_names = [:id, :content, :user_id, :created_at, :updated_at]
|
15
|
-
end
|
16
|
-
|
17
|
-
##################################
|
18
|
-
# Attributes getter/setters #
|
19
|
-
##################################
|
20
|
-
|
21
|
-
def id
|
22
|
-
attributes['id']
|
23
|
-
end
|
24
|
-
|
25
|
-
def id=(val)
|
26
|
-
attributes['id'] = val
|
27
|
-
end
|
28
|
-
|
29
|
-
def content
|
30
|
-
attributes['content']
|
31
|
-
end
|
32
|
-
|
33
|
-
def content=(val)
|
34
|
-
attributes['content'] = val
|
35
|
-
end
|
36
|
-
|
37
|
-
def user_id
|
38
|
-
attributes['user_id']
|
39
|
-
end
|
40
|
-
|
41
|
-
def user_id=(val)
|
42
|
-
attributes['user_id'] = val
|
43
|
-
end
|
44
|
-
|
45
|
-
def created_at
|
46
|
-
attributes['created_at']
|
47
|
-
end
|
48
|
-
|
49
|
-
def created_at=(val)
|
50
|
-
attributes['created_at'] = val
|
51
|
-
end
|
52
|
-
|
53
|
-
def updated_at
|
54
|
-
attributes['updated_at']
|
55
|
-
end
|
56
|
-
|
57
|
-
def updated_at=(val)
|
58
|
-
attributes['updated_at'] = val
|
59
|
-
end
|
60
|
-
|
61
|
-
##################################
|
62
|
-
# Association getter/setters #
|
63
|
-
##################################
|
64
|
-
|
65
|
-
def self.association_names
|
66
|
-
@association_names = [:user]
|
67
|
-
end
|
68
|
-
|
69
|
-
def user
|
70
|
-
associations['user']
|
71
|
-
end
|
72
|
-
|
73
|
-
def user=(val)
|
74
|
-
associations['user'] = val
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
##################################
|
79
|
-
# Model Methods getter/setters #
|
80
|
-
##################################
|
81
|
-
|
82
|
-
def self.model_instance_methods
|
83
|
-
return @model_instance_methods if @model_instance_methods
|
84
|
-
@model_instance_methods = {}
|
85
|
-
@model_instance_methods
|
86
|
-
end
|
87
|
-
|
88
|
-
def self.model_class_methods
|
89
|
-
return @model_class_methods if @model_class_methods
|
90
|
-
@model_class_methods = {}
|
91
|
-
@model_class_methods[:from_users_followed_by] = :not_implemented
|
92
|
-
@model_class_methods
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.clear_mock
|
96
|
-
@model_class_methods, @model_instance_methods = nil, nil
|
97
|
-
delete_all
|
98
|
-
end
|
99
|
-
|
100
|
-
|
101
|
-
def self.from_users_followed_by(user)
|
102
|
-
block = model_class_methods[:from_users_followed_by]
|
103
|
-
is_implemented(block, "::from_users_followed_by")
|
104
|
-
instance_exec(*[user], &block)
|
105
|
-
end
|
106
|
-
|
107
|
-
|
108
|
-
end
|
data/mocks/relationship_mock.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'active_mocker/mock_requires'
|
2
|
-
Object.send(:remove_const, "RelationshipMock") if ActiveMocker.class_exists?("RelationshipMock")
|
3
|
-
|
4
|
-
class RelationshipMock < ::ActiveHash::Base
|
5
|
-
include ActiveMocker::ActiveHash::ARApi
|
6
|
-
include ActiveMocker::MockInstanceMethods
|
7
|
-
extend ActiveMocker::MockClassMethods
|
8
|
-
|
9
|
-
def self.column_names
|
10
|
-
["id", "follower_id", "followed_id", "created_at", "updated_at"]
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.attribute_names
|
14
|
-
@attribute_names = [:id, :follower_id, :followed_id, :created_at, :updated_at]
|
15
|
-
end
|
16
|
-
|
17
|
-
##################################
|
18
|
-
# Attributes getter/setters #
|
19
|
-
##################################
|
20
|
-
|
21
|
-
def id
|
22
|
-
attributes['id']
|
23
|
-
end
|
24
|
-
|
25
|
-
def id=(val)
|
26
|
-
attributes['id'] = val
|
27
|
-
end
|
28
|
-
|
29
|
-
def follower_id
|
30
|
-
attributes['follower_id']
|
31
|
-
end
|
32
|
-
|
33
|
-
def follower_id=(val)
|
34
|
-
attributes['follower_id'] = val
|
35
|
-
end
|
36
|
-
|
37
|
-
def followed_id
|
38
|
-
attributes['followed_id']
|
39
|
-
end
|
40
|
-
|
41
|
-
def followed_id=(val)
|
42
|
-
attributes['followed_id'] = val
|
43
|
-
end
|
44
|
-
|
45
|
-
def created_at
|
46
|
-
attributes['created_at']
|
47
|
-
end
|
48
|
-
|
49
|
-
def created_at=(val)
|
50
|
-
attributes['created_at'] = val
|
51
|
-
end
|
52
|
-
|
53
|
-
def updated_at
|
54
|
-
attributes['updated_at']
|
55
|
-
end
|
56
|
-
|
57
|
-
def updated_at=(val)
|
58
|
-
attributes['updated_at'] = val
|
59
|
-
end
|
60
|
-
|
61
|
-
##################################
|
62
|
-
# Association getter/setters #
|
63
|
-
##################################
|
64
|
-
|
65
|
-
def self.association_names
|
66
|
-
@association_names = [:follower, :followed]
|
67
|
-
end
|
68
|
-
|
69
|
-
def follower
|
70
|
-
associations['follower']
|
71
|
-
end
|
72
|
-
|
73
|
-
def follower=(val)
|
74
|
-
associations['follower'] = val
|
75
|
-
end
|
76
|
-
|
77
|
-
def followed
|
78
|
-
associations['followed']
|
79
|
-
end
|
80
|
-
|
81
|
-
def followed=(val)
|
82
|
-
associations['followed'] = val
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
##################################
|
87
|
-
# Model Methods getter/setters #
|
88
|
-
##################################
|
89
|
-
|
90
|
-
def self.model_instance_methods
|
91
|
-
return @model_instance_methods if @model_instance_methods
|
92
|
-
@model_instance_methods = {}
|
93
|
-
@model_instance_methods
|
94
|
-
end
|
95
|
-
|
96
|
-
def self.model_class_methods
|
97
|
-
return @model_class_methods if @model_class_methods
|
98
|
-
@model_class_methods = {}
|
99
|
-
@model_class_methods
|
100
|
-
end
|
101
|
-
|
102
|
-
def self.clear_mock
|
103
|
-
@model_class_methods, @model_instance_methods = nil, nil
|
104
|
-
delete_all
|
105
|
-
end
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
end
|
data/mocks/user_mock.rb
DELETED
@@ -1,199 +0,0 @@
|
|
1
|
-
require 'active_mocker/mock_requires'
|
2
|
-
Object.send(:remove_const, "UserMock") if ActiveMocker.class_exists?("UserMock")
|
3
|
-
|
4
|
-
class UserMock < ::ActiveHash::Base
|
5
|
-
include ActiveMocker::ActiveHash::ARApi
|
6
|
-
include ActiveMocker::MockInstanceMethods
|
7
|
-
extend ActiveMocker::MockClassMethods
|
8
|
-
|
9
|
-
def self.column_names
|
10
|
-
["id", "name", "email", "created_at", "updated_at", "password_digest", "remember_token", "admin"]
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.attribute_names
|
14
|
-
@attribute_names = [:id, :name, :email, :created_at, :updated_at, :password_digest, :remember_token, :admin]
|
15
|
-
end
|
16
|
-
|
17
|
-
##################################
|
18
|
-
# Attributes getter/setters #
|
19
|
-
##################################
|
20
|
-
|
21
|
-
def id
|
22
|
-
attributes['id']
|
23
|
-
end
|
24
|
-
|
25
|
-
def id=(val)
|
26
|
-
attributes['id'] = val
|
27
|
-
end
|
28
|
-
|
29
|
-
def name
|
30
|
-
attributes['name']
|
31
|
-
end
|
32
|
-
|
33
|
-
def name=(val)
|
34
|
-
attributes['name'] = val
|
35
|
-
end
|
36
|
-
|
37
|
-
def email
|
38
|
-
attributes['email']
|
39
|
-
end
|
40
|
-
|
41
|
-
def email=(val)
|
42
|
-
attributes['email'] = val
|
43
|
-
end
|
44
|
-
|
45
|
-
def created_at
|
46
|
-
attributes['created_at']
|
47
|
-
end
|
48
|
-
|
49
|
-
def created_at=(val)
|
50
|
-
attributes['created_at'] = val
|
51
|
-
end
|
52
|
-
|
53
|
-
def updated_at
|
54
|
-
attributes['updated_at']
|
55
|
-
end
|
56
|
-
|
57
|
-
def updated_at=(val)
|
58
|
-
attributes['updated_at'] = val
|
59
|
-
end
|
60
|
-
|
61
|
-
def password_digest
|
62
|
-
attributes['password_digest']
|
63
|
-
end
|
64
|
-
|
65
|
-
def password_digest=(val)
|
66
|
-
attributes['password_digest'] = val
|
67
|
-
end
|
68
|
-
|
69
|
-
def remember_token
|
70
|
-
attributes['remember_token']
|
71
|
-
end
|
72
|
-
|
73
|
-
def remember_token=(val)
|
74
|
-
attributes['remember_token'] = val
|
75
|
-
end
|
76
|
-
|
77
|
-
def admin
|
78
|
-
attributes['admin']
|
79
|
-
end
|
80
|
-
|
81
|
-
def admin=(val)
|
82
|
-
attributes['admin'] = val
|
83
|
-
end
|
84
|
-
|
85
|
-
##################################
|
86
|
-
# Association getter/setters #
|
87
|
-
##################################
|
88
|
-
|
89
|
-
def self.association_names
|
90
|
-
@association_names = [:microposts, :relationships, :followed_users, :reverse_relationships, :followers]
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
def microposts
|
95
|
-
associations['microposts']
|
96
|
-
end
|
97
|
-
|
98
|
-
def microposts=(val)
|
99
|
-
associations['microposts'] = ActiveMocker::CollectionAssociation.new(val)
|
100
|
-
end
|
101
|
-
|
102
|
-
def relationships
|
103
|
-
associations['relationships']
|
104
|
-
end
|
105
|
-
|
106
|
-
def relationships=(val)
|
107
|
-
associations['relationships'] = ActiveMocker::CollectionAssociation.new(val)
|
108
|
-
end
|
109
|
-
|
110
|
-
def followed_users
|
111
|
-
associations['followed_users']
|
112
|
-
end
|
113
|
-
|
114
|
-
def followed_users=(val)
|
115
|
-
associations['followed_users'] = ActiveMocker::CollectionAssociation.new(val)
|
116
|
-
end
|
117
|
-
|
118
|
-
def reverse_relationships
|
119
|
-
associations['reverse_relationships']
|
120
|
-
end
|
121
|
-
|
122
|
-
def reverse_relationships=(val)
|
123
|
-
associations['reverse_relationships'] = ActiveMocker::CollectionAssociation.new(val)
|
124
|
-
end
|
125
|
-
|
126
|
-
def followers
|
127
|
-
associations['followers']
|
128
|
-
end
|
129
|
-
|
130
|
-
def followers=(val)
|
131
|
-
associations['followers'] = ActiveMocker::CollectionAssociation.new(val)
|
132
|
-
end
|
133
|
-
|
134
|
-
##################################
|
135
|
-
# Model Methods getter/setters #
|
136
|
-
##################################
|
137
|
-
|
138
|
-
def self.model_instance_methods
|
139
|
-
return @model_instance_methods if @model_instance_methods
|
140
|
-
@model_instance_methods = {}
|
141
|
-
@model_instance_methods[:feed] = :not_implemented
|
142
|
-
@model_instance_methods[:following?] = :not_implemented
|
143
|
-
@model_instance_methods[:follow!] = :not_implemented
|
144
|
-
@model_instance_methods[:unfollow!] = :not_implemented
|
145
|
-
@model_instance_methods
|
146
|
-
end
|
147
|
-
|
148
|
-
def self.model_class_methods
|
149
|
-
return @model_class_methods if @model_class_methods
|
150
|
-
@model_class_methods = {}
|
151
|
-
@model_class_methods[:new_remember_token] = :not_implemented
|
152
|
-
@model_class_methods[:digest] = :not_implemented
|
153
|
-
@model_class_methods
|
154
|
-
end
|
155
|
-
|
156
|
-
def self.clear_mock
|
157
|
-
@model_class_methods, @model_instance_methods = nil, nil
|
158
|
-
delete_all
|
159
|
-
end
|
160
|
-
|
161
|
-
def feed()
|
162
|
-
block = model_instance_methods[:feed]
|
163
|
-
self.class.is_implemented(block, "#feed")
|
164
|
-
instance_exec(*[], &block)
|
165
|
-
end
|
166
|
-
|
167
|
-
def following?(other_user)
|
168
|
-
block = model_instance_methods[:following?]
|
169
|
-
self.class.is_implemented(block, "#following?")
|
170
|
-
instance_exec(*[other_user], &block)
|
171
|
-
end
|
172
|
-
|
173
|
-
def follow!(other_user)
|
174
|
-
block = model_instance_methods[:follow!]
|
175
|
-
self.class.is_implemented(block, "#follow!")
|
176
|
-
instance_exec(*[other_user], &block)
|
177
|
-
end
|
178
|
-
|
179
|
-
def unfollow!(other_user)
|
180
|
-
block = model_instance_methods[:unfollow!]
|
181
|
-
self.class.is_implemented(block, "#unfollow!")
|
182
|
-
instance_exec(*[other_user], &block)
|
183
|
-
end
|
184
|
-
|
185
|
-
|
186
|
-
def self.new_remember_token()
|
187
|
-
block = model_class_methods[:new_remember_token]
|
188
|
-
is_implemented(block, "::new_remember_token")
|
189
|
-
instance_exec(*[], &block)
|
190
|
-
end
|
191
|
-
|
192
|
-
def self.digest(token)
|
193
|
-
block = model_class_methods[:digest]
|
194
|
-
is_implemented(block, "::digest")
|
195
|
-
instance_exec(*[token], &block)
|
196
|
-
end
|
197
|
-
|
198
|
-
|
199
|
-
end
|