spacex 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +53 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +14 -0
  5. data/.rubocop_todo.yml +24 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +6 -0
  8. data/CHANGELOG.md +53 -0
  9. data/CONTRIBUTING.md +35 -0
  10. data/Gemfile +7 -0
  11. data/LICENSE +21 -0
  12. data/README.md +495 -0
  13. data/Rakefile +19 -0
  14. data/lib/spacex.rb +19 -0
  15. data/lib/spacex/base_request.rb +57 -0
  16. data/lib/spacex/capsules.rb +19 -0
  17. data/lib/spacex/company_info.rb +7 -0
  18. data/lib/spacex/cores.rb +22 -0
  19. data/lib/spacex/dragon_capsules.rb +33 -0
  20. data/lib/spacex/endpoint.rb +3 -0
  21. data/lib/spacex/history.rb +7 -0
  22. data/lib/spacex/launches.rb +27 -0
  23. data/lib/spacex/missions.rb +18 -0
  24. data/lib/spacex/payloads.rb +7 -0
  25. data/lib/spacex/resource.rb +5 -0
  26. data/lib/spacex/roadster.rb +7 -0
  27. data/lib/spacex/rockets.rb +7 -0
  28. data/lib/spacex/ships.rb +33 -0
  29. data/lib/spacex/version.rb +7 -0
  30. data/rubocop.yml +8 -0
  31. data/spacex.gemspec +29 -0
  32. data/spec/fixtures/spacex/capsules.yml +83 -0
  33. data/spec/fixtures/spacex/capsules/C202.yml +123 -0
  34. data/spec/fixtures/spacex/company_info/info.yml +129 -0
  35. data/spec/fixtures/spacex/cores.yml +62 -0
  36. data/spec/fixtures/spacex/cores/B1041.yml +123 -0
  37. data/spec/fixtures/spacex/dragon_capsules/info.yml +77 -0
  38. data/spec/fixtures/spacex/dragon_capsules/info/dragon1.yml +131 -0
  39. data/spec/fixtures/spacex/history/info.yml +62 -0
  40. data/spec/fixtures/spacex/history/info/4.yml +62 -0
  41. data/spec/fixtures/spacex/launches.yml +62 -0
  42. data/spec/fixtures/spacex/launches/68.yml +69 -0
  43. data/spec/fixtures/spacex/launches/all.yml +62 -0
  44. data/spec/fixtures/spacex/launches/info.yml +62 -0
  45. data/spec/fixtures/spacex/launches/latest.yml +245 -0
  46. data/spec/fixtures/spacex/launches/next.yml +123 -0
  47. data/spec/fixtures/spacex/launches/past.yml +62 -0
  48. data/spec/fixtures/spacex/launches/upcoming.yml +64 -0
  49. data/spec/fixtures/spacex/missions/F3364BF.yml +157 -0
  50. data/spec/fixtures/spacex/missions/info.yml +62 -0
  51. data/spec/fixtures/spacex/payloads/RatSat.yml +62 -0
  52. data/spec/fixtures/spacex/payloads/info.yml +62 -0
  53. data/spec/fixtures/spacex/roadster/info.yml +133 -0
  54. data/spec/fixtures/spacex/rockets/info.yml +105 -0
  55. data/spec/fixtures/spacex/rockets/info/falcon1.yml +139 -0
  56. data/spec/fixtures/spacex/rockets/info/invalid.yml +61 -0
  57. data/spec/fixtures/spacex/ships/info.yml +139 -0
  58. data/spec/fixtures/spacex/ships/info/AMERICANCHAMPION.yml +125 -0
  59. data/spec/spacex/capsules_spec.rb +38 -0
  60. data/spec/spacex/company_info_spec.rb +27 -0
  61. data/spec/spacex/cores_spec.rb +45 -0
  62. data/spec/spacex/dragon_capsules_spec.rb +107 -0
  63. data/spec/spacex/endpoint_spec.rb +9 -0
  64. data/spec/spacex/history_spec.rb +50 -0
  65. data/spec/spacex/launches_spec.rb +652 -0
  66. data/spec/spacex/missions_spec.rb +35 -0
  67. data/spec/spacex/payloads_spec.rb +62 -0
  68. data/spec/spacex/roadster_spec.rb +36 -0
  69. data/spec/spacex/rockets_spec.rb +210 -0
  70. data/spec/spacex/ships_spec.rb +65 -0
  71. data/spec/spacex/version_spec.rb +7 -0
  72. data/spec/spec_helper.rb +20 -0
  73. data/spec/support/vcr.rb +11 -0
  74. metadata +283 -0
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
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
9
+ 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.'
19
+ end
20
+ end
21
+
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."
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe SPACEX::CompanyInfo do
4
+ context '#info', vcr: { cassette_name: 'company_info/info' } do
5
+ subject do
6
+ SPACEX::CompanyInfo.info
7
+ end
8
+ it 'returns company info' do
9
+ expect(subject.name).to eq 'SpaceX'
10
+ expect(subject.founder).to eq 'Elon Musk'
11
+ expect(subject.founded).to eq 2002
12
+ expect(subject.employees).to eq 7000
13
+ expect(subject.vehicles).to eq 3
14
+ expect(subject.launche_sites).to eq nil
15
+ expect(subject.test_sites).to eq 1
16
+ expect(subject.ceo).to eq 'Elon Musk'
17
+ expect(subject.cto).to eq 'Elon Musk'
18
+ expect(subject.coo).to eq 'Gwynne Shotwell'
19
+ expect(subject.cto_propulsion).to eq 'Tom Mueller'
20
+ expect(subject.valuation).to eq 27_500_000_000
21
+ expect(subject.headquarters.address).to eq 'Rocket Road'
22
+ expect(subject.headquarters.city).to eq 'Hawthorne'
23
+ expect(subject.headquarters.state).to eq 'California'
24
+ expect(subject.summary).to eq 'SpaceX designs, manufactures and launches advanced rockets and spacecraft. The company was founded in 2002 to revolutionize space technology, with the ultimate goal of enabling people to live on other planets.'
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
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
9
+ 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.'
22
+ end
23
+ end
24
+
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
37
+ expect(subject.rtls_attempts).to eq 0
38
+ expect(subject.rtls_landings).to eq 0
39
+ expect(subject.asds_attempts).to eq 1
40
+ 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'
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,107 @@
1
+ require 'spec_helper'
2
+
3
+ describe SPACEX::DragonCapsules do
4
+ context '#info', vcr: { cassette_name: 'dragon_capsules/info' } do
5
+ subject do
6
+ SPACEX::DragonCapsules.info
7
+ end
8
+ it 'returns Dragon Capsules info' do
9
+ expect(subject.first.capsule_id).to eq 'dragon1'
10
+ expect(subject.first.name).to eq 'Dragon 1'
11
+ expect(subject.first.type).to eq 'capsule'
12
+ expect(subject.first.active).to eq true
13
+ expect(subject.first.crew_capacity).to eq 0
14
+ expect(subject.first.sidewall_angle_deg).to eq 15
15
+ expect(subject.first.orbit_duration_yr).to eq 2
16
+ expect(subject.first.dry_mass_kg).to eq 4_200
17
+ expect(subject.first.dry_mass_lb).to eq 9_300
18
+ expect(subject.first.first_flight).to eq '2010-12-08'
19
+ expect(subject.first.heat_shield).to eq ({ 'material' => 'PICA-X', 'size_meters' => 3.6, 'temp_degrees' => 3000, 'dev_partner' => 'NASA' })
20
+ expect(subject.first.heat_shield['material']).to eq 'PICA-X'
21
+ expect(subject.first.heat_shield['size_meters']).to eq 3.6
22
+ expect(subject.first.heat_shield['temp_degrees']).to eq 3_000
23
+ expect(subject.first.heat_shield['dev_partner']).to eq 'NASA'
24
+ expect(subject.first.thrusters[0]['type']).to eq 'Draco'
25
+ expect(subject.first.thrusters[0]['amount']).to eq 18
26
+ expect(subject.first.thrusters[0]['pods']).to eq 4
27
+ expect(subject.first.thrusters[0]['fuel_1']).to eq 'nitrogen tetroxide'
28
+ expect(subject.first.thrusters[0]['fuel_2']).to eq 'monomethylhydrazine'
29
+ expect(subject.first.thrusters[0]['thrust']['kN']).to eq 0.4
30
+ expect(subject.first.thrusters[0]['thrust']['lbf']).to eq 90
31
+ expect(subject.first.launch_payload_mass['kg']).to eq 6_000
32
+ expect(subject.first.launch_payload_mass['lb']).to eq 13_228
33
+ expect(subject.first.launch_payload_vol['cubic_meters']).to eq 25
34
+ expect(subject.first.launch_payload_vol['cubic_feet']).to eq 883
35
+ expect(subject.first.return_payload_mass['kg']).to eq 3_000
36
+ expect(subject.first.return_payload_mass['lb']).to eq 6_614
37
+ expect(subject.first.return_payload_vol['cubic_meters']).to eq 11
38
+ expect(subject.first.return_payload_vol['cubic_feet']).to eq 388
39
+ expect(subject.first.pressurized_capsule['payload_volume']['cubic_meters']).to eq 11
40
+ expect(subject.first.pressurized_capsule['payload_volume']['cubic_feet']).to eq 388
41
+ expect(subject.first.trunk['trunk_volume']['cubic_meters']).to eq 14
42
+ expect(subject.first.trunk['trunk_volume']['cubic_feet']).to eq 494
43
+ expect(subject.first.trunk['cargo']['solar_array']).to eq 2
44
+ expect(subject.first.trunk['cargo']['unpressurized_cargo']).to eq true
45
+ expect(subject.first.height_w_trunk['meters']).to eq 7.2
46
+ expect(subject.first.height_w_trunk['feet']).to eq 23.6
47
+ expect(subject.first.diameter['meters']).to eq 3.7
48
+ expect(subject.first.diameter['feet']).to eq 12
49
+ expect(subject.first.wikipedia).to eq 'https://en.wikipedia.org/wiki/SpaceX_Dragon'
50
+ expect(subject.first.description).to start_with 'Dragon is a reusable spacecraft developed'
51
+
52
+ expect(subject[1].capsule_id).to eq 'dragon2'
53
+ expect(subject[1].name).to eq 'Dragon 2'
54
+ end
55
+ end
56
+
57
+ context "#info('dragon1')", vcr: { cassette_name: 'dragon_capsules/info/dragon1' } do
58
+ subject do
59
+ SPACEX::DragonCapsules.info('dragon1')
60
+ end
61
+
62
+ it 'returns Dragon Capsule info for "dragon1"' do
63
+ expect(subject.capsule_id).to eq 'dragon1'
64
+ expect(subject.name).to eq 'Dragon 1'
65
+ expect(subject.type).to eq 'capsule'
66
+ expect(subject.active).to eq true
67
+ expect(subject.crew_capacity).to eq 0
68
+ expect(subject.sidewall_angle_deg).to eq 15
69
+ expect(subject.orbit_duration_yr).to eq 2
70
+ expect(subject.dry_mass_kg).to eq 4_200
71
+ expect(subject.dry_mass_lb).to eq 9_300
72
+ expect(subject.first_flight).to eq '2010-12-08'
73
+ expect(subject.heat_shield).to eq ({ 'material' => 'PICA-X', 'size_meters' => 3.6, 'temp_degrees' => 3000, 'dev_partner' => 'NASA' })
74
+ expect(subject.heat_shield['material']).to eq 'PICA-X'
75
+ expect(subject.heat_shield['size_meters']).to eq 3.6
76
+ expect(subject.heat_shield['temp_degrees']).to eq 3_000
77
+ expect(subject.heat_shield['dev_partner']).to eq 'NASA'
78
+ expect(subject.thrusters[0]['type']).to eq 'Draco'
79
+ expect(subject.thrusters[0]['amount']).to eq 18
80
+ expect(subject.thrusters[0]['pods']).to eq 4
81
+ expect(subject.thrusters[0]['fuel_1']).to eq 'nitrogen tetroxide'
82
+ expect(subject.thrusters[0]['fuel_2']).to eq 'monomethylhydrazine'
83
+ expect(subject.thrusters[0]['thrust']['kN']).to eq 0.4
84
+ expect(subject.thrusters[0]['thrust']['lbf']).to eq 90
85
+ expect(subject.launch_payload_mass['kg']).to eq 6_000
86
+ expect(subject.launch_payload_mass['lb']).to eq 13_228
87
+ expect(subject.launch_payload_vol['cubic_meters']).to eq 25
88
+ expect(subject.launch_payload_vol['cubic_feet']).to eq 883
89
+ expect(subject.return_payload_mass['kg']).to eq 3_000
90
+ expect(subject.return_payload_mass['lb']).to eq 6_614
91
+ expect(subject.return_payload_vol['cubic_meters']).to eq 11
92
+ expect(subject.return_payload_vol['cubic_feet']).to eq 388
93
+ expect(subject.pressurized_capsule['payload_volume']['cubic_meters']).to eq 11
94
+ expect(subject.pressurized_capsule['payload_volume']['cubic_feet']).to eq 388
95
+ expect(subject.trunk['trunk_volume']['cubic_meters']).to eq 14
96
+ expect(subject.trunk['trunk_volume']['cubic_feet']).to eq 494
97
+ expect(subject.trunk['cargo']['solar_array']).to eq 2
98
+ expect(subject.trunk['cargo']['unpressurized_cargo']).to eq true
99
+ expect(subject.height_w_trunk['meters']).to eq 7.2
100
+ expect(subject.height_w_trunk['feet']).to eq 23.6
101
+ expect(subject.diameter['meters']).to eq 3.7
102
+ expect(subject.diameter['feet']).to eq 12
103
+ expect(subject.wikipedia).to eq 'https://en.wikipedia.org/wiki/SpaceX_Dragon'
104
+ expect(subject.description).to start_with 'Dragon is a reusable spacecraft developed by Space'
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe SPACEX::ENDPOINT_URI do
4
+ subject { SPACEX::ENDPOINT_URI }
5
+
6
+ it 'returns the URI for v3 of the SpaceX API' do
7
+ expect(subject).to eq 'https://api.spacexdata.com/v3'
8
+ end
9
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
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
+ )
25
+ end
26
+ end
27
+
28
+ context '#info(4)', vcr: { cassette_name: 'history/info/4' } do
29
+ subject do
30
+ SPACEX::History.info(4)
31
+ end
32
+
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
+ )
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,652 @@
1
+ require 'spec_helper'
2
+
3
+ describe SPACEX::Launches do
4
+ context '#latest', vcr: { cassette_name: 'launches/latest' } do
5
+ subject do
6
+ SPACEX::Launches.latest
7
+ end
8
+
9
+ it 'returns latest launch' do
10
+ expect(subject.flight_number).to eq 67
11
+ expect(subject.mission_name).to eq 'Merah Putih'
12
+ expect(subject.launch_year).to eq '2018'
13
+ expect(subject.launch_date_unix).to eq 1_533_619_080
14
+ expect(subject.launch_date_utc).to eq '2018-08-07T05:18:00.000Z'
15
+ expect(subject.launch_date_local).to eq '2018-08-07T01:18:00-04:00'
16
+ expect(subject.launch_success).to eq true
17
+ expect(subject.rocket.rocket_id).to eq 'falcon9'
18
+ expect(subject.rocket.rocket_name).to eq 'Falcon 9'
19
+ expect(subject.rocket.rocket_type).to eq 'FT'
20
+ expect(subject.rocket.first_stage.cores.first.core_serial).to eq 'B1046'
21
+ expect(subject.rocket.first_stage.cores.first.flight).to eq 2
22
+ expect(subject.rocket.first_stage.cores.first.block).to eq 5
23
+ expect(subject.rocket.first_stage.cores.first.reused).to eq true
24
+ expect(subject.rocket.first_stage.cores.first.land_success).to eq true
25
+ expect(subject.rocket.first_stage.cores.first.landing_type).to eq 'ASDS'
26
+ expect(subject.rocket.first_stage.cores.first.landing_vehicle).to eq 'OCISLY'
27
+ expect(subject.rocket.second_stage.block).to eq 5
28
+ expect(subject.rocket.second_stage.payloads.first.payload_id).to eq 'Telkom-4'
29
+ expect(subject.rocket.second_stage.payloads.first.norad_id.first).to eq 43_587
30
+ expect(subject.rocket.second_stage.payloads.first.reused).to eq false
31
+ expect(subject.rocket.second_stage.payloads.first.customers.first).to eq 'Telkom'
32
+ expect(subject.rocket.second_stage.payloads.first.nationality).to eq 'Indonesia'
33
+ expect(subject.rocket.second_stage.payloads.first.manufacturer).to eq 'SSL'
34
+ expect(subject.rocket.second_stage.payloads.first.payload_type).to eq 'Satellite'
35
+ expect(subject.rocket.second_stage.payloads.first.payload_mass_kg).to eq 5800
36
+ expect(subject.rocket.second_stage.payloads.first.payload_mass_lbs).to eq 12_786.81
37
+ expect(subject.rocket.second_stage.payloads.first.orbit).to eq 'GTO'
38
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.regime).to eq 'geostationary'
39
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.longitude).to eq '-108'.to_i
40
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.semi_major_axis_km).to eq 21_226.178
41
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.eccentricity).to eq 0.6904141
42
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.periapsis_km).to eq 193.19
43
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.apoapsis_km).to eq 29_502.896
44
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.inclination_deg).to eq 27.0648
45
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.period_min).to eq 512.941
46
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.lifespan_years).to eq 15
47
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.epoch).to eq '2018-08-07T06:57:16.000Z'
48
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.mean_motion).to eq 2.80734018
49
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.raan).to eq 227.0228
50
+ expect(subject.telemetry.flight_club).to eq nil
51
+ expect(subject.reuse.core).to eq true
52
+ expect(subject.reuse.sire_core1).to eq nil
53
+ expect(subject.reuse.side_core2).to eq false
54
+ expect(subject.reuse.fairings).to eq false
55
+ expect(subject.reuse.capsule).to eq false
56
+ expect(subject.launch_site.site_id).to eq 'ccafs_slc_40'
57
+ expect(subject.launch_site.site_name).to eq 'CCAFS SLC 40'
58
+ expect(subject.launch_site.site_name_long).to eq 'Cape Canaveral Air Force Station Space Launch Complex 40'
59
+ expect(subject.launch_success).to eq true
60
+ expect(subject.links.mission_patch).to eq 'https://images2.imgbox.com/a8/f5/ZgdsrbqW_o.png'
61
+ expect(subject.links.mision_patch_small).to eq nil
62
+ expect(subject.links.reddit_campaign).to eq 'https://www.reddit.com/r/spacex/comments/91gwfg/merah_putih_telkom4_launch_campaign_thread/'
63
+ expect(subject.links.reddit_launch).to eq 'https://www.reddit.com/r/spacex/comments/9539nr/rspacex_merah_putih_telkom4_official_launch/'
64
+ expect(subject.links.reddit_recovery).to eq nil
65
+ expect(subject.links.reddit_media).to eq 'https://www.reddit.com/r/spacex/comments/94zr0b/rspacex_merah_putih_media_thread_videos_images/'
66
+ expect(subject.links.presskit).to eq 'https://www.spacex.com/sites/spacex/files/merahputihpresskit.pdf'
67
+ expect(subject.links.article_link).to eq 'https://spaceflightnow.com/2018/08/07/indonesian-communications-satellite-deployed-in-orbit-by-spacex/'
68
+ expect(subject.links.wikipedia).to eq 'https://en.wikipedia.org/wiki/Telkom_Indonesia'
69
+ expect(subject.links.video_link).to eq 'https://www.youtube.com/watch?v=FjfQNBYv2IY'
70
+ expect(subject.details).to eq 'Indonesian comsat intended to replace the aging Telkom 1 at 108° E. First reflight of a Block 5-version booster.'
71
+ expect(subject.upcoming).to eq false
72
+ expect(subject.static_fire_date_utc).to eq '2018-08-02T15:53:00.000Z'
73
+ end
74
+ end
75
+
76
+ context '#info', vcr: { cassette_name: 'launches/info' } do
77
+ subject do
78
+ SPACEX::Launches.info
79
+ end
80
+
81
+ it 'returns and array of launch hashes' do
82
+ expect(subject).to be_an Array
83
+ expect(subject.first).to be_a Hash
84
+ end
85
+
86
+ it 'returns the correct number of launches' do
87
+ expect(subject.count).to eq 90
88
+ end
89
+
90
+ it 'returns the subject.first launch' do
91
+ expect(subject.first.flight_number).to eq 1
92
+ expect(subject.first.mission_name).to eq 'FalconSat'
93
+ expect(subject.first.launch_year).to eq '2006'
94
+ expect(subject.first.launch_date_unix).to eq 1_143_239_400
95
+ expect(subject.first.launch_date_utc).to eq '2006-03-24T22:30:00.000Z'
96
+ expect(subject.first.launch_date_local).to eq '2006-03-25T10:30:00+12:00'
97
+ expect(subject.first.launch_success).to eq false
98
+ expect(subject.first.rocket.rocket_id).to eq 'falcon1'
99
+ expect(subject.first.rocket.rocket_name).to eq 'Falcon 1'
100
+ expect(subject.first.rocket.rocket_type).to eq 'Merlin A'
101
+ expect(subject.first.rocket.first_stage.cores.first.core_serial).to eq 'Merlin1A'
102
+ expect(subject.first.rocket.first_stage.cores.first.flight).to eq 1
103
+ expect(subject.first.rocket.first_stage.cores.first.block).to eq nil
104
+ expect(subject.first.rocket.first_stage.cores.first.reused).to eq false
105
+ expect(subject.first.rocket.first_stage.cores.first.land_success).to eq nil
106
+ expect(subject.first.rocket.first_stage.cores.first.landing_type).to eq nil
107
+ expect(subject.first.rocket.first_stage.cores.first.landing_vehicle).to eq nil
108
+ expect(subject.first.rocket.second_stage.block).to eq 1
109
+ expect(subject.first.rocket.second_stage.payloads.first.payload_id).to eq 'FalconSAT-2'
110
+ expect(subject.first.rocket.second_stage.payloads.first.norad_id.first).to eq nil
111
+ expect(subject.first.rocket.second_stage.payloads.first.reused).to eq false
112
+ expect(subject.first.rocket.second_stage.payloads.first.customers.first).to eq 'DARPA'
113
+ expect(subject.first.rocket.second_stage.payloads.first.nationality).to eq 'United States'
114
+ expect(subject.first.rocket.second_stage.payloads.first.manufacturer).to eq 'SSTL'
115
+ expect(subject.first.rocket.second_stage.payloads.first.payload_type).to eq 'Satellite'
116
+ expect(subject.first.rocket.second_stage.payloads.first.payload_mass_kg).to eq 20
117
+ expect(subject.first.rocket.second_stage.payloads.first.payload_mass_lbs).to eq 43
118
+ expect(subject.first.rocket.second_stage.payloads.first.orbit).to eq 'LEO'
119
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.reference_system).to eq 'geocentric'
120
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.regime).to eq 'low-earth'
121
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.longitude).to eq nil
122
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.semi_major_axis_km).to eq nil
123
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.eccentricity).to eq nil
124
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.periapsis_km).to eq 400
125
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.apoapsis_km).to eq 500
126
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.inclination_deg).to eq 39
127
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.period_min).to eq nil
128
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.lifespan_years).to eq nil
129
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.epoch).to eq nil
130
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.mean_motion).to eq nil
131
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.raan).to eq nil
132
+ expect(subject.first.telemetry.flight_club).to eq nil
133
+ expect(subject.first.reuse).to be_nil
134
+ expect(subject.first.launch_site.site_id).to eq 'kwajalein_atoll'
135
+ expect(subject.first.launch_site.site_name).to eq 'Kwajalein Atoll'
136
+ expect(subject.first.launch_site.site_name_long).to eq 'Kwajalein Atoll Omelek Island'
137
+ expect(subject.first.launch_success).to eq false
138
+ expect(subject.first.links.mission_patch).to eq 'https://images2.imgbox.com/40/e3/GypSkayF_o.png'
139
+ expect(subject.first.links.mision_patch_small).to eq nil
140
+ expect(subject.first.links.reddit_campaign).to eq nil
141
+ expect(subject.first.links.reddit_launch).to eq nil
142
+ expect(subject.first.links.reddit_recovery).to eq nil
143
+ expect(subject.first.links.reddit_media).to eq nil
144
+ expect(subject.first.links.presskit).to eq nil
145
+ expect(subject.first.links.article_link).to eq 'https://www.space.com/2196-spacex-inaugural-falcon-1-rocket-lost-launch.html'
146
+ expect(subject.first.links.wikipedia).to eq 'https://en.wikipedia.org/wiki/DemoSat'
147
+ expect(subject.first.links.video_link).to eq 'https://www.youtube.com/watch?v=0a_00nJ_Y88'
148
+ expect(subject.first.details).to eq 'Engine failure at 33 seconds and loss of vehicle'
149
+ expect(subject.first.upcoming).to eq false
150
+ expect(subject.first.static_fire_date_utc).to eq '2006-03-17T00:00:00.000Z'
151
+ end
152
+
153
+ it 'returns the subject.last scheduled launch' do
154
+ expect(subject.last.flight_number).to eq 91
155
+ expect(subject.last.mission_name).to eq 'GPS IIIA-3'
156
+ expect(subject.last.launch_year).to eq '2019'
157
+ expect(subject.last.launch_date_unix).to eq 1_569_888_000
158
+ expect(subject.last.launch_date_utc).to eq '2019-10-01T00:00:00.000Z'
159
+ expect(subject.last.launch_date_local).to eq '2019-09-30T20:00:00-04:00'
160
+ expect(subject.last.launch_success).to eq nil
161
+ expect(subject.last.rocket.rocket_id).to eq 'falcon9'
162
+ expect(subject.last.rocket.rocket_name).to eq 'Falcon 9'
163
+ expect(subject.last.rocket.rocket_type).to eq 'FT'
164
+ expect(subject.last.rocket.last_stage).to be_nil
165
+ expect(subject.last.rocket.second_stage.block).to eq nil
166
+ expect(subject.last.rocket.second_stage.payloads.last.payload_id).to eq 'GPS IIIA-3'
167
+ expect(subject.last.rocket.second_stage.payloads.last.norad_id.last).to eq nil
168
+ expect(subject.last.rocket.second_stage.payloads.last.reused).to eq false
169
+ expect(subject.last.rocket.second_stage.payloads.last.customers.last).to eq 'USAF'
170
+ expect(subject.last.rocket.second_stage.payloads.last.nationality).to eq 'United States'
171
+ expect(subject.last.rocket.second_stage.payloads.last.manufacturer).to eq 'Lockheed Martin'
172
+ expect(subject.last.rocket.second_stage.payloads.last.payload_type).to eq 'Satellite'
173
+ expect(subject.last.rocket.second_stage.payloads.last.payload_mass_kg).to eq 3880
174
+ expect(subject.last.rocket.second_stage.payloads.last.payload_mass_lbs).to eq 8553.94
175
+ expect(subject.last.rocket.second_stage.payloads.last.orbit).to eq 'MEO'
176
+ expect(subject.last.rocket.second_stage.payloads.last.orbit_params.reference_system).to eq nil
177
+ expect(subject.last.rocket.second_stage.payloads.last.orbit_params.regime).to eq nil
178
+ expect(subject.last.rocket.second_stage.payloads.last.orbit_params.longitude).to eq nil
179
+ expect(subject.last.rocket.second_stage.payloads.last.orbit_params.semi_major_axis_km).to eq nil
180
+ expect(subject.last.rocket.second_stage.payloads.last.orbit_params.eccentricity).to eq nil
181
+ expect(subject.last.rocket.second_stage.payloads.last.orbit_params.periapsis_km).to eq nil
182
+ expect(subject.last.rocket.second_stage.payloads.last.orbit_params.apoapsis_km).to eq nil
183
+ expect(subject.last.rocket.second_stage.payloads.last.orbit_params.inclination_deg).to eq nil
184
+ expect(subject.last.rocket.second_stage.payloads.last.orbit_params.period_min).to eq nil
185
+ expect(subject.last.rocket.second_stage.payloads.last.orbit_params.lifespan_years).to eq 15
186
+ expect(subject.last.rocket.second_stage.payloads.last.orbit_params.epoch).to eq nil
187
+ expect(subject.last.rocket.second_stage.payloads.last.orbit_params.mean_motion).to eq nil
188
+ expect(subject.last.rocket.second_stage.payloads.last.orbit_params.raan).to eq nil
189
+ expect(subject.last.telemetry.flight_club).to eq nil
190
+ expect(subject.last.reuse).to be_nil
191
+ expect(subject.last.launch_site.site_id).to eq 'ccafs_slc_40'
192
+ expect(subject.last.launch_site.site_name).to eq 'CCAFS SLC 40'
193
+ expect(subject.last.launch_site.site_name_long).to eq 'Cape Canaveral Air Force Station Space Launch Complex 40'
194
+ expect(subject.last.launch_success).to eq nil
195
+ expect(subject.last.links.mission_patch).to eq nil
196
+ expect(subject.last.links.mision_patch_small).to eq nil
197
+ expect(subject.last.links.reddit_campaign).to eq nil
198
+ expect(subject.last.links.reddit_launch).to eq nil
199
+ expect(subject.last.links.reddit_recovery).to eq nil
200
+ expect(subject.last.links.reddit_media).to eq nil
201
+ expect(subject.last.links.presskit).to eq nil
202
+ expect(subject.last.links.article_link).to eq nil
203
+ expect(subject.last.links.wikipedia).to eq nil
204
+ expect(subject.last.links.video_link).to eq nil
205
+ expect(subject.last.details).to eq nil
206
+ expect(subject.last.upcoming).to eq true
207
+ expect(subject.last.static_fire_date_utc).to eq nil
208
+ end
209
+ end
210
+
211
+ context '#info(68)', vcr: { cassette_name: 'launches/68' } do
212
+ subject do
213
+ SPACEX::Launches.info(68)
214
+ end
215
+
216
+ it 'returns info for flight number 68' do
217
+ expect(subject.flight_number).to eq(68)
218
+ expect(subject.rocket.rocket_name).to eq('Falcon 9')
219
+ expect(subject.rocket.first_stage.cores.first.core_serial).to eq('B1049')
220
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.regime).to eq('geostationary')
221
+
222
+ expect(subject).to eq(
223
+ 'flight_number' => 68,
224
+ 'mission_name' => 'Telstar 18V',
225
+ 'mission_id' => [
226
+ 'F4F83DE'
227
+ ],
228
+ 'launch_year' => '2018',
229
+ 'launch_date_unix' => 1_536_554_700,
230
+ 'launch_date_utc' => '2018-09-10T04:45:00.000Z',
231
+ 'launch_date_local' => '2018-09-10T00:45:00-04:00',
232
+ 'is_tentative' => false,
233
+ 'tentative_max_precision' => 'hour',
234
+ 'rocket' => {
235
+ 'rocket_id' => 'falcon9',
236
+ 'rocket_name' => 'Falcon 9',
237
+ 'rocket_type' => 'FT',
238
+ 'first_stage' => {
239
+ 'cores' => [{
240
+ 'core_serial' => 'B1049',
241
+ 'flight' => 1,
242
+ 'block' => 5,
243
+ 'reused' => false,
244
+ 'land_success' => true,
245
+ 'landing_intent' => true,
246
+ 'landing_type' => 'ASDS',
247
+ 'landing_vehicle' => 'OCISLY'
248
+ }]
249
+ },
250
+ 'second_stage' => {
251
+ 'block' => 5,
252
+ 'payloads' => [{
253
+ 'payload_id' => 'Telstar 18V',
254
+ 'norad_id' => [43_611],
255
+ 'reused' => false,
256
+ 'customers' => ['Telesat'],
257
+ 'nationality' => 'Canada',
258
+ 'manufacturer' => 'SSL',
259
+ 'payload_type' => 'Satellite',
260
+ 'payload_mass_kg' => 7060,
261
+ 'payload_mass_lbs' => 15_564.64,
262
+ 'orbit' => 'GTO',
263
+ 'orbit_params' => {
264
+ 'reference_system' => 'geocentric',
265
+ 'regime' => 'geostationary',
266
+ 'longitude' => 138,
267
+ 'semi_major_axis_km' => 7226.647,
268
+ 'eccentricity' => 0.0013608,
269
+ 'periapsis_km' => 838.677,
270
+ 'apoapsis_km' => 858.346,
271
+ 'inclination_deg' => 98.8086,
272
+ 'period_min' => 101.897,
273
+ 'lifespan_years' => 15,
274
+ 'epoch' => '2018-09-07T06:29:40.000Z',
275
+ 'mean_motion' => 14.13180055,
276
+ 'raan' => 322.194,
277
+ 'arg_of_pericenter' => 130.3173,
278
+ 'mean_anomaly' => 328.1487
279
+ }
280
+ }]
281
+ },
282
+ 'fairings' => {
283
+ 'reused' => false,
284
+ 'recovery_attempt' => false,
285
+ 'recovered' => false,
286
+ 'ship' => nil
287
+ }
288
+ },
289
+ 'ships' => %w[OCISLY HAWK GOQUEST],
290
+ 'telemetry' => {
291
+ 'flight_club' => 'https://www.flightclub.io/result/2d?code=T18V'
292
+ },
293
+ 'launch_site' => {
294
+ 'site_id' => 'ccafs_slc_40',
295
+ 'site_name' => 'CCAFS SLC 40',
296
+ 'site_name_long' => 'Cape Canaveral Air Force Station Space Launch Complex 40'
297
+ },
298
+ 'launch_success' => true,
299
+ 'links' => {
300
+ 'mission_patch' => 'https://images2.imgbox.com/ba/db/3plcm5IB_o.png',
301
+ 'mission_patch_small' => 'https://images2.imgbox.com/2d/d2/jStsqeLC_o.png',
302
+ 'reddit_campaign' => 'https://www.reddit.com/r/spacex/comments/95cte4/telstar_18v_apstar_5c_launch_campaign_thread/',
303
+ 'reddit_launch' => 'https://www.reddit.com/r/spacex/comments/9e7bmq/rspacex_telstar_18v_official_launch_discussion/',
304
+ 'reddit_recovery' => 'https://www.reddit.com/r/spacex/comments/9erxlh/telstar_18_vantage_recovery_thread/',
305
+ 'reddit_media' => 'https://www.reddit.com/r/spacex/comments/9ebkqw/rspacex_telstar_18v_media_thread_videos_images/',
306
+ 'presskit' => 'https://www.spacex.com/sites/spacex/files/telstar18vantagepresskit.pdf',
307
+ 'article_link' => 'https://spaceflightnow.com/2018/09/10/spacex-telesat-achieve-repeat-success-with-midnight-hour-launch/',
308
+ 'wikipedia' => 'https://en.wikipedia.org/wiki/Telstar_18V',
309
+ 'video_link' => 'https://www.youtube.com/watch?v=Apw3xqwsG1U',
310
+ 'flickr_images' => [
311
+ 'https://farm2.staticflickr.com/1878/43690848045_492ef182dd_o.jpg',
312
+ 'https://farm2.staticflickr.com/1856/43881229604_6d42e838b6_o.jpg',
313
+ 'https://farm2.staticflickr.com/1852/43881223704_93777e34af_o.jpg',
314
+ 'https://farm2.staticflickr.com/1841/43881217094_558b7b214e_o.jpg',
315
+ 'https://farm2.staticflickr.com/1869/43881193934_423eff8c86_o.jpg'
316
+ ]
317
+ },
318
+ 'details' => 'SpaceX\'s sixteenth flight of 2018 launched the Telstar '\
319
+ '18v GEO communication satellite for Telesat, the second launch for '\
320
+ 'the canadian company in a few months. The first stage was a new '\
321
+ 'Falcon 9 V1.2 Block 5 which was successfully recovered on OCISLY.',
322
+ 'upcoming' => false,
323
+ 'static_fire_date_utc' => '2018-09-05T07:21:00.000Z',
324
+ 'static_fire_date_unix' => 1_536_132_060
325
+ )
326
+ end
327
+ end
328
+
329
+ context '#next', vcr: { cassette_name: 'launches/next' } do
330
+ subject do
331
+ SPACEX::Launches.next
332
+ end
333
+
334
+ it 'returns next launch' do
335
+ expect(subject.flight_number).to eq 70
336
+ expect(subject.mission_name).to eq 'Es’hail 2'
337
+ expect(subject.launch_year).to eq '2018'
338
+ expect(subject.launch_date_unix).to eq 1_541_030_400
339
+ expect(subject.launch_date_utc).to eq '2018-11-01T00:00:00.000Z'
340
+ expect(subject.launch_date_local).to eq '2018-10-31T20:00:00-04:00'
341
+ expect(subject.launch_success).to eq nil
342
+ expect(subject.rocket.rocket_id).to eq 'falcon9'
343
+ expect(subject.rocket.rocket_name).to eq 'Falcon 9'
344
+ expect(subject.rocket.rocket_type).to eq 'FT'
345
+ expect(subject.rocket.first_stage.cores.first.core_serial).to eq nil
346
+ expect(subject.rocket.first_stage.cores.first.flight).to eq nil
347
+ expect(subject.rocket.first_stage.cores.first.block).to eq 5
348
+ expect(subject.rocket.first_stage.cores.first.reused).to eq false
349
+ expect(subject.rocket.first_stage.cores.first.land_success).to eq nil
350
+ expect(subject.rocket.first_stage.cores.first.landing_type).to eq nil
351
+ expect(subject.rocket.first_stage.cores.first.landing_vehicle).to eq nil
352
+ expect(subject.rocket.second_stage.block).to eq 5
353
+ expect(subject.rocket.second_stage.payloads.first.payload_id).to eq 'Es’hail 2'
354
+ expect(subject.rocket.second_stage.payloads.first.norad_id.first).to eq nil
355
+ expect(subject.rocket.second_stage.payloads.first.reused).to eq false
356
+ expect(subject.rocket.second_stage.payloads.first.customers.first).to eq 'Es’hailSat'
357
+ expect(subject.rocket.second_stage.payloads.first.nationality).to eq 'Qatar'
358
+ expect(subject.rocket.second_stage.payloads.first.manufacturer).to eq 'Mitsubishi Electric'
359
+ expect(subject.rocket.second_stage.payloads.first.payload_type).to eq 'Satellite'
360
+ expect(subject.rocket.second_stage.payloads.first.payload_mass_kg).to eq 3000
361
+ expect(subject.rocket.second_stage.payloads.first.payload_mass_lbs).to eq 6_613.868
362
+ expect(subject.rocket.second_stage.payloads.first.orbit).to eq 'GTO'
363
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.regime).to eq 'geostationary'
364
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.longitude).to eq 25.5
365
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.semi_major_axis_km).to eq nil
366
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.eccentricity).to eq nil
367
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.periapsis_km).to eq nil
368
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.apoapsis_km).to eq nil
369
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.inclination_deg).to eq nil
370
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.period_min).to eq nil
371
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.lifespan_years).to eq 15
372
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.epoch).to eq nil
373
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.mean_motion).to eq nil
374
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.raan).to eq nil
375
+ expect(subject.telemetry.flight_club).to eq nil
376
+ expect(subject.launch_site.site_id).to eq 'ccafs_slc_40'
377
+ expect(subject.launch_site.site_name).to eq 'CCAFS SLC 40'
378
+ expect(subject.launch_site.site_name_long).to eq 'Cape Canaveral Air Force Station Space Launch Complex 40'
379
+ expect(subject.launch_success).to eq nil
380
+ expect(subject.links.mission_patch).to eq nil
381
+ expect(subject.links.mision_patch_small).to eq nil
382
+ expect(subject.links.reddit_campaign).to eq nil
383
+ expect(subject.links.reddit_launch).to eq nil
384
+ expect(subject.links.reddit_recovery).to eq nil
385
+ expect(subject.links.reddit_media).to eq nil
386
+ expect(subject.links.presskit).to eq nil
387
+ expect(subject.links.article_link).to eq nil
388
+ expect(subject.links.wikipedia).to eq nil
389
+ expect(subject.links.video_link).to eq nil
390
+ expect(subject.details).to eq nil
391
+ expect(subject.upcoming).to eq true
392
+ expect(subject.static_fire_date_utc).to eq nil
393
+ end
394
+ end
395
+
396
+ context '#upcoming', vcr: { cassette_name: 'launches/upcoming' } do
397
+ subject do
398
+ SPACEX::Launches.upcoming
399
+ end
400
+
401
+ it 'returns and array of upcoming launch hashes' do
402
+ expect(subject).to be_an Array
403
+ expect(subject.first).to be_a Hash
404
+ expect(subject.all?(&:upcoming)).to be true
405
+ end
406
+
407
+ it 'returns launches scheduled in the future' do
408
+ subject.each do |launch|
409
+ expect(launch.launch_year).to be >= Time.now.year.to_s
410
+ expect(Time.parse(launch.launch_date_utc)).to be >= Time.now.utc
411
+ expect(launch.rocket.first_stage.cores.first.land_success).to be nil
412
+ expect(launch.launch_success).to be nil
413
+ end
414
+ end
415
+
416
+ context 'returns upcoming launches' do
417
+ it 'returns the next upcoming launch' do
418
+ expect(subject.first.flight_number).to eq 70
419
+ expect(subject.first.mission_name).to eq 'Es’hail 2'
420
+ expect(subject.first.mission_id).to eq []
421
+ expect(subject.first.launch_year).to eq '2018'
422
+ expect(subject.first.launch_date_unix).to eq 1_542_228_360
423
+ expect(subject.first.launch_date_utc).to eq '2018-11-14T20:46:00.000Z'
424
+ expect(subject.first.launch_date_local).to eq '2018-11-14T15:46:00-05:00'
425
+ expect(subject.first.is_tentative).to eq true
426
+ expect(subject.first.tentative_max_precision).to eq 'hour'
427
+ expect(subject.first.rocket.rocket_id).to eq 'falcon9'
428
+ expect(subject.first.rocket.rocket_name).to eq 'Falcon 9'
429
+ expect(subject.first.rocket.rocket_type).to eq 'FT'
430
+ expect(subject.first.rocket.first_stage.cores).to be_an(Array)
431
+ expect(subject.first.rocket.first_stage.cores.first).to eq(
432
+ 'core_serial' => nil,
433
+ 'flight' => nil,
434
+ 'block' => 5,
435
+ 'gridfins' => true,
436
+ 'legs' => true,
437
+ 'reused' => false,
438
+ 'land_success' => nil,
439
+ 'landing_intent' => true,
440
+ 'landing_type' => 'ASDS',
441
+ 'landing_vehicle' => 'OCISLY'
442
+ )
443
+ expect(subject.first.rocket.second_stage.block).to eq 5
444
+ expect(subject.first.rocket.second_stage.payloads).to be_an(Array)
445
+ expect(subject.first.rocket.second_stage.payloads.first).to eq(
446
+ 'payload_id' => 'Es’hail 2',
447
+ 'norad_id' => [],
448
+ 'reused' => false,
449
+ 'customers' => ['Es’hailSat'],
450
+ 'nationality' => 'Qatar',
451
+ 'manufacturer' => 'Mitsubishi Electric',
452
+ 'payload_type' => 'Satellite',
453
+ 'payload_mass_kg' => 3000,
454
+ 'payload_mass_lbs' => 6613.868,
455
+ 'orbit' => 'GTO',
456
+ 'orbit_params' => {
457
+ 'reference_system' => 'geocentric',
458
+ 'regime' => 'geostationary',
459
+ 'longitude' => 25.5,
460
+ 'semi_major_axis_km' => nil,
461
+ 'eccentricity' => nil,
462
+ 'periapsis_km' => nil,
463
+ 'apoapsis_km' => nil,
464
+ 'inclination_deg' => nil,
465
+ 'period_min' => nil,
466
+ 'lifespan_years' => 15,
467
+ 'epoch' => nil,
468
+ 'mean_motion' => nil,
469
+ 'raan' => nil,
470
+ 'arg_of_pericenter' => nil,
471
+ 'mean_anomaly' => nil
472
+ }
473
+ )
474
+ expect(subject.first.rocket.fairings).to eq(
475
+ 'reused' => false,
476
+ 'recovery_attempt' => false,
477
+ 'recovered' => false,
478
+ 'ship' => nil
479
+ )
480
+ expect(subject.first.ships).to eq []
481
+ expect(subject.first.telemetry.flight_club).to eq nil
482
+ expect(subject.first.launch_site).to eq(
483
+ 'site_id' => 'ccafs_slc_40',
484
+ 'site_name' => 'CCAFS SLC 40',
485
+ 'site_name_long' => 'Cape Canaveral Air Force Station Space Launch Complex 40'
486
+ )
487
+ expect(subject.first.launch_success).to eq nil
488
+ expect(subject.first.links).to eq(
489
+ 'mission_patch' => nil,
490
+ 'mission_patch_small' => nil,
491
+ 'reddit_campaign' => 'https://www.reddit.com/r/spacex/comments/9p82jt/eshail_2_launch_campaign_thread/',
492
+ 'reddit_launch' => nil,
493
+ 'reddit_recovery' => nil,
494
+ 'reddit_media' => nil,
495
+ 'presskit' => nil,
496
+ 'article_link' => nil,
497
+ 'wikipedia' => nil,
498
+ 'video_link' => nil,
499
+ 'flickr_images' => []
500
+ )
501
+ expect(subject.first.details).to eq 'SpaceX\'s eighteenth flight of 2018 will '\
502
+ 'be its first for Es\'hailSat. Es\'hail-2 is a communications satellite '\
503
+ 'that will deliver television and internet to Qatar and the surrounding '\
504
+ 'region. It will be launched into a geostationary transfer orbit from '\
505
+ 'LC-39A at Kennedy Space Center. The booster is expected to land on OCISLY.'
506
+ expect(subject.first.upcoming).to eq true
507
+ expect(subject.first.static_fire_date_utc).to eq nil
508
+ expect(subject.first.static_fire_date_unix).to eq nil
509
+ end
510
+
511
+ it 'returns the last upcoming launch' do
512
+ expect(subject.last.flight_number).to eq 91
513
+ expect(subject.last.mission_name).to eq 'GPS IIIA-3'
514
+ expect(subject.last.mission_id).to eq []
515
+ expect(subject.last.launch_year).to eq '2019'
516
+ expect(subject.last.launch_date_unix).to eq 1_569_888_000
517
+ expect(subject.last.launch_date_utc).to eq '2019-10-01T00:00:00.000Z'
518
+ expect(subject.last.launch_date_local).to eq '2019-09-30T20:00:00-04:00'
519
+ expect(subject.last.is_tentative).to eq true
520
+ expect(subject.last.tentative_max_precision).to eq 'month'
521
+ expect(subject.last.rocket.rocket_id).to eq 'falcon9'
522
+ expect(subject.last.rocket.rocket_name).to eq 'Falcon 9'
523
+ expect(subject.last.rocket.rocket_type).to eq 'FT'
524
+ expect(subject.last.rocket.first_stage.cores).to be_an(Array)
525
+ expect(subject.last.rocket.first_stage.cores.first).to eq(
526
+ 'core_serial' => nil,
527
+ 'flight' => nil,
528
+ 'block' => nil,
529
+ 'gridfins' => nil,
530
+ 'legs' => nil,
531
+ 'reused' => false,
532
+ 'land_success' => nil,
533
+ 'landing_intent' => nil,
534
+ 'landing_type' => nil,
535
+ 'landing_vehicle' => nil
536
+ )
537
+ expect(subject.last.rocket.second_stage.block).to eq nil
538
+ expect(subject.last.rocket.second_stage.payloads).to be_an(Array)
539
+ expect(subject.last.rocket.second_stage.payloads.first).to eq(
540
+ 'payload_id' => 'GPS IIIA-3',
541
+ 'norad_id' => [],
542
+ 'reused' => false,
543
+ 'customers' => ['USAF'],
544
+ 'nationality' => 'United States',
545
+ 'manufacturer' => 'Lockheed Martin',
546
+ 'payload_type' => 'Satellite',
547
+ 'payload_mass_kg' => 3880,
548
+ 'payload_mass_lbs' => 8553.94,
549
+ 'orbit' => 'MEO',
550
+ 'orbit_params' => {
551
+ 'reference_system' => nil,
552
+ 'regime' => nil,
553
+ 'longitude' => nil,
554
+ 'semi_major_axis_km' => nil,
555
+ 'eccentricity' => nil,
556
+ 'periapsis_km' => nil,
557
+ 'apoapsis_km' => nil,
558
+ 'inclination_deg' => nil,
559
+ 'period_min' => nil,
560
+ 'lifespan_years' => 15,
561
+ 'epoch' => nil,
562
+ 'mean_motion' => nil,
563
+ 'raan' => nil,
564
+ 'arg_of_pericenter' => nil,
565
+ 'mean_anomaly' => nil
566
+ }
567
+ )
568
+ expect(subject.last.rocket.fairings).to eq(
569
+ 'reused' => false,
570
+ 'recovery_attempt' => nil,
571
+ 'recovered' => nil,
572
+ 'ship' => nil
573
+ )
574
+ expect(subject.last.ships).to eq []
575
+ expect(subject.last.telemetry.flight_club).to eq nil
576
+ expect(subject.last.launch_site).to eq(
577
+ 'site_id' => 'ccafs_slc_40',
578
+ 'site_name' => 'CCAFS SLC 40',
579
+ 'site_name_long' => 'Cape Canaveral Air Force Station Space Launch Complex 40'
580
+ )
581
+ expect(subject.last.launch_success).to eq nil
582
+ expect(subject.last.links).to eq(
583
+ 'mission_patch' => nil,
584
+ 'mission_patch_small' => nil,
585
+ 'reddit_campaign' => nil,
586
+ 'reddit_launch' => nil,
587
+ 'reddit_recovery' => nil,
588
+ 'reddit_media' => nil,
589
+ 'presskit' => nil,
590
+ 'article_link' => nil,
591
+ 'wikipedia' => nil,
592
+ 'video_link' => nil,
593
+ 'flickr_images' => []
594
+ )
595
+ expect(subject.last.details).to eq nil
596
+ expect(subject.last.upcoming).to eq true
597
+ expect(subject.last.static_fire_date_utc).to eq nil
598
+ expect(subject.last.static_fire_date_unix).to eq nil
599
+ end
600
+ end
601
+ end
602
+
603
+ context '#all', vcr: { cassette_name: 'launches/all' } do
604
+ subject do
605
+ SPACEX::Launches.all
606
+ end
607
+
608
+ it 'returns all launches' do
609
+ expect(subject.first.flight_number).to eq 1
610
+ expect(subject.first.mission_name).to eq 'FalconSat'
611
+ end
612
+ end
613
+
614
+ context '#past', vcr: { cassette_name: 'launches/past' } do
615
+ subject do
616
+ SPACEX::Launches.past
617
+ end
618
+
619
+ it 'returns and array of launch hashes' do
620
+ expect(subject).to be_an Array
621
+ expect(subject.first).to be_a Hash
622
+ end
623
+
624
+ it 'returns the correct number of launches' do
625
+ expect(subject.count).to eq 69
626
+ end
627
+
628
+ context 'returns past launches' do
629
+ it 'returns the first launch' do
630
+ expect(subject.first.flight_number).to eq(1)
631
+ expect(subject.first.mission_name).to eq('FalconSat')
632
+ expect(subject.first.rocket.rocket_name).to eq('Falcon 1')
633
+ expect(subject.first.rocket.first_stage.cores.first.core_serial).to eq('Merlin1A')
634
+ expect(subject.first.rocket.second_stage.payloads.first.payload_id).to eq('FalconSAT-2')
635
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.regime).to eq('low-earth')
636
+ expect(subject.first.launch_site.site_id).to eq('kwajalein_atoll')
637
+ expect(subject.first.launch_success).to eq(false)
638
+ end
639
+
640
+ it 'returns the last past launch' do
641
+ expect(subject.last.flight_number).to eq(69)
642
+ expect(subject.last.mission_name).to eq('SAOCOM 1A')
643
+ expect(subject.last.rocket.rocket_name).to eq('Falcon 9')
644
+ expect(subject.last.rocket.first_stage.cores.first.core_serial).to eq('B1048')
645
+ expect(subject.last.rocket.second_stage.payloads.first.payload_id).to eq('SAOCOM 1A')
646
+ expect(subject.last.rocket.second_stage.payloads.first.orbit_params.regime).to eq('sun-synchronous')
647
+ expect(subject.last.launch_site.site_id).to eq('vafb_slc_4e')
648
+ expect(subject.last.launch_success).to eq(true)
649
+ end
650
+ end
651
+ end
652
+ end