Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix warning when overriding an exsiting method
- Loading branch information
Showing
3 changed files
with
66 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'spec_helper' | ||
|
||
describe 'warns when overrides a method' do | ||
module Clumsy | ||
def self.included base | ||
base.send :include, AASM | ||
|
||
base.aasm do | ||
state :valid | ||
event(:save) { } | ||
end | ||
end | ||
end | ||
|
||
describe 'state' do | ||
class Base | ||
def valid?; end | ||
end | ||
it do | ||
expect { Base.send :include, Clumsy }. | ||
to output(/Base: overriding method 'valid\?'!/).to_stderr | ||
end | ||
end | ||
|
||
describe 'event' do | ||
context 'may?' do | ||
class Base | ||
def may_save?; end | ||
def save!; end | ||
def save; end | ||
end | ||
let(:klass) { Base } | ||
it do | ||
expect { Base.send :include, Clumsy }. | ||
to output(/Base: overriding method 'may_save\?'!/).to_stderr | ||
expect { Base.send :include, Clumsy }. | ||
to output(/Base: overriding method 'save!'!/).to_stderr | ||
expect { Base.send :include, Clumsy }. | ||
to output(/Base: overriding method 'save'!/).to_stderr | ||
end | ||
end | ||
end | ||
end |