Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from site-prism/feature/add_type
Feature/add type
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |