Permalink
Browse files

fix in! exception

  • Loading branch information...
1 parent 50676cb commit 20a411cc0387264618d8c760a899fcfa012d4a66 Ryan Ong & Grant Hutchins committed Feb 13, 2012
Showing with 7 additions and 5 deletions.
  1. +1 −1 lib/unit/class.rb
  2. +6 −4 spec/error_spec.rb
View
@@ -150,7 +150,7 @@ def in!(unit)
unit = coerce_object(unit)
result = self.in(unit)
unless result.unit == unit.unit
- raise TypeError, "Unexpected #{result.inspect}, expected to be in #{other_unit.unit_string}"
+ raise TypeError, "Unexpected #{result.inspect}, expected to be in #{unit.unit_string}"
end
result
end
View
@@ -13,14 +13,16 @@
describe "TypeError when trying to convert incompatible unit using #in!" do
it "should have a nice error message" do
unit = Unit(1000, "m / s")
- lambda { unit.in!("seconds") }.should
- raise_error(TypeError, %{Unexpected Unit("1000/1 m.s^-1"), expected to be in s})
+ expect { unit.in!("seconds") }.to(
+ raise_error(TypeError, %{Unexpected #{unit.inspect}, expected to be in s})
+ )
end
it "should have a nice error message using the DSL", :dsl => true do
unit = Unit(1000, "m / s")
- lambda { unit.in_seconds! }.should
- raise_error(TypeError, %{Unexpected Unit("1000/1 m.s^-1"), expected to be in s})
+ expect { unit.in_seconds! }.to(
+ raise_error(TypeError, %{Unexpected #{unit.inspect}, expected to be in s})
+ )
end
end

0 comments on commit 20a411c

Please sign in to comment.