measured 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0036468352e098a2fa434a576a3a802078666f8
4
- data.tar.gz: 2e0d6385ada089335c87ebb8e79da28bfcd826bd
3
+ metadata.gz: 5a69b542ffb24ed97433592b86e4b9528adb4e95
4
+ data.tar.gz: 1a7f476e754cdb1781fda2b31c630746f91977d3
5
5
  SHA512:
6
- metadata.gz: d206778b9f16b8fa24c281a68bae304f76325ef9aba6a9d7bdcfe183438beb71f8858a8d77587e54723e67e350f841e5830ed63766758e10432a241671536a92
7
- data.tar.gz: 88e4bf7c581f6fb755d9c8cf435a0bc4ef025429b22a57a388d66c7f65862cd9c36e04a752970a94e8fe183d41db441df628a64bf751fbffe122545936cfdcdd
6
+ metadata.gz: 0a864576e69e8a8df51ba081597ab43c684220c6485b1c04da07fb48cbabe0a15532055e197bfb43c3ad5a14066f8b2c949d103ffa10465fd3d068a5d7fe3cc9
7
+ data.tar.gz: 955237150a140886a4be19ae03de0d8745befdfa076db4f9239b01964631f4064a6de13680bb846ff5cb058987e0a42801819b32159563234afc20d1926549df
@@ -8,6 +8,8 @@ class Measured::Measurable
8
8
  raise Measured::UnitError, "Unit #{ unit } does not exits." unless self.class.conversion.unit_or_alias?(unit)
9
9
 
10
10
  @value = case value
11
+ when NilClass
12
+ raise Measured::UnitError, "Unit value cannot be nil"
11
13
  when Float
12
14
  BigDecimal(value, self.class.conversion.significant_digits)
13
15
  when BigDecimal
@@ -1,3 +1,3 @@
1
1
  module Measured
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -41,6 +41,12 @@ class Measured::MeasurableTest < ActiveSupport::TestCase
41
41
  assert_equal "fireball", Magic.new(1, :fire).unit
42
42
  end
43
43
 
44
+ test "#initialize raises an expected error when initializing with nil" do
45
+ assert_raises Measured::UnitError do
46
+ Magic.new(nil, :fire)
47
+ end
48
+ end
49
+
44
50
  test "#unit allows you to read the unit string" do
45
51
  assert_equal "magic_missile", @magic.unit
46
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: measured
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin McPhillips
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-22 00:00:00.000000000 Z
11
+ date: 2015-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport