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

- old
+ new

@@ -35,20 +35,17 @@ end describe "with measurements" do before(:each) do - module Barometer - class Barometer::Measurement - attr_accessor :success - end - end @weather = Barometer::Weather.new @wunderground = Barometer::Measurement.new(:wunderground) - @wunderground.success = true + @wunderground.stub!(:success).and_return(true) + @wunderground.stub!(:success?).and_return(true) @yahoo = Barometer::Measurement.new(:yahoo) - @yahoo.success = true + @yahoo.stub!(:success).and_return(true) + @yahoo.stub!(:success?).and_return(true) @google = Barometer::Measurement.new(:google) @weather.measurements << @wunderground @weather.measurements << @yahoo @weather.measurements << @google end @@ -82,14 +79,16 @@ before(:each) do @weather = Barometer::Weather.new @wunderground = Barometer::Measurement.new(:wunderground) @wunderground.current = Barometer::Measurement::Result.new - @wunderground.success = true + @wunderground.stub!(:success).and_return(true) + @wunderground.stub!(:success?).and_return(true) @yahoo = Barometer::Measurement.new(:yahoo) @yahoo.current = Barometer::Measurement::Result.new - @yahoo.success = true + @yahoo.stub!(:success).and_return(true) + @yahoo.stub!(:success?).and_return(true) @google = Barometer::Measurement.new(:google) @weather.measurements << @wunderground @weather.measurements << @yahoo @weather.measurements << @google end @@ -294,19 +293,21 @@ @weather.windy?.should be_nil end it "returns true if a measurement returns true" do wunderground = Barometer::Measurement.new(:wunderground) - wunderground.success = true + wunderground.stub!(:success).and_return(true) + wunderground.stub!(:success?).and_return(true) @weather.measurements << wunderground @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 + wunderground.stub!(:success).and_return(true) + wunderground.stub!(:success?).and_return(true) @weather.measurements << wunderground @weather.measurements.each { |m| m.stub!(:windy?).and_return(false) } @weather.windy?.should be_false end @@ -330,19 +331,21 @@ @weather.wet?.should be_nil end it "returns true if a measurement returns true" do wunderground = Barometer::Measurement.new(:wunderground) - wunderground.success = true + wunderground.stub!(:success).and_return(true) + wunderground.stub!(:success?).and_return(true) @weather.measurements << wunderground @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 + wunderground.stub!(:success).and_return(true) + wunderground.stub!(:success?).and_return(true) @weather.measurements << wunderground @weather.measurements.each { |m| m.stub!(:wet?).and_return(false) } @weather.wet?.should be_false end @@ -366,20 +369,22 @@ @weather.night?.should be_nil end it "returns true if a measurement returns true (night is opposite)" do wunderground = Barometer::Measurement.new(:wunderground) - wunderground.success = true + wunderground.stub!(:success).and_return(true) + wunderground.stub!(:success?).and_return(true) @weather.measurements << wunderground @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 + wunderground.stub!(:success).and_return(true) + wunderground.stub!(:success?).and_return(true) @weather.measurements << wunderground @weather.measurements.each { |m| m.stub!(:day?).and_return(false) } @weather.day?.should be_false @weather.night?.should be_true end @@ -398,28 +403,31 @@ @weather.sunny?.should be_nil end it "returns true if a measurement returns true" do wunderground = Barometer::Measurement.new(:wunderground) - wunderground.success = true + wunderground.stub!(:success).and_return(true) + wunderground.stub!(:success?).and_return(true) @weather.measurements << wunderground @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 + wunderground.stub!(:success).and_return(true) + wunderground.stub!(:success?).and_return(true) @weather.measurements << wunderground @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 + wunderground.stub!(:success).and_return(true) + wunderground.stub!(:success?).and_return(true) @weather.measurements << wunderground @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 \ No newline at end of file