Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factored out primitive/string type lookup to Attribute
- Loading branch information
Showing
7 changed files
with
78 additions
and
12 deletions.
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,3 +1,3 @@ | ||
--- | ||
threshold: 19.0 | ||
total_score: 200 | ||
total_score: 201 |
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
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
19 changes: 19 additions & 0 deletions
19
spec/unit/virtus/attribute/class_methods/from_primitive_spec.rb
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 @@ | ||
require 'spec_helper' | ||
|
||
describe Virtus::Attribute, '.from_primitive' do | ||
subject { object.from_primitive(primitive) } | ||
|
||
let(:object) { described_class } | ||
|
||
context 'when the primitive maps to an Attribute' do | ||
let(:primitive) { String } | ||
|
||
it { should equal(Virtus::Attribute::String) } | ||
end | ||
|
||
context 'when the primitive defaults to Object' do | ||
let(:primitive) { Class.new } | ||
|
||
it { should equal(Virtus::Attribute::Object) } | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
spec/unit/virtus/attribute/class_methods/from_string_spec.rb
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 @@ | ||
require 'spec_helper' | ||
|
||
describe Virtus::Attribute, '.from_string' do | ||
subject { object.from_string(string.to_s) } | ||
|
||
let(:object) { described_class } | ||
|
||
context 'when the string maps to an Attribute' do | ||
let(:string) { 'String' } | ||
|
||
it { should equal(Virtus::Attribute::String) } | ||
end | ||
|
||
context 'when the string does not map to an Attribute' do | ||
let(:string) { 'Unknown' } | ||
|
||
it { should be_nil } | ||
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