spec/weather_spec.rb in barometer-0.6.4 vs spec/weather_spec.rb in barometer-0.6.6

- old
+ new

@@ -1,6 +1,6 @@ -require 'spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Weather" do describe "when initialized" do @@ -81,14 +81,14 @@ describe "when calculating averages" do before(:each) do @weather = Barometer::Weather.new @wunderground = Barometer::Measurement.new(:wunderground) - @wunderground.current = Measurement::Result.new + @wunderground.current = Barometer::Measurement::Result.new @wunderground.success = true @yahoo = Barometer::Measurement.new(:yahoo) - @yahoo.current = Measurement::Result.new + @yahoo.current = Barometer::Measurement::Result.new @yahoo.success = true @google = Barometer::Measurement.new(:google) @weather.measurements << @wunderground @weather.measurements << @yahoo @weather.measurements << @google @@ -296,19 +296,19 @@ it "returns true if a measurement returns true" do wunderground = Barometer::Measurement.new(:wunderground) wunderground.success = true @weather.measurements << wunderground - Barometer::Measurement.any_instance.stubs(:windy?).returns(true) + @weather.measurements.each { |m| m.stub!(:windy?).and_return(true) } @weather.windy?.should be_true end it "returns false if a measurement returns false" do wunderground = Barometer::Measurement.new(:wunderground) wunderground.success = true @weather.measurements << wunderground - Barometer::Measurement.any_instance.stubs(:windy?).returns(false) + @weather.measurements.each { |m| m.stub!(:windy?).and_return(false) } @weather.windy?.should be_false end end @@ -332,19 +332,19 @@ it "returns true if a measurement returns true" do wunderground = Barometer::Measurement.new(:wunderground) wunderground.success = true @weather.measurements << wunderground - Barometer::Measurement.any_instance.stubs(:wet?).returns(true) + @weather.measurements.each { |m| m.stub!(:wet?).and_return(true) } @weather.wet?.should be_true end it "returns false if a measurement returns false" do wunderground = Barometer::Measurement.new(:wunderground) wunderground.success = true @weather.measurements << wunderground - Barometer::Measurement.any_instance.stubs(:wet?).returns(false) + @weather.measurements.each { |m| m.stub!(:wet?).and_return(false) } @weather.wet?.should be_false end end @@ -368,20 +368,20 @@ it "returns true if a measurement returns true (night is opposite)" do wunderground = Barometer::Measurement.new(:wunderground) wunderground.success = true @weather.measurements << wunderground - Barometer::Measurement.any_instance.stubs(:day?).returns(true) + @weather.measurements.each { |m| m.stub!(:day?).and_return(true) } @weather.day?.should be_true @weather.night?.should be_false end it "returns false if a measurement returns false (night is opposite)" do wunderground = Barometer::Measurement.new(:wunderground) wunderground.success = true @weather.measurements << wunderground - Barometer::Measurement.any_instance.stubs(:day?).returns(false) + @weather.measurements.each { |m| m.stub!(:day?).and_return(false) } @weather.day?.should be_false @weather.night?.should be_true end end @@ -400,29 +400,29 @@ it "returns true if a measurement returns true" do wunderground = Barometer::Measurement.new(:wunderground) wunderground.success = true @weather.measurements << wunderground - Barometer::Measurement.any_instance.stubs(:day?).returns(true) - Barometer::Measurement.any_instance.stubs(:sunny?).returns(true) + @weather.measurements.each { |m| m.stub!(:day?).and_return(true) } + @weather.measurements.each { |m| m.stub!(:sunny?).and_return(true) } @weather.sunny?.should be_true end it "returns false if a measurement returns false" do wunderground = Barometer::Measurement.new(:wunderground) wunderground.success = true @weather.measurements << wunderground - Barometer::Measurement.any_instance.stubs(:day?).returns(true) - Barometer::Measurement.any_instance.stubs(:sunny?).returns(false) + @weather.measurements.each { |m| m.stub!(:day?).and_return(true) } + @weather.measurements.each { |m| m.stub!(:sunny?).and_return(false) } @weather.sunny?.should be_false end it "returns false if night time" do wunderground = Barometer::Measurement.new(:wunderground) wunderground.success = true @weather.measurements << wunderground - Barometer::Measurement.any_instance.stubs(:sunny?).returns(true) - Barometer::Measurement.any_instance.stubs(:day?).returns(false) + @weather.measurements.each { |m| m.stub!(:sunny?).and_return(true) } + @weather.measurements.each { |m| m.stub!(:day?).and_return(false) } @weather.sunny?.should be_false end end \ No newline at end of file