Skip to content

Commit

Permalink
feature(spec) validate that the enum was indeed defined on the model …
Browse files Browse the repository at this point in the history
…with both old and new syntax
  • Loading branch information
harunkumars committed Aug 21, 2024
1 parent 9003239 commit 26c8e45
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spec/rich_enums_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,41 +50,47 @@

course_class.rich_enum status: { active: 0, inactive: 1 }, alt: :name
expect(course_class).to have_received(:enum).with(:status, { active: 0, inactive: 1 })
expect(course_class.defined_enums).to include("status")
end

it "invokes the enum method with the correct arguments" do
allow(course_class).to receive(:enum).and_call_original

course_class.rich_enum status: { active: [0, 'LIVE'], inactive: [1, 'NOT_LIVE'] }, alt: :name
expect(course_class).to have_received(:enum).with(:status, { active: 0, inactive: 1 })
expect(course_class.defined_enums).to include("status")
end

it "invokes the enum method with the correct arguments" do
allow(course_class).to receive(:enum).and_call_original
course_class.rich_enum status: { active: [0, 'LIVE'], inactive: [1, 'NOT_LIVE'] }, prefix: true, alt: 'state'

expect(course_class).to have_received(:enum).with(:status, { active: 0, inactive: 1 }, prefix: true)
expect(course_class.defined_enums).to include("status")
end
else
it "invokes the enum method with the correct arguments" do
allow(course_class).to receive(:enum).and_call_original

course_class.rich_enum status: { active: 0, inactive: 1 }, alt: :name
expect(course_class).to have_received(:enum).with(status: { active: 0, inactive: 1 })
expect(course_class.defined_enums).to include("status")
end

it "invokes the enum method with the correct arguments" do
allow(course_class).to receive(:enum).and_call_original

course_class.rich_enum status: { active: [0, 'LIVE'], inactive: [1, 'NOT_LIVE'] }, alt: :name
expect(course_class).to have_received(:enum).with(status: { active: 0, inactive: 1 })
expect(course_class.defined_enums).to include("status")
end

it "invokes the enum method with the correct arguments" do
allow(course_class).to receive(:enum).and_call_original
course_class.rich_enum status: { active: [0, 'LIVE'], inactive: [1, 'NOT_LIVE'] }, _prefix: true, alt: 'state'

expect(course_class).to have_received(:enum).with(status: { active: 0, inactive: 1 }, _prefix: true)
expect(course_class.defined_enums).to include("status")
end
end
end
Expand Down

0 comments on commit 26c8e45

Please sign in to comment.