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.
Files changed (126) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +26 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +6 -0
  5. data/.rubocop_todo.yml +1 -1
  6. data/CHANGELOG.md +54 -1
  7. data/CLAUDE.md +55 -0
  8. data/Dangerfile +28 -0
  9. data/Gemfile +12 -1
  10. data/README.md +52 -510
  11. data/docs/v3.md +525 -0
  12. data/docs/v4.md +179 -0
  13. data/lib/spacex/base_request.rb +8 -8
  14. data/lib/spacex/capsules.rb +10 -12
  15. data/lib/spacex/company.rb +7 -0
  16. data/lib/spacex/cores.rb +11 -14
  17. data/lib/spacex/crew.rb +15 -0
  18. data/lib/spacex/{dragon_capsules.rb → dragons.rb} +14 -16
  19. data/lib/spacex/history.rb +9 -2
  20. data/lib/spacex/landpads.rb +23 -0
  21. data/lib/spacex/launches.rb +35 -11
  22. data/lib/spacex/launchpads.rb +23 -0
  23. data/lib/spacex/models.rb +16 -0
  24. data/lib/spacex/payloads.rb +31 -2
  25. data/lib/spacex/rockets.rb +26 -3
  26. data/lib/spacex/ships.rb +22 -24
  27. data/lib/spacex/starlink.rb +16 -0
  28. data/lib/spacex/version.rb +1 -1
  29. data/lib/spacex.rb +2 -17
  30. data/spacex.gemspec +6 -9
  31. data/spec/coverage_helper.rb +5 -0
  32. data/spec/fixtures/spacex/v4/capsules/all.yml +122 -0
  33. data/spec/fixtures/spacex/v4/capsules/one.yml +89 -0
  34. data/spec/fixtures/spacex/v4/company.yml +80 -0
  35. data/spec/fixtures/spacex/v4/cores/all.yml +76 -0
  36. data/spec/fixtures/spacex/v4/cores/one.yml +75 -0
  37. data/spec/fixtures/spacex/v4/crew/all.yml +92 -0
  38. data/spec/fixtures/spacex/v4/crew/one.yml +74 -0
  39. data/spec/fixtures/spacex/v4/dragons/all.yml +101 -0
  40. data/spec/fixtures/spacex/v4/dragons/one.yml +189 -0
  41. data/spec/fixtures/spacex/v4/history/all.yml +85 -0
  42. data/spec/fixtures/spacex/v4/history/one.yml +168 -0
  43. data/spec/fixtures/spacex/v4/landpads/all.yml +85 -0
  44. data/spec/fixtures/spacex/v4/landpads/one.yml +172 -0
  45. data/spec/fixtures/spacex/v4/launches/all.yml +85 -0
  46. data/spec/fixtures/spacex/v4/launches/latest.yml +84 -0
  47. data/spec/fixtures/spacex/v4/launches/next.yml +84 -0
  48. data/spec/fixtures/spacex/v4/launches/one.yml +167 -0
  49. data/spec/fixtures/spacex/v4/launches/past.yml +85 -0
  50. data/spec/fixtures/spacex/v4/launches/upcoming.yml +97 -0
  51. data/spec/fixtures/spacex/v4/launchpads/all.yml +139 -0
  52. data/spec/fixtures/spacex/v4/launchpads/one.yml +225 -0
  53. data/spec/fixtures/spacex/v4/payloads/all.yml +85 -0
  54. data/spec/fixtures/spacex/v4/payloads/one.yml +167 -0
  55. data/spec/fixtures/spacex/v4/roadster.yml +90 -0
  56. data/spec/fixtures/spacex/v4/rockets/all.yml +76 -0
  57. data/spec/fixtures/spacex/v4/rockets/one.yml +84 -0
  58. data/spec/fixtures/spacex/v4/ships/all.yml +164 -0
  59. data/spec/fixtures/spacex/v4/ships/one.yml +248 -0
  60. data/spec/fixtures/spacex/v4/starlink/all.yml +17713 -0
  61. data/spec/fixtures/spacex/v4/starlink/one.yml +17798 -0
  62. data/spec/spacex/base_request_spec.rb +112 -0
  63. data/spec/spacex/capsules_spec.rb +19 -28
  64. data/spec/spacex/company_spec.rb +26 -0
  65. data/spec/spacex/cores_spec.rb +18 -31
  66. data/spec/spacex/crew_spec.rb +27 -0
  67. data/spec/spacex/dragons_spec.rb +39 -0
  68. data/spec/spacex/history_spec.rb +16 -40
  69. data/spec/spacex/landpads_spec.rb +35 -0
  70. data/spec/spacex/launches_spec.rb +28 -628
  71. data/spec/spacex/launchpads_spec.rb +34 -0
  72. data/spec/spacex/payloads_spec.rb +27 -51
  73. data/spec/spacex/roadster_spec.rb +5 -29
  74. data/spec/spacex/rockets_spec.rb +26 -194
  75. data/spec/spacex/ships_spec.rb +20 -51
  76. data/spec/spacex/starlink_spec.rb +28 -0
  77. data/spec/spacex/version_spec.rb +12 -0
  78. data/spec/spec_helper.rb +3 -9
  79. metadata +106 -137
  80. data/.ruby-version +0 -1
  81. data/.travis.yml +0 -21
  82. data/lib/spacex/api_info.rb +0 -7
  83. data/lib/spacex/company_info.rb +0 -7
  84. data/lib/spacex/endpoint.rb +0 -3
  85. data/lib/spacex/landing_pads.rb +0 -11
  86. data/lib/spacex/launch_pads.rb +0 -11
  87. data/lib/spacex/missions.rb +0 -18
  88. data/spec/fixtures/spacex/api_info/info.yml +0 -65
  89. data/spec/fixtures/spacex/capsules/C202.yml +0 -123
  90. data/spec/fixtures/spacex/capsules.yml +0 -83
  91. data/spec/fixtures/spacex/company_info/info.yml +0 -129
  92. data/spec/fixtures/spacex/cores/B1041.yml +0 -123
  93. data/spec/fixtures/spacex/cores.yml +0 -62
  94. data/spec/fixtures/spacex/dragon_capsules/info/dragon1.yml +0 -131
  95. data/spec/fixtures/spacex/dragon_capsules/info.yml +0 -77
  96. data/spec/fixtures/spacex/history/info/4.yml +0 -62
  97. data/spec/fixtures/spacex/history/info.yml +0 -62
  98. data/spec/fixtures/spacex/landing_pads/info/LZ-4.yml +0 -70
  99. data/spec/fixtures/spacex/landing_pads/info.yml +0 -68
  100. data/spec/fixtures/spacex/launch_pads/info/vafb_slc_4e.yml +0 -71
  101. data/spec/fixtures/spacex/launch_pads/info.yml +0 -104
  102. data/spec/fixtures/spacex/launches/68.yml +0 -69
  103. data/spec/fixtures/spacex/launches/all.yml +0 -62
  104. data/spec/fixtures/spacex/launches/info.yml +0 -62
  105. data/spec/fixtures/spacex/launches/latest.yml +0 -245
  106. data/spec/fixtures/spacex/launches/next.yml +0 -123
  107. data/spec/fixtures/spacex/launches/past.yml +0 -62
  108. data/spec/fixtures/spacex/launches/upcoming.yml +0 -64
  109. data/spec/fixtures/spacex/launches.yml +0 -62
  110. data/spec/fixtures/spacex/missions/F3364BF.yml +0 -157
  111. data/spec/fixtures/spacex/missions/info.yml +0 -62
  112. data/spec/fixtures/spacex/payloads/RatSat.yml +0 -62
  113. data/spec/fixtures/spacex/payloads/info.yml +0 -62
  114. data/spec/fixtures/spacex/roadster/info.yml +0 -133
  115. data/spec/fixtures/spacex/rockets/info/falcon1.yml +0 -139
  116. data/spec/fixtures/spacex/rockets/info/invalid.yml +0 -61
  117. data/spec/fixtures/spacex/rockets/info.yml +0 -105
  118. data/spec/fixtures/spacex/ships/info/AMERICANCHAMPION.yml +0 -125
  119. data/spec/fixtures/spacex/ships/info.yml +0 -139
  120. data/spec/spacex/api_info_spec.rb +0 -16
  121. data/spec/spacex/company_info_spec.rb +0 -27
  122. data/spec/spacex/dragon_capsules_spec.rb +0 -107
  123. data/spec/spacex/endpoint_spec.rb +0 -9
  124. data/spec/spacex/landing_pads_spec.rb +0 -72
  125. data/spec/spacex/launch_pads_spec.rb +0 -77
  126. 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 do
6
- SPACEX::Capsules.info
7
- end
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.capsule_serial).to eq 'C201'
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('C202')", vcr: { cassette_name: 'capsules/C202' } do
23
- subject do
24
- SPACEX::Capsules.info('C202')
25
- end
26
- it 'return specific capsule details' do
27
- expect(subject.capsule_serial).to eq 'C202'
28
- expect(subject.capsule_id).to eq 'dragon2'
29
- expect(subject.status).to eq 'active'
30
- expect(subject.original_launch).to eq nil
31
- expect(subject.original_launch_unix).to eq nil
32
- expect(subject.missions).to be_an(Array)
33
- expect(subject.landings).to eq 0
34
- expect(subject.type).to eq 'Dragon 2.0'
35
- expect(subject.details).to start_with "Capsule used to qualify Dragon 2's environmental control and life support systems."
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
@@ -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 do
6
- SPACEX::Cores.info
7
- end
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.core_serial).to eq 'B1052'
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('B1041')", vcr: { cassette_name: 'cores/B1041' } do
26
- subject do
27
- SPACEX::Cores.info('B1041')
28
- end
29
- it 'returns details of core' do
30
- expect(subject.core_serial).to eq 'B1041'
31
- expect(subject.block).to eq 4
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.water_landing).to eq false
42
- expect(subject.details).to start_with 'Will fly expendable on Iridium NEXT Mission 5'
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
@@ -1,50 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SPACEX::History do
4
- context '#info', vcr: { cassette_name: 'history/info' } do
5
- subject do
6
- SPACEX::History.info
7
- end
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 '#info(4)', vcr: { cassette_name: 'history/info/4' } do
29
- subject do
30
- SPACEX::History.info(4)
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 Historical event info for event id 4' do
34
- expect(subject.id).to eq 4
35
- expect(subject.title).to eq 'Falcon 9 First Flight'
36
- expect(subject.event_date_utc).to eq '2010-06-04T18:45:00Z'
37
- expect(subject.event_date_unix).to eq 1_275_677_100
38
- expect(subject.flight_number).to eq 6
39
- expect(subject.details).to eq(
40
- 'Met 100% of mission objectives on the first flight!'
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