-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1 from site-prism/feature/add_dsl_validations
Add input spec and input dsl validator
- Loading branch information
Showing
5 changed files
with
46 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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
require_relative 'dsl/validation' |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
require_relative 'validation/input' |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module TestingRecord | ||
module DSL | ||
module Validation | ||
# [TestingRecord::DSL::Validation::Input] | ||
# Validations for direct inputs into creating models | ||
module Input | ||
def type_valid?(input) | ||
type_validations.include?(input) | ||
end | ||
|
||
private | ||
|
||
def type_validations = %i[singular plural] | ||
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe TestingRecord::DSL::Validation::Input do | ||
subject(:klazz) do | ||
Class.new do | ||
extend TestingRecord::DSL::Validation::Input | ||
end | ||
end | ||
|
||
describe '#type_valid?' do | ||
it 'is `true` when the type is singular' do | ||
expect(klazz.type_valid?(:singular)).to be true | ||
end | ||
|
||
it 'is `true` when the type is plural' do | ||
expect(klazz.type_valid?(:plural)).to be true | ||
end | ||
|
||
it 'is `false` for all other types' do | ||
expect(klazz.type_valid?(:foo)).to be false | ||
end | ||
end | ||
end |