spec/data/units_spec.rb in barometer-0.7.3 vs spec/data/units_spec.rb in barometer-0.8.0
- old
+ new
@@ -1,67 +1,67 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Units" do
-
+
describe "when initialized" do
-
+
before(:each) do
@units = Data::Units.new
end
-
+
it "responds to metric, defaults to true" do
@units.metric.should be_true
end
-
+
it "allows metric to be set" do
@units.metric.should be_true
-
+
@units2 = Data::Units.new(false)
@units2.metric.should be_false
end
-
+
it "stubs metric_default" do
lambda { @units.metric_default = 5 }.should raise_error(NotImplementedError)
end
-
+
it "stubs imperial_default" do
lambda { @units.imperial_default = 5 }.should raise_error(NotImplementedError)
end
-
+
end
-
+
describe "changing units" do
-
+
before(:each) do
@units = Data::Units.new
end
-
+
it "indicates if metric?" do
@units.metric.should be_true
@units.metric?.should be_true
@units.metric = false
@units.metric.should be_false
@units.metric?.should be_false
end
-
+
it "changes to imperial" do
@units.metric?.should be_true
@units.imperial!
@units.metric?.should be_false
end
-
+
it "changes to metric" do
@units.metric = false
@units.metric?.should be_false
@units.metric!
@units.metric?.should be_true
end
end
-
+
describe "when assigning values" do
-
+
before(:each) do
module Barometer
class Data::Units
attr_accessor :a, :b
def metric_default=(value)
@@ -75,27 +75,27 @@
@units_metric = Data::Units.new(true)
@units_imperial = Data::Units.new(false)
@test_value_a = 5.5
@test_value_b = 9.9
end
-
+
it "assigns metric_default" do
@units_metric.metric?.should be_true
@units_metric << @test_value_a
@units_metric.a.should == @test_value_a
-
+
@units_metric << [@test_value_b, @test_value_a]
@units_metric.a.should == @test_value_b
end
-
+
it "assigns imperial_default" do
@units_imperial.metric?.should be_false
@units_imperial << @test_value_a
@units_imperial.b.should == @test_value_a
-
+
@units_imperial << [@test_value_a, @test_value_b]
@units_imperial.b.should == @test_value_b
end
-
+
end
-end
\ No newline at end of file
+end