ndbc 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NDBC::Station do
4
-
5
- let(:station) { NDBC::Station.new(41009) }
6
-
4
+
5
+ subject(:station) { NDBC::Station.new(41009) }
6
+
7
+ methods = %i(wdir wspd gst wvht dpd apd mwd pres atmp wtmp dewp vis ptdy tide dir spd gdr gsp
8
+ gtime h0 wwh wwp wwd steepness avp swh swp swd swd owner ttype hull name payload
9
+ location timezone forecast note active)
10
+ methods.each do |method_sym|
11
+ it { is_expected.to respond_to(method_sym) }
12
+ end
13
+
7
14
  describe "initialization" do
8
15
 
9
16
  it "assigns the id" do
@@ -11,13 +18,41 @@ describe NDBC::Station do
11
18
  end
12
19
 
13
20
  it "has a connection" do
14
- expect(station).to respond_to(:connection)
21
+ expect(station).to respond_to(:connection)
15
22
  end
16
23
 
17
24
  end
18
25
 
19
- shared_examples_for "station" do
26
+ describe '.all' do
27
+ let(:result) do
28
+ VCR.use_cassette("station_table") do
29
+ NDBC::Station.all
30
+ end
31
+ end
20
32
 
33
+ it 'returns an array of stations' do
34
+ expect(result).to be_a(Array)
35
+ expect(result).to all(be_a(NDBC::Station))
36
+ end
37
+
38
+ describe 'the stations' do
39
+ it 'have the data from the station_table filled in' do
40
+ expect(result).to all(satisfy do |station|
41
+ location = station.location
42
+ location.class == Hash &&
43
+ location.key?(:latitude) &&
44
+ location.key?(:longitude)
45
+ end)
46
+ expect(result).to all(satisfy do |station|
47
+ inactive_regex = /disestablished|discontinued|inoperative|decommissioned/
48
+ station.note.nil? ||
49
+ station.active == !station.note.match(inactive_regex)
50
+ end)
51
+ end
52
+ end
53
+ end
54
+
55
+ shared_examples_for "station" do
21
56
  it "returns a hash with units and values" do
22
57
  expect(result[:units]).to be_a(Hash)
23
58
  expect(result[:values]).to be_a(Array)
@@ -52,9 +87,9 @@ describe NDBC::Station do
52
87
 
53
88
  end
54
89
 
55
- describe "standard_meteorological_data" do
90
+ describe "#standard_meteorological_data" do
56
91
 
57
- let(:result) do
92
+ let(:result) do
58
93
  VCR.use_cassette("standard_meteorological_data") do
59
94
  station.standard_meteorological_data
60
95
  end
@@ -63,10 +98,10 @@ describe NDBC::Station do
63
98
  it_behaves_like "station"
64
99
 
65
100
  context 'when the station is not found' do
66
-
101
+
67
102
  let(:not_found_station) { NDBC::Station.new(00000) }
68
103
 
69
- let(:not_found_result) do
104
+ let(:not_found_result) do
70
105
  VCR.use_cassette("standard_meteorological_data_not_found") do
71
106
  not_found_station.standard_meteorological_data
72
107
  end
@@ -81,11 +116,8 @@ describe NDBC::Station do
81
116
 
82
117
  end
83
118
 
84
- describe "meteorological data from drifting buoys" do
85
- end
86
-
87
- describe "continuous winds data" do
88
- let(:result) do
119
+ describe "#continuous_winds_data" do
120
+ let(:result) do
89
121
  VCR.use_cassette("continuous_winds_data") do
90
122
  station.continuous_winds_data
91
123
  end
@@ -94,8 +126,8 @@ describe NDBC::Station do
94
126
  it_behaves_like "station"
95
127
  end
96
128
 
97
- describe "spectral wave summaries" do
98
- let(:result) do
129
+ describe "#spectral_wave_summaries" do
130
+ let(:result) do
99
131
  VCR.use_cassette("spectral_wave_summaries") do
100
132
  station.spectral_wave_summaries
101
133
  end
@@ -105,7 +137,7 @@ describe NDBC::Station do
105
137
  end
106
138
 
107
139
  describe "error handling" do
108
-
140
+
109
141
  let(:not_found) do
110
142
  NDBC::Station.new(00000)
111
143
  end
@@ -118,7 +150,7 @@ describe NDBC::Station do
118
150
  end
119
151
  end
120
152
 
121
- describe "spectral wave forecasts" do
153
+ describe "#spectral_wave_forecasts" do
122
154
 
123
155
  let(:buoy) { NDBC::Station.new(41009) }
124
156
 
@@ -135,7 +167,7 @@ describe NDBC::Station do
135
167
 
136
168
  it "parses the cycle line and uses it to set up the first date" do
137
169
  expect(response.first[:time]).to eq( DateTime.new(2015, 9, 7, 3) )
138
- end
170
+ end
139
171
 
140
172
  it "returns an array of hashes with a height key" do
141
173
  expect(response.first[:hst]).to be_a Float
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ndbc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Hertz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-10 00:00:00.000000000 Z
11
+ date: 2016-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,9 +136,11 @@ files:
136
136
  - LICENSE.txt
137
137
  - README.md
138
138
  - Rakefile
139
+ - changelog.md
139
140
  - lib/ndbc.rb
140
141
  - lib/ndbc/connection.rb
141
142
  - lib/ndbc/station.rb
143
+ - lib/ndbc/station_table.rb
142
144
  - lib/ndbc/version.rb
143
145
  - ndbc.gemspec
144
146
  - spec/fixtures/vcr_cassettes/continuous_winds_data.yml
@@ -148,6 +150,7 @@ files:
148
150
  - spec/fixtures/vcr_cassettes/standard_meteorological_data.yml
149
151
  - spec/fixtures/vcr_cassettes/standard_meteorological_data_not_found.yml
150
152
  - spec/fixtures/vcr_cassettes/station_not_found.yml
153
+ - spec/fixtures/vcr_cassettes/station_table.yml
151
154
  - spec/ndbc/connection_spec.rb
152
155
  - spec/ndbc/station_spec.rb
153
156
  - spec/ndbc_spec.rb
@@ -184,6 +187,7 @@ test_files:
184
187
  - spec/fixtures/vcr_cassettes/standard_meteorological_data.yml
185
188
  - spec/fixtures/vcr_cassettes/standard_meteorological_data_not_found.yml
186
189
  - spec/fixtures/vcr_cassettes/station_not_found.yml
190
+ - spec/fixtures/vcr_cassettes/station_table.yml
187
191
  - spec/ndbc/connection_spec.rb
188
192
  - spec/ndbc/station_spec.rb
189
193
  - spec/ndbc_spec.rb