active_mocker 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/active_mocker.rb +8 -3
- data/lib/active_mocker/active_record.rb +2 -0
- data/lib/active_mocker/active_record/relationships.rb +4 -4
- data/lib/active_mocker/active_record/unknown_class_method.rb +12 -0
- data/lib/active_mocker/base.rb +0 -1
- data/lib/active_mocker/config.rb +5 -0
- data/lib/active_mocker/logger.rb +3 -0
- data/lib/active_mocker/version.rb +1 -1
- data/spec/lib/active_mocker/base_spec.rb +4 -0
- data/spec/lib/active_mocker/model_reader_spec.rb +3 -0
- data/spec/lib/model.rb +3 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efd0c09e9b3b692f45b3b44d3585075fa656c078
|
4
|
+
data.tar.gz: 1efef179992c2a8f2f85d713829e31451fc6c021
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82951efa29250007b6fda13d228005ef03d84035df9276fb1a48bbb5e08940445bb151e59505dafc9867f79a59b2d10216a1366662b9ef4edfacc22f5a760188
|
7
|
+
data.tar.gz: 3d0324bd594d7a2d67b573b14aa61ab161bf4fff5d5eea6bae014d958f22f7f19fd65a768ef1f7db7744f5d5e794fa0852dbec3096402f5ecca23e9cba03e137
|
data/README.md
CHANGED
@@ -49,8 +49,8 @@ Or install it yourself as:
|
|
49
49
|
require 'active_mocker'
|
50
50
|
|
51
51
|
ActiveMocker::Base.configure do |config|
|
52
|
-
config.schema_file =
|
53
|
-
config.model_dir =
|
52
|
+
config.schema_file = "#{APP_ROOT}/db/schema.rb"
|
53
|
+
config.model_dir = "#{APP_ROOT}/app/models"
|
54
54
|
# Dependency injection
|
55
55
|
config.schema_file_reader = schema_file
|
56
56
|
config.model_file_reader = model_file
|
@@ -60,6 +60,8 @@ Or install it yourself as:
|
|
60
60
|
config.model_relationships = true #default
|
61
61
|
config.model_methods = true #default
|
62
62
|
config.mass_assignment = true #default
|
63
|
+
# Logging
|
64
|
+
config.log_level = Logger::WARN #default
|
63
65
|
end
|
64
66
|
|
65
67
|
mocker = ActiveMocker::Base.new({schema: {path: [path to schema.rb file]},
|
data/lib/active_mocker.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
require "active_mocker/version"
|
2
2
|
$:.unshift File.expand_path('../../', __FILE__)
|
3
|
-
require '
|
3
|
+
require 'logger'
|
4
|
+
require 'active_mocker/logger'
|
5
|
+
require 'active_support/all'
|
4
6
|
require 'active_mocker/table'
|
7
|
+
require 'active_mocker/field'
|
8
|
+
require 'file_reader'
|
5
9
|
require 'active_mocker/config'
|
6
10
|
require 'active_mocker/reparameterize'
|
7
|
-
require 'active_mocker/field'
|
8
11
|
require 'active_mocker/active_record'
|
9
12
|
require 'active_mocker/model_reader'
|
10
13
|
require 'active_mocker/schema_reader'
|
11
14
|
require 'active_mocker/active_record/schema'
|
12
15
|
require 'active_mocker/base'
|
13
|
-
require '
|
16
|
+
require 'active_mocker/active_record'
|
17
|
+
require 'active_mocker/model_reader'
|
18
|
+
require 'active_mocker/reparameterize'
|
14
19
|
module ActiveMocker
|
15
20
|
|
16
21
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
$:.unshift File.expand_path('../../', __FILE__)
|
2
2
|
require 'active_mocker/active_record/scope'
|
3
3
|
require 'active_mocker/active_record/relationships'
|
4
|
+
require 'active_mocker/active_record/unknown_class_method'
|
4
5
|
|
5
6
|
module ActiveMocker
|
6
7
|
module ActiveRecord
|
7
8
|
class Base
|
8
9
|
extend Scope
|
9
10
|
extend Relationships
|
11
|
+
extend UnknownClassMethod
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
@@ -13,22 +13,22 @@ module Relationships
|
|
13
13
|
|
14
14
|
def has_many(*args)
|
15
15
|
@has_many ||= []
|
16
|
-
@has_many.push args
|
16
|
+
@has_many.push [args.first]
|
17
17
|
end
|
18
18
|
|
19
19
|
def has_one(*args)
|
20
20
|
@has_one ||= []
|
21
|
-
@has_one.push args
|
21
|
+
@has_one.push [args.first]
|
22
22
|
end
|
23
23
|
|
24
24
|
def belongs_to(*args)
|
25
25
|
@belongs_to ||= []
|
26
|
-
@belongs_to.push args
|
26
|
+
@belongs_to.push [args.first]
|
27
27
|
end
|
28
28
|
|
29
29
|
def has_and_belongs_to_many(*args)
|
30
30
|
@has_and_belongs_to_many ||= []
|
31
|
-
@has_and_belongs_to_many.push args
|
31
|
+
@has_and_belongs_to_many.push [args.first]
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
data/lib/active_mocker/base.rb
CHANGED
data/lib/active_mocker/config.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
$:.unshift File.expand_path('../../', __FILE__)
|
3
|
+
require 'logger'
|
4
|
+
require 'active_mocker/logger'
|
3
5
|
require 'string_reader'
|
4
6
|
require 'active_mocker/table'
|
5
7
|
require 'active_mocker/config'
|
@@ -30,6 +32,8 @@ describe ActiveMocker::Base do
|
|
30
32
|
config.model_relationships = true #default
|
31
33
|
config.model_methods = true #default
|
32
34
|
config.mass_assignment = true #default
|
35
|
+
# Logging
|
36
|
+
config.log_level = Logger::WARN #default
|
33
37
|
end
|
34
38
|
|
35
39
|
end
|
@@ -2,6 +2,7 @@ require 'rspec'
|
|
2
2
|
$:.unshift File.expand_path('../../', __FILE__)
|
3
3
|
require 'string_reader'
|
4
4
|
require 'file_reader'
|
5
|
+
require 'active_mocker/logger'
|
5
6
|
require 'active_mocker/active_record'
|
6
7
|
require 'active_mocker/model_reader'
|
7
8
|
require 'active_mocker/reparameterize'
|
@@ -121,5 +122,7 @@ describe ActiveMocker::ModelReader do
|
|
121
122
|
|
122
123
|
end
|
123
124
|
|
125
|
+
describe
|
126
|
+
|
124
127
|
end
|
125
128
|
|
data/spec/lib/model.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
class Model < ActiveRecord::Base
|
2
2
|
|
3
|
-
belongs_to :company
|
3
|
+
belongs_to :company, class_name: 'PlanServiceCategory'
|
4
4
|
has_many :users
|
5
5
|
has_one :account
|
6
6
|
has_and_belongs_to_many :disclosure
|
7
|
+
devise :database_authenticatable, :registerable,
|
8
|
+
:recoverable, :rememberable, :trackable, :validatable
|
7
9
|
|
8
10
|
def self.duper(value, *args)
|
9
11
|
|
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: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Zeisler
|
@@ -115,9 +115,11 @@ files:
|
|
115
115
|
- lib/active_mocker/active_record/relationships.rb
|
116
116
|
- lib/active_mocker/active_record/schema.rb
|
117
117
|
- lib/active_mocker/active_record/scope.rb
|
118
|
+
- lib/active_mocker/active_record/unknown_class_method.rb
|
118
119
|
- lib/active_mocker/base.rb
|
119
120
|
- lib/active_mocker/config.rb
|
120
121
|
- lib/active_mocker/field.rb
|
122
|
+
- lib/active_mocker/logger.rb
|
121
123
|
- lib/active_mocker/model_reader.rb
|
122
124
|
- lib/active_mocker/reparameterize.rb
|
123
125
|
- lib/active_mocker/schema_reader.rb
|