1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

reduce warning output when running specs

This commit is contained in:
Thorsten Böttger 2017-02-10 22:00:03 +11:00
parent 8a63cf504f
commit 0a11594066
4 changed files with 16 additions and 6 deletions

View file

@ -208,7 +208,9 @@ module AASM
klass.defined_enums.values.any?{ |methods|
methods.keys{| enum | enum + '?' == method_name }
})
@state_machine.config.logger.warn "#{klass.name}: overriding method '#{method_name}'!"
unless AASM::Configuration.hide_warnings
@state_machine.config.logger.warn "#{klass.name}: overriding method '#{method_name}'!"
end
end
klass.send(:define_method, method_name, method_definition)

View file

@ -34,5 +34,9 @@ module AASM
# Configure a logger, with default being a Logger to STDERR
attr_accessor :logger
class << self
attr_accessor :hide_warnings
end
end
end

View file

@ -1,5 +1 @@
RSpec.configure do |config|
config.before(:each) do
allow_any_instance_of(Logger).to receive(:warn)
end
end
AASM::Configuration.hide_warnings = true

View file

@ -1,6 +1,14 @@
require 'spec_helper'
describe 'warns when overrides a method' do
before do
AASM::Configuration.hide_warnings = false
end
after do
AASM::Configuration.hide_warnings = true
end
module Clumsy
def self.included base
base.send :include, AASM