spacex 1.0.2 → 2.0.0
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.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +26 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +54 -1
- data/CLAUDE.md +55 -0
- data/Dangerfile +28 -0
- data/Gemfile +12 -1
- data/README.md +52 -510
- data/docs/v3.md +525 -0
- data/docs/v4.md +179 -0
- data/lib/spacex/base_request.rb +8 -8
- data/lib/spacex/capsules.rb +10 -12
- data/lib/spacex/company.rb +7 -0
- data/lib/spacex/cores.rb +11 -14
- data/lib/spacex/crew.rb +15 -0
- data/lib/spacex/{dragon_capsules.rb → dragons.rb} +14 -16
- data/lib/spacex/history.rb +9 -2
- data/lib/spacex/landpads.rb +23 -0
- data/lib/spacex/launches.rb +35 -11
- data/lib/spacex/launchpads.rb +23 -0
- data/lib/spacex/models.rb +16 -0
- data/lib/spacex/payloads.rb +31 -2
- data/lib/spacex/rockets.rb +26 -3
- data/lib/spacex/ships.rb +22 -24
- data/lib/spacex/starlink.rb +16 -0
- data/lib/spacex/version.rb +1 -1
- data/lib/spacex.rb +2 -17
- data/spacex.gemspec +6 -9
- data/spec/coverage_helper.rb +5 -0
- data/spec/fixtures/spacex/v4/capsules/all.yml +122 -0
- data/spec/fixtures/spacex/v4/capsules/one.yml +89 -0
- data/spec/fixtures/spacex/v4/company.yml +80 -0
- data/spec/fixtures/spacex/v4/cores/all.yml +76 -0
- data/spec/fixtures/spacex/v4/cores/one.yml +75 -0
- data/spec/fixtures/spacex/v4/crew/all.yml +92 -0
- data/spec/fixtures/spacex/v4/crew/one.yml +74 -0
- data/spec/fixtures/spacex/v4/dragons/all.yml +101 -0
- data/spec/fixtures/spacex/v4/dragons/one.yml +189 -0
- data/spec/fixtures/spacex/v4/history/all.yml +85 -0
- data/spec/fixtures/spacex/v4/history/one.yml +168 -0
- data/spec/fixtures/spacex/v4/landpads/all.yml +85 -0
- data/spec/fixtures/spacex/v4/landpads/one.yml +172 -0
- data/spec/fixtures/spacex/v4/launches/all.yml +85 -0
- data/spec/fixtures/spacex/v4/launches/latest.yml +84 -0
- data/spec/fixtures/spacex/v4/launches/next.yml +84 -0
- data/spec/fixtures/spacex/v4/launches/one.yml +167 -0
- data/spec/fixtures/spacex/v4/launches/past.yml +85 -0
- data/spec/fixtures/spacex/v4/launches/upcoming.yml +97 -0
- data/spec/fixtures/spacex/v4/launchpads/all.yml +139 -0
- data/spec/fixtures/spacex/v4/launchpads/one.yml +225 -0
- data/spec/fixtures/spacex/v4/payloads/all.yml +85 -0
- data/spec/fixtures/spacex/v4/payloads/one.yml +167 -0
- data/spec/fixtures/spacex/v4/roadster.yml +90 -0
- data/spec/fixtures/spacex/v4/rockets/all.yml +76 -0
- data/spec/fixtures/spacex/v4/rockets/one.yml +84 -0
- data/spec/fixtures/spacex/v4/ships/all.yml +164 -0
- data/spec/fixtures/spacex/v4/ships/one.yml +248 -0
- data/spec/fixtures/spacex/v4/starlink/all.yml +17713 -0
- data/spec/fixtures/spacex/v4/starlink/one.yml +17798 -0
- data/spec/spacex/base_request_spec.rb +112 -0
- data/spec/spacex/capsules_spec.rb +19 -28
- data/spec/spacex/company_spec.rb +26 -0
- data/spec/spacex/cores_spec.rb +18 -31
- data/spec/spacex/crew_spec.rb +27 -0
- data/spec/spacex/dragons_spec.rb +39 -0
- data/spec/spacex/history_spec.rb +16 -40
- data/spec/spacex/landpads_spec.rb +35 -0
- data/spec/spacex/launches_spec.rb +28 -628
- data/spec/spacex/launchpads_spec.rb +34 -0
- data/spec/spacex/payloads_spec.rb +27 -51
- data/spec/spacex/roadster_spec.rb +5 -29
- data/spec/spacex/rockets_spec.rb +26 -194
- data/spec/spacex/ships_spec.rb +20 -51
- data/spec/spacex/starlink_spec.rb +28 -0
- data/spec/spacex/version_spec.rb +12 -0
- data/spec/spec_helper.rb +3 -9
- metadata +106 -137
- data/.ruby-version +0 -1
- data/.travis.yml +0 -21
- data/lib/spacex/api_info.rb +0 -7
- data/lib/spacex/company_info.rb +0 -7
- data/lib/spacex/endpoint.rb +0 -3
- data/lib/spacex/landing_pads.rb +0 -11
- data/lib/spacex/launch_pads.rb +0 -11
- data/lib/spacex/missions.rb +0 -18
- data/spec/fixtures/spacex/api_info/info.yml +0 -65
- data/spec/fixtures/spacex/capsules/C202.yml +0 -123
- data/spec/fixtures/spacex/capsules.yml +0 -83
- data/spec/fixtures/spacex/company_info/info.yml +0 -129
- data/spec/fixtures/spacex/cores/B1041.yml +0 -123
- data/spec/fixtures/spacex/cores.yml +0 -62
- data/spec/fixtures/spacex/dragon_capsules/info/dragon1.yml +0 -131
- data/spec/fixtures/spacex/dragon_capsules/info.yml +0 -77
- data/spec/fixtures/spacex/history/info/4.yml +0 -62
- data/spec/fixtures/spacex/history/info.yml +0 -62
- data/spec/fixtures/spacex/landing_pads/info/LZ-4.yml +0 -70
- data/spec/fixtures/spacex/landing_pads/info.yml +0 -68
- data/spec/fixtures/spacex/launch_pads/info/vafb_slc_4e.yml +0 -71
- data/spec/fixtures/spacex/launch_pads/info.yml +0 -104
- data/spec/fixtures/spacex/launches/68.yml +0 -69
- data/spec/fixtures/spacex/launches/all.yml +0 -62
- data/spec/fixtures/spacex/launches/info.yml +0 -62
- data/spec/fixtures/spacex/launches/latest.yml +0 -245
- data/spec/fixtures/spacex/launches/next.yml +0 -123
- data/spec/fixtures/spacex/launches/past.yml +0 -62
- data/spec/fixtures/spacex/launches/upcoming.yml +0 -64
- data/spec/fixtures/spacex/launches.yml +0 -62
- data/spec/fixtures/spacex/missions/F3364BF.yml +0 -157
- data/spec/fixtures/spacex/missions/info.yml +0 -62
- data/spec/fixtures/spacex/payloads/RatSat.yml +0 -62
- data/spec/fixtures/spacex/payloads/info.yml +0 -62
- data/spec/fixtures/spacex/roadster/info.yml +0 -133
- data/spec/fixtures/spacex/rockets/info/falcon1.yml +0 -139
- data/spec/fixtures/spacex/rockets/info/invalid.yml +0 -61
- data/spec/fixtures/spacex/rockets/info.yml +0 -105
- data/spec/fixtures/spacex/ships/info/AMERICANCHAMPION.yml +0 -125
- data/spec/fixtures/spacex/ships/info.yml +0 -139
- data/spec/spacex/api_info_spec.rb +0 -16
- data/spec/spacex/company_info_spec.rb +0 -27
- data/spec/spacex/dragon_capsules_spec.rb +0 -107
- data/spec/spacex/endpoint_spec.rb +0 -9
- data/spec/spacex/landing_pads_spec.rb +0 -72
- data/spec/spacex/launch_pads_spec.rb +0 -77
- data/spec/spacex/missions_spec.rb +0 -35
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe SPACEX::BaseRequest do
|
|
4
|
+
describe 'BASE_URI' do
|
|
5
|
+
it 'points to the SpaceX v4 API' do
|
|
6
|
+
expect(SPACEX::BASE_URI).to eq 'https://api.spacexdata.com'
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe '.info' do
|
|
11
|
+
context 'when the response body is an array' do
|
|
12
|
+
before do
|
|
13
|
+
stub_request(:get, 'https://api.spacexdata.com/v4/capsules')
|
|
14
|
+
.to_return(
|
|
15
|
+
status: 200,
|
|
16
|
+
body: '[{"id":"abc","serial":"C101"},{"id":"def","serial":"C102"}]',
|
|
17
|
+
headers: { 'Content-Type' => 'application/json' }
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'returns an array of SPACEX::Response objects' do
|
|
22
|
+
result = SPACEX::BaseRequest.info('capsules')
|
|
23
|
+
expect(result).to be_an Array
|
|
24
|
+
expect(result.length).to eq 2
|
|
25
|
+
expect(result.first).to be_a SPACEX::Response
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'maps response fields onto each element' do
|
|
29
|
+
result = SPACEX::BaseRequest.info('capsules')
|
|
30
|
+
expect(result.first.id).to eq 'abc'
|
|
31
|
+
expect(result.last.serial).to eq 'C102'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context 'when a klass is provided' do
|
|
35
|
+
it 'wraps each element in the given class' do
|
|
36
|
+
result = SPACEX::BaseRequest.info('capsules', SPACEX::Capsules)
|
|
37
|
+
expect(result).to be_an Array
|
|
38
|
+
expect(result.first).to be_a SPACEX::Capsules
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context 'when the response body is a single object' do
|
|
44
|
+
before do
|
|
45
|
+
stub_request(:get, 'https://api.spacexdata.com/v4/company')
|
|
46
|
+
.to_return(
|
|
47
|
+
status: 200,
|
|
48
|
+
body: '{"id":"spacex","name":"SpaceX"}',
|
|
49
|
+
headers: { 'Content-Type' => 'application/json' }
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'returns a single SPACEX::Response' do
|
|
54
|
+
result = SPACEX::BaseRequest.info('company')
|
|
55
|
+
expect(result).to be_a SPACEX::Response
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'maps response fields' do
|
|
59
|
+
result = SPACEX::BaseRequest.info('company')
|
|
60
|
+
expect(result.id).to eq 'spacex'
|
|
61
|
+
expect(result.name).to eq 'SpaceX'
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context 'when a klass is provided' do
|
|
65
|
+
it 'returns an instance of the given class' do
|
|
66
|
+
result = SPACEX::BaseRequest.info('company', SPACEX::Capsules)
|
|
67
|
+
expect(result).to be_a SPACEX::Capsules
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
context 'when the API returns a 404' do
|
|
73
|
+
before do
|
|
74
|
+
stub_request(:get, 'https://api.spacexdata.com/v4/capsules/unknown-id')
|
|
75
|
+
.to_return(status: 404, body: '', headers: {})
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'raises Faraday::ResourceNotFound' do
|
|
79
|
+
expect { SPACEX::BaseRequest.info('capsules/unknown-id') }
|
|
80
|
+
.to raise_error(Faraday::ResourceNotFound)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
context 'when the API returns a 500' do
|
|
85
|
+
before do
|
|
86
|
+
stub_request(:get, 'https://api.spacexdata.com/v4/capsules')
|
|
87
|
+
.to_return(status: 500, body: '', headers: {})
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'raises Faraday::ServerError' do
|
|
91
|
+
expect { SPACEX::BaseRequest.info('capsules') }
|
|
92
|
+
.to raise_error(Faraday::ServerError)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe 'SPACEX::Response' do
|
|
98
|
+
it 'is a Hashie::Mash' do
|
|
99
|
+
expect(SPACEX::Response.new).to be_a Hashie::Mash
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'silently ignores unknown properties' do
|
|
103
|
+
expect { SPACEX::Response.new(unknown_field: 'value') }.not_to raise_error
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it 'provides access to properties' do
|
|
107
|
+
response = SPACEX::Response.new('id' => 'abc', 'name' => 'test')
|
|
108
|
+
expect(response.id).to eq 'abc'
|
|
109
|
+
expect(response.name).to eq 'test'
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe SPACEX::Capsules do
|
|
4
|
-
context '#info', vcr: { cassette_name: 'capsules' } do
|
|
5
|
-
subject
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
it 'returns an array of capsules ' do
|
|
4
|
+
context '#info', vcr: { cassette_name: 'v4/capsules/all' } do
|
|
5
|
+
subject { SPACEX::Capsules.info }
|
|
6
|
+
|
|
7
|
+
it 'returns an array of SPACEX::Capsules' do
|
|
9
8
|
expect(subject).to be_an Array
|
|
10
|
-
expect(subject.first
|
|
11
|
-
expect(subject.first.capsule_id).to eq 'dragon2'
|
|
12
|
-
expect(subject.first.status).to eq 'active'
|
|
13
|
-
expect(subject.first.original_launch).to eq nil
|
|
14
|
-
expect(subject.first.original_launch_unix).to eq nil
|
|
15
|
-
expect(subject.first.missions).to be_an(Array)
|
|
16
|
-
expect(subject.first.landings).to eq 0
|
|
17
|
-
expect(subject.first.type).to eq 'Dragon 2.0'
|
|
18
|
-
expect(subject.first.details).to start_with 'Pressure vessel used for Dragon 2 structural testing.'
|
|
9
|
+
expect(subject.first).to be_a SPACEX::Capsules
|
|
19
10
|
end
|
|
20
11
|
end
|
|
21
12
|
|
|
22
|
-
context "#info('
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
it '
|
|
27
|
-
expect(subject.
|
|
28
|
-
expect(subject.
|
|
29
|
-
expect(subject.
|
|
30
|
-
expect(subject.
|
|
31
|
-
expect(subject.
|
|
32
|
-
expect(subject.
|
|
33
|
-
expect(subject.
|
|
34
|
-
expect(subject.type).to eq 'Dragon
|
|
35
|
-
expect(subject.
|
|
13
|
+
context "#info('5e9e2c5bf35918ed873b2664')",
|
|
14
|
+
vcr: { cassette_name: 'v4/capsules/one' } do
|
|
15
|
+
subject { SPACEX::Capsules.info('5e9e2c5bf35918ed873b2664') }
|
|
16
|
+
|
|
17
|
+
it 'returns specific capsule details' do
|
|
18
|
+
expect(subject.id).to eq '5e9e2c5bf35918ed873b2664'
|
|
19
|
+
expect(subject.land_landings).to eq 0
|
|
20
|
+
expect(subject.last_update).to eq 'Reentered after three weeks in orbit'
|
|
21
|
+
expect(subject.launches).to be_an Array
|
|
22
|
+
expect(subject.reuse_count).to eq 1
|
|
23
|
+
expect(subject.serial).to eq 'C101'
|
|
24
|
+
expect(subject.status).to eq 'retired'
|
|
25
|
+
expect(subject.type).to eq 'Dragon 1.0'
|
|
26
|
+
expect(subject.water_landings).to eq 1
|
|
36
27
|
end
|
|
37
28
|
end
|
|
38
29
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe SPACEX::Company do
|
|
4
|
+
context '#info', vcr: { cassette_name: 'v4/company' } do
|
|
5
|
+
subject { SPACEX::Company.info }
|
|
6
|
+
|
|
7
|
+
it 'returns company info as a Response' do
|
|
8
|
+
expect(subject.name).to eq 'SpaceX'
|
|
9
|
+
expect(subject.founder).to eq 'Elon Musk'
|
|
10
|
+
expect(subject.founded).to eq 2002
|
|
11
|
+
expect(subject.employees).to eq 9500
|
|
12
|
+
expect(subject.vehicles).to eq 4
|
|
13
|
+
expect(subject.launch_sites).to eq 3
|
|
14
|
+
expect(subject.test_sites).to eq 3
|
|
15
|
+
expect(subject.ceo).to eq 'Elon Musk'
|
|
16
|
+
expect(subject.cto).to eq 'Elon Musk'
|
|
17
|
+
expect(subject.coo).to eq 'Gwynne Shotwell'
|
|
18
|
+
expect(subject.cto_propulsion).to eq 'Tom Mueller'
|
|
19
|
+
expect(subject.valuation).to eq 74_000_000_000
|
|
20
|
+
expect(subject.headquarters.address).to eq 'Rocket Road'
|
|
21
|
+
expect(subject.headquarters.city).to eq 'Hawthorne'
|
|
22
|
+
expect(subject.headquarters.state).to eq 'California'
|
|
23
|
+
expect(subject.id).to eq '5eb75edc42fea42237d7f3ed'
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
data/spec/spacex/cores_spec.rb
CHANGED
|
@@ -1,45 +1,32 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe SPACEX::Cores do
|
|
4
|
-
context '#info', vcr: { cassette_name: 'cores' } do
|
|
5
|
-
subject
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
it 'returns an array of cores ' do
|
|
4
|
+
context '#info', vcr: { cassette_name: 'v4/cores/all' } do
|
|
5
|
+
subject { SPACEX::Cores.info }
|
|
6
|
+
|
|
7
|
+
it 'returns an array of SPACEX::Cores' do
|
|
9
8
|
expect(subject).to be_an Array
|
|
10
|
-
expect(subject.first
|
|
11
|
-
expect(subject.first.block).to eq 5
|
|
12
|
-
expect(subject.first.status).to eq 'active'
|
|
13
|
-
expect(subject.first.original_launch).to eq nil
|
|
14
|
-
expect(subject.first.original_launch_unix).to eq nil
|
|
15
|
-
expect(subject.first.missions).to be_an(Array)
|
|
16
|
-
expect(subject.first.rtls_attempts).to eq 0
|
|
17
|
-
expect(subject.first.rtls_landings).to eq 0
|
|
18
|
-
expect(subject.first.asds_attempts).to eq 0
|
|
19
|
-
expect(subject.first.asds_landings).to eq 0
|
|
20
|
-
expect(subject.first.water_landing).to eq false
|
|
21
|
-
expect(subject.first.details).to start_with 'On test stand at McGregor.'
|
|
9
|
+
expect(subject.first).to be_a SPACEX::Cores
|
|
22
10
|
end
|
|
23
11
|
end
|
|
24
12
|
|
|
25
|
-
context "#info('
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
it 'returns
|
|
30
|
-
expect(subject.
|
|
31
|
-
expect(subject.
|
|
32
|
-
expect(subject.status).to eq 'expended'
|
|
33
|
-
expect(subject.original_launch).to eq '2017-10-09T12:37:00.000Z'
|
|
34
|
-
expect(subject.original_launch_unix).to eq 1_507_552_620
|
|
35
|
-
expect(subject.missions[1]['name']).to eq 'Iridium NEXT Mission 5'
|
|
36
|
-
expect(subject.missions[1]['flight']).to eq 58
|
|
13
|
+
context "#info('60b800111f83cc1e59f16438')",
|
|
14
|
+
vcr: { cassette_name: 'v4/cores/one' } do
|
|
15
|
+
subject { SPACEX::Cores.info('60b800111f83cc1e59f16438') }
|
|
16
|
+
|
|
17
|
+
it 'returns specific core details' do
|
|
18
|
+
expect(subject.block).to eq 5
|
|
19
|
+
expect(subject.reuse_count).to eq 0
|
|
37
20
|
expect(subject.rtls_attempts).to eq 0
|
|
38
21
|
expect(subject.rtls_landings).to eq 0
|
|
39
22
|
expect(subject.asds_attempts).to eq 1
|
|
40
23
|
expect(subject.asds_landings).to eq 1
|
|
41
|
-
expect(subject.
|
|
42
|
-
expect(subject.
|
|
24
|
+
expect(subject.last_update).to eq 'Landed on OCISLY* as of June 3, 2021 '
|
|
25
|
+
expect(subject.launches).to be_an Array
|
|
26
|
+
expect(subject.launches.first).to eq '5fe3af84b3467846b3242161'
|
|
27
|
+
expect(subject.serial).to eq 'B1067'
|
|
28
|
+
expect(subject.status).to eq 'unknown'
|
|
29
|
+
expect(subject.id).to eq '60b800111f83cc1e59f16438'
|
|
43
30
|
end
|
|
44
31
|
end
|
|
45
32
|
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe SPACEX::Crew do
|
|
4
|
+
context '#info', vcr: { cassette_name: 'v4/crew/all' } do
|
|
5
|
+
subject { SPACEX::Crew.info }
|
|
6
|
+
|
|
7
|
+
it 'returns an array of SPACEX::Crew' do
|
|
8
|
+
expect(subject).to be_an Array
|
|
9
|
+
expect(subject.first).to be_a SPACEX::Crew
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context "#info('607a3ab45a906a44023e0872')",
|
|
14
|
+
vcr: { cassette_name: 'v4/crew/one' } do
|
|
15
|
+
subject { SPACEX::Crew.info('607a3ab45a906a44023e0872') }
|
|
16
|
+
|
|
17
|
+
it 'returns specific crew member details' do
|
|
18
|
+
expect(subject.agency).to eq 'SpaceX'
|
|
19
|
+
expect(subject.id).to eq '607a3ab45a906a44023e0872'
|
|
20
|
+
expect(subject.image).to eq 'https://imgur.com/ll7TlwD.png'
|
|
21
|
+
expect(subject.launches).to eq ['607a37565a906a44023e0866']
|
|
22
|
+
expect(subject.name).to eq 'Hayley Arceneaux'
|
|
23
|
+
expect(subject.status).to eq 'active'
|
|
24
|
+
expect(subject.wikipedia).to eq 'https://en.wikipedia.org/wiki/Hayley_Arceneaux'
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe SPACEX::Dragons do
|
|
4
|
+
context '#info', vcr: { cassette_name: 'v4/dragons/all' } do
|
|
5
|
+
subject { SPACEX::Dragons.info }
|
|
6
|
+
it 'returns an array of SPACEX::Dragons' do
|
|
7
|
+
expect(subject).to be_an Array
|
|
8
|
+
expect(subject.first).to be_a SPACEX::Dragons
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context "#info('5e9d058759b1ff74a7ad5f8f')",
|
|
13
|
+
vcr: { cassette_name: 'v4/dragons/one' } do
|
|
14
|
+
subject { SPACEX::Dragons.info('5e9d058759b1ff74a7ad5f8f') }
|
|
15
|
+
|
|
16
|
+
it 'returns a specific dragon with all properties' do
|
|
17
|
+
expect(subject).to be_a SPACEX::Dragons
|
|
18
|
+
expect(subject.id).to eq '5e9d058759b1ff74a7ad5f8f'
|
|
19
|
+
expect(subject.name).to eq 'Dragon 1'
|
|
20
|
+
expect(subject.type).to eq 'capsule'
|
|
21
|
+
expect(subject.active).to eq true
|
|
22
|
+
expect(subject.crew_capacity).to eq 0
|
|
23
|
+
expect(subject.sidewall_angle_deg).to eq 15
|
|
24
|
+
expect(subject.orbit_duration_yr).to eq 2
|
|
25
|
+
expect(subject.dry_mass_kg).to eq 4200
|
|
26
|
+
expect(subject.dry_mass_lb).to eq 9300
|
|
27
|
+
expect(subject.first_flight).to eq '2010-12-08'
|
|
28
|
+
expect(subject.wikipedia).to eq 'https://en.wikipedia.org/wiki/SpaceX_Dragon'
|
|
29
|
+
expect(subject.description).not_to be_nil
|
|
30
|
+
expect(subject.heat_shield).to be_a Hash
|
|
31
|
+
expect(subject.launch_payload_mass).to be_a Hash
|
|
32
|
+
expect(subject.return_payload_mass).to be_a Hash
|
|
33
|
+
expect(subject.diameter).to be_a Hash
|
|
34
|
+
expect(subject.height_w_trunk).to be_a Hash
|
|
35
|
+
expect(subject.thrusters).to be_an Array
|
|
36
|
+
expect(subject.flickr_images).to be_an Array
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
data/spec/spacex/history_spec.rb
CHANGED
|
@@ -1,50 +1,26 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe SPACEX::History do
|
|
4
|
-
context '#info', vcr: { cassette_name: 'history/
|
|
5
|
-
subject
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
it 'returns all historical events when no id is passed' do
|
|
10
|
-
first_subject = subject.first
|
|
11
|
-
expect(first_subject.id).to eq 1
|
|
12
|
-
expect(first_subject.title).to eq 'Falcon 1 Makes History'
|
|
13
|
-
expect(first_subject.event_date_utc).to eq '2008-09-28T23:15:00Z'
|
|
14
|
-
expect(first_subject.event_date_unix).to eq 1_222_643_700
|
|
15
|
-
expect(first_subject.flight_number).to eq 4
|
|
16
|
-
expect(first_subject.details).to eq(
|
|
17
|
-
'Falcon 1 becomes the first privately '\
|
|
18
|
-
'developed liquid fuel rocket to reach Earth orbit.'
|
|
19
|
-
)
|
|
20
|
-
expect(first_subject.links).to eq(
|
|
21
|
-
'reddit' => nil,
|
|
22
|
-
'article' => 'http://www.spacex.com/news/2013/02/11/flight-4-launch-update-0',
|
|
23
|
-
'wikipedia' => 'https://en.wikipedia.org/wiki/Falcon_1'
|
|
24
|
-
)
|
|
4
|
+
context '#info', vcr: { cassette_name: 'v4/history/all' } do
|
|
5
|
+
subject { SPACEX::History.info }
|
|
6
|
+
it 'returns an array of SPACEX::History' do
|
|
7
|
+
expect(subject).to be_an Array
|
|
8
|
+
expect(subject.first).to be_a SPACEX::History
|
|
25
9
|
end
|
|
26
10
|
end
|
|
27
11
|
|
|
28
|
-
context
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
end
|
|
12
|
+
context "#info('5f6fb2cfdcfdf403df37971e')",
|
|
13
|
+
vcr: { cassette_name: 'v4/history/one' } do
|
|
14
|
+
subject { SPACEX::History.info('5f6fb2cfdcfdf403df37971e') }
|
|
32
15
|
|
|
33
|
-
it 'returns
|
|
34
|
-
expect(subject
|
|
35
|
-
expect(subject.
|
|
36
|
-
expect(subject.
|
|
37
|
-
expect(subject.
|
|
38
|
-
expect(subject.
|
|
39
|
-
expect(subject.details).to
|
|
40
|
-
|
|
41
|
-
)
|
|
42
|
-
expect(subject.links).to eq(
|
|
43
|
-
'reddit' => nil,
|
|
44
|
-
'article' => 'http://www.bbc.com/news/10209704',
|
|
45
|
-
'wikipedia' =>
|
|
46
|
-
'https://en.wikipedia.org/wiki/Dragon_Spacecraft_Qualification_Unit'
|
|
47
|
-
)
|
|
16
|
+
it 'returns a specific history event with all properties' do
|
|
17
|
+
expect(subject).to be_a SPACEX::History
|
|
18
|
+
expect(subject.id).to eq '5f6fb2cfdcfdf403df37971e'
|
|
19
|
+
expect(subject.title).to eq 'Falcon reaches Earth orbit'
|
|
20
|
+
expect(subject.event_date_utc).to eq '2008-09-28T23:15:00Z'
|
|
21
|
+
expect(subject.event_date_unix).to eq 1_222_643_700
|
|
22
|
+
expect(subject.details).to include('Falcon 1')
|
|
23
|
+
expect(subject.links).to be_a Hash
|
|
48
24
|
end
|
|
49
25
|
end
|
|
50
26
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe SPACEX::Landpads do
|
|
4
|
+
context '#info', vcr: { cassette_name: 'v4/landpads/all' } do
|
|
5
|
+
subject { SPACEX::Landpads.info }
|
|
6
|
+
it 'returns an array of SPACEX::Landpads' do
|
|
7
|
+
expect(subject).to be_an Array
|
|
8
|
+
expect(subject.first).to be_a SPACEX::Landpads
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context "#info('5e9e3032383ecb267a34e7c7')",
|
|
13
|
+
vcr: { cassette_name: 'v4/landpads/one' } do
|
|
14
|
+
subject { SPACEX::Landpads.info('5e9e3032383ecb267a34e7c7') }
|
|
15
|
+
|
|
16
|
+
it 'returns a specific landpad with all properties' do
|
|
17
|
+
expect(subject).to be_a SPACEX::Landpads
|
|
18
|
+
expect(subject.id).to eq '5e9e3032383ecb267a34e7c7'
|
|
19
|
+
expect(subject.name).to eq 'LZ-1'
|
|
20
|
+
expect(subject.full_name).to eq 'Landing Zone 1'
|
|
21
|
+
expect(subject.status).to eq 'active'
|
|
22
|
+
expect(subject.type).to eq 'RTLS'
|
|
23
|
+
expect(subject.locality).to eq 'Cape Canaveral'
|
|
24
|
+
expect(subject.region).to eq 'Florida'
|
|
25
|
+
expect(subject.latitude).to eq 28.485833
|
|
26
|
+
expect(subject.longitude).to eq(-80.544444)
|
|
27
|
+
expect(subject.landing_attempts).to eq 21
|
|
28
|
+
expect(subject.landing_successes).to eq 20
|
|
29
|
+
expect(subject.wikipedia).to eq 'https://en.wikipedia.org/wiki/Landing_Zones_1_and_2'
|
|
30
|
+
expect(subject.details).not_to be_nil
|
|
31
|
+
expect(subject.launches).to be_an Array
|
|
32
|
+
expect(subject.images).to be_a Hash
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|