Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80cfbdc
commit 3886e5a
Showing
4 changed files
with
1,203 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
clima_tempo (2.0) | ||
clima_tempo (2.2) | ||
nokogiri (>= 1.5.9) | ||
|
||
GEM | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,49 @@ | ||
require "spec_helper" | ||
|
||
describe ClimaTempo do | ||
it "missing type" do | ||
expect { climatempo = ClimaTempo.new(:code) }.to raise_error(TypeError) | ||
end | ||
|
||
it "missing parameters" do | ||
expect { climatempo = ClimaTempo.new }.to raise_error(ArgumentError) | ||
expect { climatempo = ClimaTempo.new({}) }.to raise_error(ArgumentError) | ||
end | ||
|
||
context "values for the time" do | ||
context "values from São Paulo" do | ||
before do | ||
fixture = File.open("spec/fixture/sao_paulo.html").read | ||
FakeWeb.register_uri :any, "http://www.climatempo.com.br/previsao-do-tempo/cidade/558/empty", :body => fixture | ||
|
||
@climatempo = ClimaTempo.new :code => 558 | ||
@clima_tempo = ClimaTempo.new :code => 558 | ||
end | ||
|
||
it "object type" do | ||
@climatempo.now.should be_an(Hash) | ||
@clima_tempo.now.should be_an(Hash) | ||
end | ||
|
||
it "keys" do | ||
hash = @climatempo.now | ||
it "object keys" do | ||
hash = @clima_tempo.now | ||
|
||
hash.should have(7).items | ||
hash.should have(6).items | ||
|
||
hash.should have_key(:temperature) | ||
hash.should have_key(:wind) | ||
hash.should have_key(:condition) | ||
hash.should have_key(:pressure) | ||
hash.should have_key(:intensity) | ||
hash.should have_key(:moisture) | ||
hash.should have_key(:video) | ||
end | ||
|
||
it "values" do | ||
hash = @climatempo.now | ||
it "object values" do | ||
hash = @clima_tempo.now | ||
|
||
hash[:temperature].should == "24ºC" | ||
hash[:wind].should == "Sudeste" | ||
hash[:condition].should == "Muitas nuvens" | ||
hash[:pressure].should == "1021 hPa" | ||
hash[:intensity].should == "19 Km/h" | ||
hash[:moisture].should == "57%" | ||
hash[:video].should include("grande-sp") | ||
hash[:temperature].should == "28ºC" | ||
hash[:wind].should == "Norte" | ||
hash[:condition].should == "Tempo firme" | ||
hash[:pressure].should == "1017 hPa" | ||
hash[:intensity].should == "11 Km/h" | ||
hash[:moisture].should == "51%" | ||
end | ||
end | ||
end |
Oops, something went wrong.