sandy 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,7 +31,7 @@ module Sandy
31
31
  "total_customers" => @total_customers,
32
32
  "latitude" => @latitude,
33
33
  "longitude" => @longitude,
34
- "estimated_recovery_time" => @longitude,
34
+ "estimated_recovery_time" => @estimated_recovery_time,
35
35
  "children" => @children }.to_json
36
36
  end
37
37
  end
@@ -18,8 +18,7 @@ module Sandy::Provider
18
18
  end
19
19
 
20
20
  def to_json(*a)
21
- hash = {}
22
- { "areas" => @areas.map(&:to_json) }
21
+ { "report" => { "areas" => @areas } }.to_json
23
22
  end
24
23
 
25
24
  private
@@ -1,3 +1,3 @@
1
1
  module Sandy
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -16,17 +16,25 @@ describe Sandy::Area do
16
16
 
17
17
  describe "#to_json" do
18
18
  let(:parent) { Sandy::Area.new(0, "Manhattan") }
19
- subject { Sandy::Area.new(customers_affected,
20
- nil, { parent: parent }).to_json }
21
-
22
- it { should == {"name" => nil,
23
- "customers_affected" => customers_affected,
24
- "parent" => parent.name,
25
- "total_customers" => nil,
26
- "latitude" => nil,
27
- "longitude" => nil,
28
- "estimated_recovery_time" => nil,
29
- "children" => [] }.to_json }
19
+ let(:current) { Sandy::Area.new(customers_affected, "Downtown",
20
+ { parent: parent }) }
21
+ let(:child) { Sandy::Area.new(0, "Battery Park", { parent: current }) }
22
+ let(:json) { current.to_json }
23
+
24
+ it "parses with the correct values" do
25
+ JSON.parse(json).should == {"name" => "Downtown",
26
+ "customers_affected" => customers_affected,
27
+ "parent" => "Manhattan",
28
+ "total_customers" => nil,
29
+ "latitude" => nil,
30
+ "longitude" => nil,
31
+ "estimated_recovery_time" => nil,
32
+ "children" => [] }
33
+ end
34
+
35
+ it "renders only the name for the parent field" do
36
+ JSON.parse(json)["parent"].should == "Manhattan"
37
+ end
30
38
  end
31
39
 
32
40
  context "with an area name" do
@@ -11,8 +11,10 @@ describe Sandy::Provider::ConEd::Report do
11
11
  end
12
12
 
13
13
  describe "#to_json" do
14
- it 'has an array of areas' do
15
- Sandy::Provider::ConEd::Report.new.to_json["areas"].should be_an_instance_of Array
14
+ subject {}
15
+ it 'has areas' do
16
+ json = JSON.parse(Sandy::Provider::ConEd::Report.new.to_json)
17
+ json["report"]["areas"].should_not be_empty
16
18
  end
17
19
  end
18
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sandy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-18 00:00:00.000000000 Z
12
+ date: 2012-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty