active_mocker 1.1.2 → 1.1.3

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: bfe27b7374829d87d0aa1c346ecee3fb84e590f9
4
- data.tar.gz: 5032e5a828552e52cd2f94b0ea9fcd85aaaeb43e
3
+ metadata.gz: addb986f00f2c8a59ad022a22a1617214d46b058
4
+ data.tar.gz: 9e77573e2e57c8bb14273c4715b2fd642e3022da
5
5
  SHA512:
6
- metadata.gz: debf17b98ec1e2204d28a18b80fadf6e753ce90592eee6203fe842e475c21cce8f6c80d96ce0be70c1d990ff7dc7955f5d469cbd1852ee903e3f127bdd2afaeb
7
- data.tar.gz: ec9343f533db64c8206fbb8349a7d683d8baf426d8980582918ba9556d2e71e6ebfb231cf3838606e376fcf8467a4f4abe701f9b8910efb7557f1347014992d3
6
+ metadata.gz: e40f73589ec2ea036b515fa33953515235be712e8793b90e3407387a0961a12fadacf81da5174b69c4709f715237f8c4e51fdf5a508892af31b2a4d63d445941
7
+ data.tar.gz: a64603e11da45d5df1f6f86c1b95c37dd7274682f2fc8edce0d0425da415d7e0be837c59cdf664465a8eca69f9675cf59cb536b63f7a9681bfb84adbbb5f3693
data/README.md CHANGED
@@ -77,7 +77,7 @@ Or install it yourself as:
77
77
  person_mock.first_name
78
78
  => "Dustin"
79
79
 
80
- ### When schema.rb changes the mock fails
80
+ ### When schema.rb changes, the mock fails
81
81
 
82
82
  #db/schema.rb
83
83
 
@@ -117,7 +117,7 @@ Or install it yourself as:
117
117
  "Now implemented"
118
118
  end
119
119
 
120
- ### When the model changes the mock fails
120
+ ### When the model changes, the mock fails
121
121
 
122
122
  #app/models/person.rb
123
123
 
@@ -200,7 +200,7 @@ ActiveHash is a simple base class that allows you to use a ruby hash as a readon
200
200
  => 0
201
201
 
202
202
 
203
- ::find_by
203
+ #### ::find_by
204
204
 
205
205
  person = PersonMock.create(first_name: 'Dustin')
206
206
 
@@ -210,7 +210,8 @@ ActiveHash is a simple base class that allows you to use a ruby hash as a readon
210
210
 
211
211
  ### Known Limitations
212
212
 
213
- **::mock** model names and table names must follow the default ActiveRecord naming pattern.
213
+ * **::mock** model names and table names must follow the default ActiveRecord naming pattern.
214
+ * Included/extended modules will not be loaded unless they are required explicitly.
214
215
 
215
216
  ## Contributing
216
217
 
@@ -2,6 +2,7 @@ $:.unshift File.expand_path('../../', __FILE__)
2
2
  require 'active_mocker/active_record/scope'
3
3
  require 'active_mocker/active_record/relationships'
4
4
  require 'active_mocker/active_record/unknown_class_method'
5
+ require 'active_mocker/active_record/unknown_module'
5
6
 
6
7
  module ActiveMocker
7
8
  module ActiveRecord
@@ -9,6 +10,7 @@ module ActiveMocker
9
10
  extend Scope
10
11
  extend Relationships
11
12
  extend UnknownClassMethod
13
+ extend UnknownModule
12
14
  end
13
15
  end
14
16
  end
@@ -3,7 +3,7 @@ module ActiveMocker
3
3
  module UnknownClassMethod
4
4
 
5
5
  def method_missing(meth, *args)
6
- Logger_.debug "ActiveMocker ::#{meth} called from class #{self.name} is unknown and will not be available in mock."
6
+ Logger_.debug "ActiveMocker :: #{meth} called from class #{self.name} is unknown and will not be available in mock."
7
7
  end
8
8
 
9
9
  end
@@ -0,0 +1,25 @@
1
+ module ActiveMocker
2
+
3
+ module UnknownModule
4
+
5
+ def include(_module)
6
+ begin
7
+ super _module
8
+ rescue => e
9
+ Logger_.debug e
10
+ Logger_.debug "ActiveMocker :: Can't include module #{_module} from class #{self.name}.\n #{caller}"
11
+
12
+ end
13
+ end
14
+
15
+ def extend(_module)
16
+ begin
17
+ super _module
18
+ rescue
19
+ Logger_.debug "ActiveMocker :: Can't extend module #{_module} from class #{self.name}..\n #{caller}"
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -20,9 +20,22 @@ module ActiveMocker
20
20
  end
21
21
 
22
22
  def eval_file
23
- m = Module.new
24
- m.module_eval(read_file)
25
- m.const_get m.constants.first
23
+ failure = true
24
+ while failure
25
+ begin
26
+ m = Module.new
27
+ m.module_eval(read_file)
28
+ rescue NameError => e
29
+ result = e.to_s.scan /::(\w*)$/ # gets the Constant name from error
30
+ const_name = result.flatten.first
31
+ Logger_.debug "ActiveMocker :: Can't can't find Constant #{const_name} from class #{model_name}..\n #{caller}"
32
+ Object.const_set(const_name,const_name)
33
+ next
34
+ end
35
+ failure = false
36
+ model = m.const_get m.constants.first
37
+ end
38
+ model
26
39
  end
27
40
 
28
41
  def read_file
@@ -1,3 +1,3 @@
1
1
  module ActiveMocker
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
@@ -32,7 +32,7 @@ describe ActiveMocker::Base do
32
32
  #config.model_methods = true #default
33
33
  #config.mass_assignment = true #default
34
34
  # Logging
35
- config.log_level = Logger::WARN #default
35
+ config.log_level = Logger::DEBUG #default
36
36
  end
37
37
 
38
38
  end
@@ -1,5 +1,6 @@
1
1
  class Model < ActiveRecord::Base
2
-
2
+ include FooBar
3
+ extend Baz
3
4
  belongs_to :company, class_name: 'PlanServiceCategory'
4
5
  has_many :users
5
6
  has_one :account
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: 1.1.2
4
+ version: 1.1.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-04-03 00:00:00.000000000 Z
11
+ date: 2014-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -120,6 +120,7 @@ files:
120
120
  - lib/active_mocker/active_record/schema.rb
121
121
  - lib/active_mocker/active_record/scope.rb
122
122
  - lib/active_mocker/active_record/unknown_class_method.rb
123
+ - lib/active_mocker/active_record/unknown_module.rb
123
124
  - lib/active_mocker/base.rb
124
125
  - lib/active_mocker/config.rb
125
126
  - lib/active_mocker/field.rb