Skip to content

Commit

Permalink
Merge pull request #2 from site-prism/feature/add_type
Browse files Browse the repository at this point in the history
Feature/add type
  • Loading branch information
luke-hill committed Dec 20, 2023
2 parents 5c51078 + a155808 commit 96422c7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/testing_record/model.rb
@@ -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
@@ -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

0 comments on commit 96422c7

Please sign in to comment.