Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add type #2

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/testing_record/model.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# frozen_string_literal: true

module TestingRecord
# The top level Model. Most of the behaviours specified here are fairly rudimentary ones that will then
# include other behaviour(s), from the included modules
class Model
class << self
# Set the type of model, this should be one of `:singular` or `:plural`
#
# @return [Symbol]
def type(type)
@type = type
end
end
end
end
24 changes: 23 additions & 1 deletion spec/testing_record/model_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# frozen_string_literal: true

RSpec.describe TestingRecord::Model do
it { is_expected.to be_a(TestingRecord::Model) }
context 'when classified as a singular model' do
let(:model) do
Class.new(TestingRecord::Model) do
type :singular
end
end

it 'sets the singular model properties' do
expect(model.instance_variable_get(:@type)).to eq(:singular)
end
end

context 'when classified as a plural model' do
let(:model) do
Class.new(TestingRecord::Model) do
type :plural
end
end

it 'sets the singular model properties' do
expect(model.instance_variable_get(:@type)).to eq(:plural)
end
end
end