Skip to content

Commit

Permalink
test: Add already defined method spec
Browse files Browse the repository at this point in the history
  • Loading branch information
hatsu38 committed Aug 28, 2024
1 parent 9e2fc62 commit 00c1497
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion spec/enum/enum_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class Neighborhood < ActiveHash::Base
describe "define_enum_methods" do
class Movie < ActiveHash::Base
include ActiveHash::Enum
include ActiveHash::Associations

self.data = [
{:name => 'Die Hard 2', :rating => '4.3'},
Expand All @@ -107,6 +106,28 @@ class Movie < ActiveHash::Base
expect(Movie::IN_OUT.die_hard_2?).to be_falsey
expect(Movie::IN_OUT.the_informant?).to be_falsey
end

context "already defined method" do
it "overrides the method" do
class Movie < ActiveHash::Base
def die_hard_2?
true
end
end

expect(Movie::DIE_HARD_2.die_hard_2?).to be_truthy
expect(Movie::DIE_HARD_2.the_informant?).to be_falsey
expect(Movie::DIE_HARD_2.in_out?).to be_falsey

expect(Movie::THE_INFORMANT.the_informant?).to be_truthy
expect(Movie::THE_INFORMANT.die_hard_2?).to be_truthy
expect(Movie::THE_INFORMANT.in_out?).to be_falsey

expect(Movie::IN_OUT.in_out?).to be_truthy
expect(Movie::IN_OUT.die_hard_2?).to be_truthy
expect(Movie::IN_OUT.the_informant?).to be_falsey
end
end
end
end

Expand Down

0 comments on commit 00c1497

Please sign in to comment.