Skip to content

Commit

Permalink
Fix typo in check_missing_methods! (#364)
Browse files Browse the repository at this point in the history
Fix typo in `check_missing_methods!`
  • Loading branch information
danwakefield authored Nov 11, 2019
2 parents 74b2072 + 9561d15 commit fe19baa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/statesman/adapters/active_record_queries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Adapters
module ActiveRecordQueries
def self.check_missing_methods!(base)
missing_methods = %i[transition_class initial_state].
reject { |_method| base.respond_to?(:method) }
reject { |m| base.respond_to?(m) }
return if missing_methods.none?

raise NotImplementedError,
Expand Down
28 changes: 28 additions & 0 deletions spec/statesman/adapters/active_record_queries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,32 @@ class UnknownModelTransition < OtherActiveRecordModelTransition; end
end
end
end

describe "check_missing_methods!" do
subject(:check_missing_methods!) { described_class.check_missing_methods!(base) }

context "when base has no missing methods" do
let(:base) do
Class.new do
def self.transition_class; end

def self.initial_state; end
end
end

it "does not raise an error" do
expect { check_missing_methods! }.to_not raise_exception(NotImplementedError)
end
end

context "when base has missing methods" do
let(:base) do
Class.new
end

it "raises an error" do
expect { check_missing_methods! }.to raise_exception(NotImplementedError)
end
end
end
end

0 comments on commit fe19baa

Please sign in to comment.