active_mocker 2.0.0.beta1 → 2.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -1
  3. data/README.md +11 -18
  4. data/lib/active_mocker.rb +5 -0
  5. data/lib/active_mocker/config.rb +7 -8
  6. data/lib/active_mocker/{mock → deprecated_components}/mock_abilities.rb +19 -7
  7. data/lib/active_mocker/deprecated_components/rspec.rb +12 -0
  8. data/lib/active_mocker/display_errors.rb +64 -0
  9. data/lib/active_mocker/error_object.rb +46 -0
  10. data/lib/active_mocker/generate.rb +30 -64
  11. data/lib/active_mocker/mock.rb +1 -2
  12. data/lib/active_mocker/mock/association.rb +0 -2
  13. data/lib/active_mocker/mock/base.rb +270 -256
  14. data/lib/active_mocker/mock/belongs_to.rb +14 -20
  15. data/lib/active_mocker/mock/collection.rb +0 -6
  16. data/lib/active_mocker/mock/do_nothing_active_record_methods.rb +39 -41
  17. data/lib/active_mocker/mock/exceptions.rb +4 -11
  18. data/lib/active_mocker/mock/has_and_belongs_to_many.rb +0 -2
  19. data/lib/active_mocker/mock/has_many.rb +4 -5
  20. data/lib/active_mocker/mock/has_one.rb +5 -11
  21. data/lib/active_mocker/mock/hash_process.rb +14 -17
  22. data/lib/active_mocker/mock/mock_relation.rb +10 -0
  23. data/lib/active_mocker/mock/object_inspect.rb +29 -32
  24. data/lib/active_mocker/mock/queries.rb +14 -18
  25. data/lib/active_mocker/mock/records.rb +45 -43
  26. data/lib/active_mocker/mock/relation.rb +1 -4
  27. data/lib/active_mocker/mock/single_relation.rb +13 -17
  28. data/lib/active_mocker/mock/template_methods.rb +1 -4
  29. data/lib/active_mocker/mock_creator.rb +4 -5
  30. data/lib/active_mocker/mock_template/_associations.erb +6 -6
  31. data/lib/active_mocker/mock_template/_class_methods.erb +1 -1
  32. data/lib/active_mocker/mock_template/_scopes.erb +3 -3
  33. data/lib/active_mocker/parent_class.rb +1 -1
  34. data/lib/active_mocker/public_methods.rb +5 -2
  35. data/lib/active_mocker/rspec.rb +0 -8
  36. data/lib/active_mocker/rspec_helper.rb +0 -2
  37. data/lib/active_mocker/task.rake +0 -2
  38. data/lib/active_mocker/version.rb +1 -1
  39. metadata +36 -19
  40. data/lib/active_mocker/logger.rb +0 -15
  41. data/lib/active_mocker/output_capture.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb2357b680e38a103a603361d01ca9ed9a67f62f
4
- data.tar.gz: 0f82aa8aa703d9919650d19d5ff02eac1f4ad6ae
3
+ metadata.gz: 8936b1f4fe07483ea78ff2ec8268d9ffb583b6c7
4
+ data.tar.gz: 18b528c86620ba5988e94acb77a666e1cd4ad601
5
5
  SHA512:
6
- metadata.gz: ed04ff66eb99a25b4930262cdda6e124b26df1db6e2177e8f80ea20ef55d81ef8233dbdfda54b5c99dc9edb8454a8f5210ea57fe33cc5a4c76c2cc5b66604cd5
7
- data.tar.gz: 5417b116dc8afda6894b717e90c2fbfc212a44291aa92a2c717a39887e86e3842301ccd1c813290b9f536851064e4fe0fe4301abc286b451697a2b45ff22986c
6
+ metadata.gz: 494897b8098ec22bf7e35871b0b5dd993823203c66d2fa373d61025000010a47041c79e2240e03b939561c03f7c337bf3a8ae2577d52dba9640dc690523a1982
7
+ data.tar.gz: 9ea5b695ac94d7c02d5b791992c7ffaea6d0e8bbfd06f053d11befa2f8dc704d97e42e4d0220480a4e442a3dabc9d493d1861be0a021530e73100d1d2e1f3bb0
@@ -1,10 +1,27 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 2.0.0.pre1 - 2015-12-13
5
+ ### Enhancement
6
+ - The mock append name is now changeable using `ActiveMocker::Config.mock_append_name=`. The default still being `Mock`.
7
+ - `ActiveMocker::Mock::MockRelation(mock, collection)` to create separate independent mock collections.
8
+ - Change `ActiveMocker::Mock::Base` to `ActiveMocker::Base`
9
+ - Provide more control over error when running `rake active_mocker:build`, error_verbosity now has setting for 0 to 3.
10
+
11
+ ### Fix
12
+ - Reduce restriction on Virtus gem to 1.0.any
13
+ - When id is not a fixnum and make it match ActiveRecord behavior of calling `#to_i`.
14
+
15
+ ### Depracated
16
+ - Moved `ActiveMocker::MockAbilities` into "active_mocker/deprecated_components/mock_abilities" if a project is still dependent on it this file it can be required and used at least until version 2.1. The alternative is to use `RSpec` verified doubles.
17
+ - `#mock_class("Mock")` method has been moved to "active_mocker/deprecated_components/rspec_helper" if a project is still dependent on it this file it can be required and used at least until version 2.1. The alternative is to use the new api that is accessible by `#active_mocker`.
18
+
4
19
  ## 2.0.0.beta1 - 2015-12-01
5
20
  ### Enhancement
6
21
  - db/schema.rb is no longer required to generate mocks.
7
- - `ActiveMocker::Config.disable_modules_and_constants=` Non locally defineded Modules are included/extended by default as well as constant declaration. To Disable to feature set to `true`.
22
+ - Much better support for Single Table Inheritance and gems that add functionality by being the parent class of model.
23
+ - New DB types can be registered with this API. `ActiveRecordSchemaScrapper::Attribute.register_type(name: :array, klass: Array)`
24
+ - `ActiveMocker::Config.disable_modules_and_constants=` Non locally defined Modules are included/extended by default as well as constant declaration. To Disable to feature set to `true`.
8
25
  - `MODEL=User rake active_mocker:build` no longer takes a model name to generate just that mock. It now takes a path to a model file. `MODEL=[path-to-model] rake active_mocker:build`
9
26
 
10
27
  ### Removed
data/README.md CHANGED
@@ -106,13 +106,10 @@ end
106
106
  class Person < ActiveRecord::Base
107
107
  belongs_to :account
108
108
 
109
- def bar(name, type=nil)
109
+ def self.bar(name, type=nil)
110
110
  puts name
111
111
  end
112
112
 
113
- def self.bar
114
- end
115
-
116
113
  end
117
114
  ```
118
115
  -----------------
@@ -136,8 +133,8 @@ end
136
133
  ----------
137
134
 
138
135
  * Assigning the tag `active_mocker:true` will stub any ActiveRecord model Constants for Mock classes in an `it` or a `before/after(:each)`. This removes any need for dependency injection. Write tests and code like you would normally.
139
- * To stub any Constants in `before(:all)`, `after(:all)` use `mock_class('ClassName')`.
140
- * Mock state will be cleaned up for you in an `after(:all)`. To clean state your self use `ActiveMocker::LoadedMocks.delete_all`.
136
+ * To stub any Constants in `before(:all)`, `after(:all)` use `active_mocker.find('ClassName')`.
137
+ * Mock state will be cleaned up for you in an `after(:all)`. To clean state your self use `active_mocker.delete_all`.
141
138
 
142
139
  ---------
143
140
 
@@ -206,11 +203,6 @@ end
206
203
 
207
204
  Person.bar('foo', 'type')
208
205
  => "Now implemented with foo and type"
209
-
210
- # Rspec 3 mock class method
211
- allow_any_instance_of(Person).to receive(:bar) do
212
- "Now implemented"
213
- end
214
206
  ```
215
207
 
216
208
  #### When the model changes, the mock fails
@@ -222,7 +214,7 @@ end
222
214
  class Person < ActiveRecord::Base
223
215
  belongs_to :account
224
216
 
225
- def bar(name)
217
+ def self.bar(name)
226
218
  puts name
227
219
  end
228
220
 
@@ -231,7 +223,7 @@ end
231
223
 
232
224
  --------------
233
225
  ```ruby
234
- Person.new.bar('foo', 'type')
226
+ Person.bar('foo', 'type')
235
227
  => ArgumentError: wrong number of arguments (2 for 1)
236
228
  ```
237
229
  ----------------
@@ -241,7 +233,7 @@ Person.new.bar('foo', 'type')
241
233
  class Person < ActiveRecord::Base
242
234
  belongs_to :account
243
235
 
244
- def foo(name, type=nil)
236
+ def self.foo(name, type=nil)
245
237
  puts name
246
238
  end
247
239
 
@@ -249,10 +241,10 @@ end
249
241
  ```
250
242
  --------------
251
243
  ```ruby
252
- allow(person).to receive(:bar) do |name, type=nil|
244
+ allow(Person).to receive(:bar) do |name, type=nil|
253
245
  "Now implemented with #{name} and #{type}"
254
246
  end
255
- => NoMethodError : undefined method `bar' for class ` PersonMock '
247
+ => RSpec::Mocks::MockExpectationError: PersonMock does not implement: bar
256
248
  ```
257
249
  ### Constants and Modules
258
250
 
@@ -353,17 +345,18 @@ See [Documentation](http://rdoc.info/github/zeisler/active_mocker/master/ActiveM
353
345
 
354
346
 
355
347
  ### Schema/Migration Option Support
348
+ * A db/schema.rb is not required.
356
349
  * All schema types are supported and coerced by [Virtus](https://github.com/solnic/virtus). If coercion fails the passed value will be retained.
357
350
  * Default value is supported.
358
351
  * Scale and Precision are not supported.
359
352
 
360
353
  ### Known Limitations
361
- * Model names and table names must follow the default ActiveRecord naming pattern.
354
+ * Namespaced modules are not currently supported.
362
355
  * When an association is set in one object it may not always be reflective in other objects, especially when it is a non standard/custom association. See [test_rails_4_app/spec/active_record_compatible_api.rb](https://github.com/zeisler/active_mocker/blob/master/test_rails_4_app/spec/active_record_compatible_api.rb) for a complete list of supported associations.
363
356
  * Validation/Callbacks are not supported.
364
357
  * Sql queries, joins, etc will never be supported.
365
358
  * A record that has been created and then is modified will persist changes without calling `#save`, beware of this difference.
366
- * This is not a full replacement for ActiveRecord. It has been simplified, having only the most essential parts, so that the is code easier to maintain. I have done my best to make it work correctly, but it is up to you to know how ActiveRecord works and know it's limitations. I aim to make the code easy to read so that it can be understood and modified by it's users.
359
+ * This is not a full replacement for ActiveRecord. It's simplified, with only the most essential parts. There are many tests to verify that is works the same as ActiveRecord, but's yours responsibility to know how ActiveRecord works.
367
360
 
368
361
  ## Inspiration
369
362
  Thanks to Jeff Olfert for being my original inspiration for this project.
@@ -1,3 +1,5 @@
1
+ require "rubygems"
2
+
1
3
  require 'active_mocker/version'
2
4
  require 'active_mocker/railtie' if defined?(Rails)
3
5
  require 'ruby-progressbar'
@@ -8,9 +10,12 @@ require 'active_mocker/config'
8
10
  require "reverse_parameters"
9
11
  require "active_record_schema_scrapper"
10
12
  require "dissociated_introspection"
13
+ require "colorize"
11
14
  require "active_mocker/null_progress"
12
15
  require "active_mocker/progress"
13
16
  require "active_mocker/parent_class"
14
17
  require "active_mocker/template_creator"
15
18
  require "active_mocker/mock_creator"
19
+ require "active_mocker/error_object"
20
+ require "active_mocker/display_errors"
16
21
  require "active_mocker/generate"
@@ -1,5 +1,4 @@
1
1
  module ActiveMocker
2
-
3
2
  class Config
4
3
  class << self
5
4
 
@@ -8,17 +7,15 @@ module ActiveMocker
8
7
  :single_model_path,
9
8
  :progress_bar,
10
9
  :error_verbosity,
11
- :disable_modules_and_constants
12
- #TODO add disable include/extend of modules
13
- #TODO disable scope methods
14
- #disable instance methods, class methods
15
- # can't disable attribute as of yet
10
+ :disable_modules_and_constants,
11
+ :mock_append_name
16
12
 
17
13
  def model_base_classes=(val)
18
14
  @model_base_classes = val
19
15
  end
20
16
 
21
- def set(&block)
17
+ # @see ActiveMocker#configure
18
+ def set
22
19
  load_defaults
23
20
  yield self
24
21
  end
@@ -29,6 +26,7 @@ module ActiveMocker
29
26
  @disable_modules_and_constants = false
30
27
  @model_dir = nil unless @model_dir
31
28
  @mock_dir = nil unless @mock_dir
29
+ @mock_append_name = "Mock"
32
30
  rails_defaults if Object.const_defined?('Rails')
33
31
  end
34
32
 
@@ -38,7 +36,8 @@ module ActiveMocker
38
36
  :log_location,
39
37
  :single_model_path,
40
38
  :progress_bar,
41
- :error_verbosity
39
+ :error_verbosity,
40
+ :mock_append_name
42
41
  ].each { |ivar| instance_variable_set("@#{ivar}", nil) }
43
42
  end
44
43
 
@@ -1,7 +1,6 @@
1
1
  module ActiveMocker
2
- module Mock
2
+ # @deprecated to keep using until removal, require this file.
3
3
  module MockAbilities
4
-
5
4
  module InstanceAndClassMethods
6
5
 
7
6
  def mock_instance_method(method, exe_bind=false, &block)
@@ -15,6 +14,12 @@ module ActiveMocker
15
14
  mockable_class_methods.clear
16
15
  end
17
16
 
17
+ # @deprecated
18
+ def clear_mock
19
+ clear_mocked_methods
20
+ delete_all
21
+ end
22
+
18
23
  private
19
24
 
20
25
  def mockable_instance_methods
@@ -27,7 +32,7 @@ module ActiveMocker
27
32
  end
28
33
 
29
34
  def is_implemented(val, method, type, call_stack)
30
- raise NotImplementedError, "#{type}#{method} for Class: #{class_name}. To continue stub the method.", call_stack if val.nil?
35
+ raise NotImplementedError, "#{type}#{method} for Class: #{class_name}. To continue stub the method.", call_stack if val.nil?
31
36
  end
32
37
 
33
38
  def execute_block(method)
@@ -41,6 +46,12 @@ module ActiveMocker
41
46
  base.extend(ClassMethods)
42
47
  end
43
48
 
49
+ def self.prepended(base)
50
+ class << base
51
+ prepend(ClassMethods)
52
+ end
53
+ end
54
+
44
55
  module ClassMethods
45
56
 
46
57
  include InstanceAndClassMethods
@@ -87,12 +98,13 @@ module ActiveMocker
87
98
  attr_accessor :block, :arguments, :exe_bind
88
99
 
89
100
  def initialize(block, exe_bind)
90
- @block = block
91
- @exe_bind = exe_bind
101
+ @block = block
102
+ @exe_bind = exe_bind
92
103
  end
93
-
94
104
  end
95
-
96
105
  end
106
+
107
+ class Base
108
+ prepend MockAbilities
97
109
  end
98
110
  end
@@ -0,0 +1,12 @@
1
+ require "active_mocker/rspec"
2
+
3
+ module ActiveMocker
4
+ module Rspec
5
+ # @deprecated method, will be removed in version 2.1
6
+ # Use +active_mocker.mocks.find('ClassName')+ instead
7
+ # To keep using until removal, require this file.
8
+ def mock_class(*args)
9
+ active_mocker.mocks.find(*args)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,64 @@
1
+ module ActiveMocker
2
+ class DisplayErrors
3
+ attr_reader :errors, :model_count
4
+ attr_accessor :success_count
5
+
6
+ def initialize(model_count)
7
+ @errors = []
8
+ @success_count = 0
9
+ @model_count = model_count
10
+ end
11
+
12
+ def add(errors)
13
+ @errors.concat([*errors])
14
+ end
15
+
16
+ def wrap_errors(errors, model_name, type: nil)
17
+ add errors.map { |e| ErrorObject.build_from(object: e, class_name: model_name, type: type ? type : e.try(:type)) }
18
+ end
19
+
20
+ def wrap_an_exception(e, model_name)
21
+ add ErrorObject.build_from(exception: e, class_name: model_name)
22
+ end
23
+
24
+ def uniq_errors
25
+ @uniq_errors ||= errors.flatten.compact.uniq.sort_by(&:class_name)
26
+ end
27
+
28
+ def display_errors
29
+ uniq_errors.each do |e|
30
+ if ActiveMocker::Config.error_verbosity == 3
31
+ STDERR.puts "#{e.class_name} has the following errors:"
32
+ STDERR.puts e.message.colorize(e.level_color)
33
+ STDERR.puts e.level
34
+ STDERR.puts e.original_error.message.colorize(e.level_color) if e.original_error?
35
+ STDERR.puts e.original_error.backtrace if e.original_error?
36
+ STDERR.puts e.original_error.class.name.colorize(e.level_color) if e.original_error?
37
+ elsif ActiveMocker::Config.error_verbosity == 2
38
+ STDERR.puts e.message.colorize(e.level_color)
39
+ end
40
+ end
41
+ if ActiveMocker::Config.error_verbosity > 0 && uniq_errors.count > 0
42
+ STDERR.puts "Error Summary"
43
+ error_summary
44
+ end
45
+ failure_count_message
46
+ if ActiveMocker::Config.error_verbosity > 0 && uniq_errors.count > 0
47
+ STDERR.puts "To see more/less detail set error_verbosity = 0, 1, 2, 3"
48
+ end
49
+ end
50
+
51
+ def error_summary
52
+ error_count = uniq_errors.count { |e| [:red].include?(e.level_color) }
53
+ warn = uniq_errors.count { |e| [:yellow].include?(e.level_color) }
54
+ info = uniq_errors.count { |e| [:default].include?(e.level_color) }
55
+ STDERR.puts "errors: #{error_count}, warn: #{warn}, info: #{info}"
56
+ end
57
+
58
+ def failure_count_message
59
+ if ActiveMocker::Config.error_verbosity > 0 && (success_count < model_count || uniq_errors.count > 0)
60
+ STDERR.puts "#{ model_count - success_count } mock(s) out of #{model_count} failed."
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,46 @@
1
+ module ActiveMocker
2
+ class ErrorObject
3
+
4
+ attr_reader :message, :level, :original_error, :type, :class_name
5
+
6
+ def initialize(level: :warn, message:, class_name:, type:, original_error: nil)
7
+ @level = level
8
+ @message = message
9
+ @class_name = class_name
10
+ @type = type
11
+ @original_error = original_error
12
+ end
13
+
14
+ def self.build_from(object: nil, exception: nil, class_name: nil, type: nil)
15
+ if object
16
+ args = [:message, :original_error, :level, :type, :class_name].each_with_object({}) do |meth, hash|
17
+ hash[meth] = object.public_send(meth) if object.respond_to? meth
18
+ end
19
+ args[:type] = type unless type.nil?
20
+ args[:class_name] = class_name unless class_name.nil?
21
+ return self.new(args)
22
+ elsif exception && class_name
23
+ return self.new(message: exception.message,
24
+ class_name: class_name,
25
+ original_error: exception,
26
+ type: type ? type : :standard_error)
27
+ end
28
+ raise ArgumentError
29
+ end
30
+
31
+ def original_error?
32
+ original_error.present?
33
+ end
34
+
35
+ def level_color
36
+ case level
37
+ when :standard_error, :fatal, :error
38
+ :red
39
+ when :warn
40
+ :yellow
41
+ when :info
42
+ :default
43
+ end
44
+ end
45
+ end
46
+ end
@@ -5,95 +5,65 @@ module ActiveMocker
5
5
  raise ArgumentError, "mock_dir is missing a valued value!" if config.mock_dir.nil? || config.mock_dir.empty?
6
6
  create_mock_dir
7
7
  raise ArgumentError, "model_dir is missing a valued value!" if config.model_dir.nil? || config.model_dir.empty? || !Dir.exists?(config.model_dir)
8
- @success_count = 0
9
- @errors = []
8
+ @display_errors = DisplayErrors.new(models_paths.count)
10
9
  end
11
10
 
12
- # @returns self
11
+ # @return self
13
12
  def call
14
13
  progress_init
15
14
  models_paths.each do |file|
16
- model_name = model_name(file)
17
- model = model_name.constantize
18
- mock_file_name = "#{model_name.underscore}_#{mock_append_name.underscore}.rb"
19
- mock_file_path = File.join(Config.mock_dir, mock_file_name)
20
- schema_scrapper = schema_scrapper(model)
15
+ model_name = model_name(file)
16
+ model = get_model_const(model_name)
17
+ mock_file_name = "#{model_name.underscore}_#{config.mock_append_name.underscore}.rb"
18
+ mock_file_path = File.join(Config.mock_dir, mock_file_name)
19
+ schema_scrapper = ActiveRecordSchemaScrapper.new(model: model)
21
20
  File.open(mock_file_path, 'w') do |file_out|
22
21
  begin
23
- r = create_mock(file, file_out, schema_scrapper)
24
- collect_errors(mock_file_path, r, schema_scrapper)
25
- @success_count += 1 if r.completed?
22
+ result = create_mock(file, file_out, schema_scrapper)
23
+ collect_errors(mock_file_path, result.errors, schema_scrapper, model_name)
24
+ display_errors.success_count += 1 if result.completed?
26
25
  rescue => e
27
26
  rescue_clean_up(e, file_out, model_name)
28
27
  end
29
28
  end
30
29
  progress.increment
31
30
  end
32
- display_errors
33
- failure_count_message
31
+ display_errors.display_errors
34
32
  self
35
33
  end
36
34
 
35
+ def get_model_const(model_name)
36
+ model_name.constantize
37
+ rescue => e
38
+ display_errors.wrap_an_exception(e, model_name)
39
+ end
40
+
37
41
  private
38
42
 
39
- attr_reader :success_count, :errors
43
+ attr_reader :display_errors
40
44
 
41
45
  def create_mock(file, file_out, schema_scrapper)
42
46
  MockCreator.new(file: File.open(file),
43
47
  file_out: file_out,
44
48
  schema_scrapper: schema_scrapper,
45
49
  klasses_to_be_mocked: model_names,
46
- enabled_partials: enabled_partials).create
50
+ enabled_partials: enabled_partials,
51
+ mock_append_name: config.mock_append_name).create
47
52
  end
48
53
 
49
- def collect_errors(mock_file_path, r, schema_scrapper)
50
- unless r.errors.empty?
51
- File.delete(mock_file_path)
52
- errors.concat(r.errors)
53
- end
54
- unless schema_scrapper.associations.errors.empty?
55
- errors.concat(schema_scrapper.associations.errors.uniq(&:message))
56
- end
57
- unless schema_scrapper.attributes.errors.empty?
58
- errors.concat(schema_scrapper.attributes.errors.uniq(&:message))
54
+ def collect_errors(mock_file_path, create_mock_errors, schema_scrapper, model_name)
55
+ unless create_mock_errors.empty?
56
+ File.delete(mock_file_path) if File.exists?(mock_file_path)
57
+ display_errors.add(create_mock_errors)
59
58
  end
59
+ display_errors.wrap_errors(schema_scrapper.associations.errors, model_name, type: :associations)
60
+ display_errors.wrap_errors(schema_scrapper.attributes.errors, model_name, type: :attributes)
60
61
  end
61
62
 
62
63
  def rescue_clean_up(e, file_out, model_name)
63
- file_out.close
64
- File.delete(file_out.path)
65
- e = OpenStruct.new(message: e.message, class_name: model_name, original_error: e) if e.class <= Exception
66
- errors << e
67
- end
68
-
69
- def schema_scrapper(model)
70
- # if model.respond_to?(:abstract_class?) && model.abstract_class?
71
- # null_collection = OpenStruct.new(to_a: [], errors: [])
72
- # OpenStruct.new(associations: null_collection, attributes: null_collection, abstract_class?: true)
73
- # else
74
- ActiveRecordSchemaScrapper.new(model: model)
75
- # end
76
- end
77
-
78
- def display_errors
79
- errors.flatten.each do |e|
80
- if config.error_verbosity == 2
81
- puts "#{e.class_name} has failed:"
82
- puts e.message
83
- puts e.original_error.message if e.respond_to? :original_error
84
- puts e.original_error.backtrace if e.respond_to? :original_error
85
- puts e.original_error.class.name if e.respond_to? :original_error
86
- elsif config.error_verbosity == 1
87
- puts e.message
88
- end
89
- end
90
- end
91
-
92
- def failure_count_message
93
- if config.error_verbosity > 0 && success_count < models_paths.count
94
- "#{ models_paths.count - success_count } mock(s) out of #{models_paths.count} failed."\
95
- "To see more detail set error_verbosity = 2 or to mute this error set error_verbosity = 0."
96
- end
64
+ file_out.close unless file_out.closed?
65
+ File.delete(file_out.path) if File.exists?(file_out.path)
66
+ display_errors.wrap_an_exception(e, model_name)
97
67
  end
98
68
 
99
69
  def model_name(file)
@@ -124,10 +94,6 @@ module ActiveMocker
124
94
  FileUtils::mkdir_p(config.mock_dir) unless Dir.exists?(config.mock_dir)
125
95
  end
126
96
 
127
- def mock_append_name
128
- 'Mock'
129
- end
130
-
131
97
  def enabled_partials
132
98
  if config.disable_modules_and_constants
133
99
  MockCreator.enabled_partials_default - [*:modules_constants]
@@ -136,4 +102,4 @@ module ActiveMocker
136
102
  end
137
103
  end
138
104
  end
139
- end
105
+ end