-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f5dd43
commit f868882
Showing
19 changed files
with
96 additions
and
119 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,36 @@ | ||
require_relative '../helper' | ||
require 'helper' | ||
|
||
describe DataMiner::Attribute do | ||
before do | ||
DataMiner.unit_converter = :alchemist | ||
end | ||
|
||
describe '#enforce_conversion_options' do | ||
it 'raises an error if no converter is set but options warrant conversion' do | ||
DataMiner.unit_converter = nil | ||
attribute = DataMiner::Attribute.new :foo, 'bar', :from_units => :pounds, :to_units => :kilograms | ||
assert_raise DataMiner::Attribute::NoConverterSet do | ||
attribute.send(:enforce_conversion_options) | ||
end | ||
end | ||
it 'does not raise an error if a converter is set and options warrant conversion' do | ||
attribute = DataMiner::Attribute.new :foo, 'bar', :from_units => :pounds, :to_units => :kilograms | ||
assert_nothing_raised do | ||
attribute.send(:enforce_conversion_options) | ||
end | ||
end | ||
it 'does not raise an error if a converter is not set and no conversion options' do | ||
DataMiner.unit_converter = nil | ||
attribute = DataMiner::Attribute.new :foo, 'bar' | ||
assert_nothing_raised do | ||
attribute.send(:enforce_conversion_options) | ||
end | ||
end | ||
end | ||
|
||
describe '#convert?' do | ||
it 'returns true if a converter and from_units are set' do | ||
it 'returns true if from_units is set' do | ||
attribute = DataMiner::Attribute.new :foo, 'bar', :from_units => :pounds, :to_units => :kilograms | ||
assert attribute.send(:convert?) | ||
end | ||
it 'returns true if a converter and units_field_name are set' do | ||
attribute = DataMiner::Attribute.new :foo, 'bar', :units_field_name => 'bar' | ||
it 'returns true if to_units and units_field_name are set' do | ||
attribute = DataMiner::Attribute.new :foo, 'bar', :units_field_name => 'bar', :to_units => :kilograms | ||
assert attribute.send(:convert?) | ||
end | ||
it 'returns true if a converter and units_field_number are set' do | ||
attribute = DataMiner::Attribute.new :foo, 'bar', :units_field_number => 3 | ||
it 'returns true if to_units and units_field_number are set' do | ||
attribute = DataMiner::Attribute.new :foo, 'bar', :units_field_number => 3, :to_units => :kilograms | ||
assert attribute.send(:convert?) | ||
end | ||
it 'returns false if there is no converter' do | ||
DataMiner.unit_converter = nil | ||
attribute = DataMiner::Attribute.new :foo, 'bar', :from_units => :pounds, :to_units => :kilograms | ||
assert !attribute.send(:convert?) | ||
it 'returns false if units_field_name only is set' do | ||
attribute = DataMiner::Attribute.new :foo, 'bar', :units_field_name => 'bar' | ||
refute attribute.send(:convert?) | ||
end | ||
it 'returns false if units_field_number only is set' do | ||
attribute = DataMiner::Attribute.new :foo, 'bar', :units_field_number => 'bar' | ||
refute attribute.send(:convert?) | ||
end | ||
it 'returns false if there is a converter but no units' do | ||
attribute = DataMiner::Attribute.new :foo, 'bar' | ||
assert !attribute.send(:convert?) | ||
it 'raises if no converter and units are used' do | ||
DataMiner.unit_converter = nil | ||
lambda { | ||
DataMiner::Attribute.new :foo, 'bar', :from_units => :pounds, :to_units => :kilograms | ||
}.must_raise ArgumentError, /unit_converter/ | ||
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,4 +1,4 @@ | ||
require_relative '../../helper' | ||
require 'helper' | ||
|
||
describe 'DataMiner::UnitConverter::Alchemist' do | ||
before do | ||
|
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,4 +1,4 @@ | ||
require_relative '../../helper' | ||
require 'helper' | ||
|
||
describe 'DataMiner::UnitConverter::Conversions' do | ||
before do | ||
|
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
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
Oops, something went wrong.
f868882
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"unravel" is a bad name for this commit - it's because i git rebased everything onto a single commit that happened to be called "unravel"