spacex 0.0.5 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +7 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +6 -0
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +6 -0
  6. data/.rubocop_todo.yml +9 -23
  7. data/.ruby-version +1 -1
  8. data/.travis.yml +18 -3
  9. data/CHANGELOG.md +61 -0
  10. data/CONTRIBUTING.md +37 -0
  11. data/Gemfile +4 -2
  12. data/README.md +458 -25
  13. data/lib/spacex.rb +15 -4
  14. data/lib/spacex/api_info.rb +7 -0
  15. data/lib/spacex/base_request.rb +51 -13
  16. data/lib/spacex/capsules.rb +19 -0
  17. data/lib/spacex/company_info.rb +1 -3
  18. data/lib/spacex/cores.rb +22 -0
  19. data/lib/spacex/dragon_capsules.rb +33 -0
  20. data/lib/spacex/endpoint.rb +1 -3
  21. data/lib/spacex/history.rb +7 -0
  22. data/lib/spacex/landing_pads.rb +11 -0
  23. data/lib/spacex/launch_pads.rb +11 -0
  24. data/lib/spacex/launches.rb +21 -3
  25. data/lib/spacex/missions.rb +18 -0
  26. data/lib/spacex/payloads.rb +7 -0
  27. data/lib/spacex/resource.rb +5 -0
  28. data/lib/spacex/roadster.rb +7 -0
  29. data/lib/spacex/rockets.rb +7 -0
  30. data/lib/spacex/ships.rb +33 -0
  31. data/lib/spacex/version.rb +1 -4
  32. data/spacex.gemspec +8 -8
  33. data/spec/fixtures/spacex/api_info/info.yml +65 -0
  34. data/spec/fixtures/spacex/capsules.yml +83 -0
  35. data/spec/fixtures/spacex/capsules/C202.yml +123 -0
  36. data/spec/fixtures/spacex/company_info/info.yml +75 -14
  37. data/spec/fixtures/spacex/cores.yml +62 -0
  38. data/spec/fixtures/spacex/cores/B1041.yml +123 -0
  39. data/spec/fixtures/spacex/dragon_capsules/info.yml +77 -0
  40. data/spec/fixtures/spacex/dragon_capsules/info/dragon1.yml +131 -0
  41. data/spec/fixtures/spacex/history/info.yml +62 -0
  42. data/spec/fixtures/spacex/history/info/4.yml +62 -0
  43. data/spec/fixtures/spacex/landing_pads/info.yml +68 -0
  44. data/spec/fixtures/spacex/landing_pads/info/LZ-4.yml +70 -0
  45. data/spec/fixtures/spacex/launch_pads/info.yml +104 -0
  46. data/spec/fixtures/spacex/launch_pads/info/vafb_slc_4e.yml +71 -0
  47. data/spec/fixtures/spacex/launches.yml +62 -0
  48. data/spec/fixtures/spacex/launches/68.yml +69 -0
  49. data/spec/fixtures/spacex/launches/all.yml +62 -0
  50. data/spec/fixtures/spacex/launches/info.yml +62 -0
  51. data/spec/fixtures/spacex/launches/latest.yml +8 -8
  52. data/spec/fixtures/spacex/launches/next.yml +123 -0
  53. data/spec/fixtures/spacex/launches/past.yml +62 -0
  54. data/spec/fixtures/spacex/launches/upcoming.yml +64 -0
  55. data/spec/fixtures/spacex/missions/F3364BF.yml +157 -0
  56. data/spec/fixtures/spacex/missions/info.yml +62 -0
  57. data/spec/fixtures/spacex/payloads/RatSat.yml +62 -0
  58. data/spec/fixtures/spacex/payloads/info.yml +62 -0
  59. data/spec/fixtures/spacex/roadster/info.yml +133 -0
  60. data/spec/fixtures/spacex/rockets/info.yml +105 -0
  61. data/spec/fixtures/spacex/rockets/info/falcon1.yml +139 -0
  62. data/spec/fixtures/spacex/rockets/info/invalid.yml +61 -0
  63. data/spec/fixtures/spacex/ships/info.yml +139 -0
  64. data/spec/fixtures/spacex/ships/info/AMERICANCHAMPION.yml +125 -0
  65. data/spec/spacex/api_info_spec.rb +16 -0
  66. data/spec/spacex/capsules_spec.rb +38 -0
  67. data/spec/spacex/company_info_spec.rb +3 -5
  68. data/spec/spacex/cores_spec.rb +45 -0
  69. data/spec/spacex/dragon_capsules_spec.rb +107 -0
  70. data/spec/spacex/endpoint_spec.rb +9 -0
  71. data/spec/spacex/history_spec.rb +50 -0
  72. data/spec/spacex/landing_pads_spec.rb +72 -0
  73. data/spec/spacex/launch_pads_spec.rb +77 -0
  74. data/spec/spacex/launches_spec.rb +580 -16
  75. data/spec/spacex/missions_spec.rb +35 -0
  76. data/spec/spacex/payloads_spec.rb +62 -0
  77. data/spec/spacex/roadster_spec.rb +36 -0
  78. data/spec/spacex/rockets_spec.rb +210 -0
  79. data/spec/spacex/ships_spec.rb +65 -0
  80. data/spec/spacex/version_spec.rb +1 -3
  81. data/spec/spec_helper.rb +9 -0
  82. metadata +140 -23
@@ -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,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe SPACEX::LandingPads do
4
+ context '#info', vcr: { cassette_name: 'landing_pads/info' } do
5
+ subject do
6
+ SPACEX::LandingPads.info
7
+ end
8
+
9
+ it "returns all LandingPads' info when no id is passed" do
10
+ first_subject = subject.first
11
+
12
+ expect(subject.class).to eq Array
13
+ expect(first_subject.id).to eq 'LZ-1'
14
+ expect(first_subject.full_name).to eq 'Landing Zone 1'
15
+ expect(first_subject.status).to eq 'active'
16
+ expect(first_subject.location).to eq(
17
+ 'name' => 'Cape Canaveral',
18
+ 'region' => 'Florida',
19
+ 'latitude' => 28.485833,
20
+ 'longitude' => -80.544444
21
+ )
22
+ expect(first_subject.landing_type).to eq 'RTLS'
23
+ expect(first_subject.attempted_landings).to eq 14
24
+ expect(first_subject.successful_landings).to eq 13
25
+ expect(first_subject.wikipedia).to eq(
26
+ 'https://en.wikipedia.org/wiki/Landing_Zones_1_and_2'
27
+ )
28
+ expect(first_subject.details).to eq(
29
+ "SpaceX's first east coast landing pad is Landing Zone 1, " \
30
+ 'where the historic first Falcon 9 landing occurred in December 2015.' \
31
+ ' LC-13 was originally used as a launch pad for early Atlas missiles ' \
32
+ 'and rockets from Lockheed Martin. LC-1 was later expanded to ' \
33
+ 'include Landing Zone 2 for side booster RTLS Falcon Heavy missions, ' \
34
+ 'and it was first used in February 2018 for that purpose.'
35
+ )
36
+ end
37
+ end
38
+
39
+ context "#info('LZ-4')", vcr: { cassette_name: 'landing_pads/info/LZ-4' } do
40
+ subject do
41
+ SPACEX::LandingPads.info('LZ-4')
42
+ end
43
+
44
+ it 'returns LandingPad info for "LZ-4"' do
45
+ expect(subject.class).to eq SPACEX::Response
46
+ expect(subject.id).to eq 'LZ-4'
47
+ expect(subject.full_name).to eq 'Landing Zone 4'
48
+ expect(subject.status).to eq 'active'
49
+ expect(subject.location).to eq(
50
+ 'name' => 'Vandenberg Air Force Base',
51
+ 'region' => 'California',
52
+ 'latitude' => 34.632989,
53
+ 'longitude' => -120.615167
54
+ )
55
+ expect(subject.landing_type).to eq 'RTLS'
56
+ expect(subject.attempted_landings).to eq 2
57
+ expect(subject.successful_landings).to eq 2
58
+ expect(subject.wikipedia).to eq(
59
+ 'https://en.wikipedia.org/wiki/' \
60
+ 'Vandenberg_AFB_Space_Launch_Complex_4#LZ-4_landing_history'
61
+ )
62
+ expect(subject.details).to eq(
63
+ "SpaceX's west coast landing pad. The pad is adjacent to SLC-4E, " \
64
+ "SpaceX's west coast launch site. The pad was under construction for " \
65
+ 'about a year starting in 2016. ' \
66
+ 'After concerns with seal mating season, this pad was first used for ' \
67
+ 'the SAOCOM 1A mission in October 2018. ' \
68
+ 'Officially referred to as LZ-4 in FCC filings.'
69
+ )
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe SPACEX::LaunchPads do
4
+ context '#info', vcr: { cassette_name: 'launch_pads/info' } do
5
+ subject do
6
+ SPACEX::LaunchPads.info
7
+ end
8
+
9
+ it "returns all LaunchPads' info when no id is passed" do
10
+ first_subject = subject.first
11
+
12
+ expect(subject.class).to eq Array
13
+ expect(first_subject.id).to eq 5
14
+ expect(first_subject.name).to eq 'VAFB SLC 3W'
15
+ expect(first_subject.status).to eq 'retired'
16
+ expect(first_subject.location).to eq(
17
+ 'name' => 'Vandenberg Air Force Base',
18
+ 'region' => 'California',
19
+ 'latitude' => 34.6440904,
20
+ 'longitude' => -120.5931438
21
+ )
22
+ expect(first_subject.vehicles_launched).to eq [
23
+ 'Falcon 1'
24
+ ]
25
+ expect(first_subject.attempted_launches).to eq 0
26
+ expect(first_subject.successful_launches).to eq 0
27
+ expect(first_subject.wikipedia).to eq(
28
+ 'https://en.wikipedia.org/wiki/Vandenberg_AFB_Space_Launch_Complex_3'
29
+ )
30
+ expect(first_subject.details).to eq 'SpaceX original ' \
31
+ 'west coast launch pad for Falcon 1. Performed a static fire but was ' \
32
+ 'never used for a launch and abandoned due to scheduling conflicts.'
33
+ expect(first_subject.site_id).to eq 'vafb_slc_3w'
34
+ expect(first_subject.site_name_long).to eq(
35
+ 'Vandenberg Air Force Base Space Launch Complex 3W'
36
+ )
37
+ end
38
+ end
39
+
40
+ context "#info('vafb_slc_4e')", vcr: {
41
+ cassette_name: 'launch_pads/info/vafb_slc_4e'
42
+ } do
43
+ subject do
44
+ SPACEX::LaunchPads.info('vafb_slc_4e')
45
+ end
46
+
47
+ it 'returns LaunchPad info for "vafb_slc_4e"' do
48
+ expect(subject.class).to eq SPACEX::Response
49
+ expect(subject.id).to eq 6
50
+ expect(subject.name).to eq 'VAFB SLC 4E'
51
+ expect(subject.status).to eq 'active'
52
+ expect(subject.location).to eq(
53
+ 'name' => 'Vandenberg Air Force Base',
54
+ 'region' => 'California',
55
+ 'latitude' => 34.632093,
56
+ 'longitude' => -120.610829
57
+ )
58
+ expect(subject.vehicles_launched).to eq [
59
+ 'Falcon 9'
60
+ ]
61
+ expect(subject.attempted_launches).to eq 15
62
+ expect(subject.successful_launches).to eq 15
63
+ expect(subject.wikipedia).to eq(
64
+ 'https://en.wikipedia.org/wiki/Vandenberg_AFB_Space_Launch_Complex_4'
65
+ )
66
+
67
+ expect(subject.details).to eq 'SpaceX primary ' \
68
+ 'west coast launch pad for polar orbits and sun synchronous orbits, ' \
69
+ 'primarily used for Iridium. Also intended to be capable of ' \
70
+ 'launching Falcon Heavy.'
71
+ expect(subject.site_id).to eq 'vafb_slc_4e'
72
+ expect(subject.site_name_long).to eq(
73
+ 'Vandenberg Air Force Base Space Launch Complex 4E'
74
+ )
75
+ end
76
+ end
77
+ end
@@ -1,12 +1,11 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'spec_helper'
4
2
 
5
- describe SPACEX do
6
- context 'Launches', vcr: { cassette_name: 'launches/latest' } do
3
+ describe SPACEX::Launches do
4
+ context '#latest', vcr: { cassette_name: 'launches/latest' } do
7
5
  subject do
8
6
  SPACEX::Launches.latest
9
7
  end
8
+
10
9
  it 'returns latest launch' do
11
10
  expect(subject.flight_number).to eq 67
12
11
  expect(subject.mission_name).to eq 'Merah Putih'
@@ -15,11 +14,9 @@ describe SPACEX do
15
14
  expect(subject.launch_date_utc).to eq '2018-08-07T05:18:00.000Z'
16
15
  expect(subject.launch_date_local).to eq '2018-08-07T01:18:00-04:00'
17
16
  expect(subject.launch_success).to eq true
18
-
19
17
  expect(subject.rocket.rocket_id).to eq 'falcon9'
20
18
  expect(subject.rocket.rocket_name).to eq 'Falcon 9'
21
19
  expect(subject.rocket.rocket_type).to eq 'FT'
22
-
23
20
  expect(subject.rocket.first_stage.cores.first.core_serial).to eq 'B1046'
24
21
  expect(subject.rocket.first_stage.cores.first.flight).to eq 2
25
22
  expect(subject.rocket.first_stage.cores.first.block).to eq 5
@@ -27,9 +24,7 @@ describe SPACEX do
27
24
  expect(subject.rocket.first_stage.cores.first.land_success).to eq true
28
25
  expect(subject.rocket.first_stage.cores.first.landing_type).to eq 'ASDS'
29
26
  expect(subject.rocket.first_stage.cores.first.landing_vehicle).to eq 'OCISLY'
30
-
31
27
  expect(subject.rocket.second_stage.block).to eq 5
32
-
33
28
  expect(subject.rocket.second_stage.payloads.first.payload_id).to eq 'Telkom-4'
34
29
  expect(subject.rocket.second_stage.payloads.first.norad_id.first).to eq 43_587
35
30
  expect(subject.rocket.second_stage.payloads.first.reused).to eq false
@@ -40,10 +35,8 @@ describe SPACEX do
40
35
  expect(subject.rocket.second_stage.payloads.first.payload_mass_kg).to eq 5800
41
36
  expect(subject.rocket.second_stage.payloads.first.payload_mass_lbs).to eq 12_786.81
42
37
  expect(subject.rocket.second_stage.payloads.first.orbit).to eq 'GTO'
43
-
44
- expect(subject.rocket.second_stage.payloads.first.orbit_params.reference_system).to eq 'geocentric'
45
38
  expect(subject.rocket.second_stage.payloads.first.orbit_params.regime).to eq 'geostationary'
46
- expect(subject.rocket.second_stage.payloads.first.orbit_params.longitude).to eq -108
39
+ expect(subject.rocket.second_stage.payloads.first.orbit_params.longitude).to eq '-108'.to_i
47
40
  expect(subject.rocket.second_stage.payloads.first.orbit_params.semi_major_axis_km).to eq 21_226.178
48
41
  expect(subject.rocket.second_stage.payloads.first.orbit_params.eccentricity).to eq 0.6904141
49
42
  expect(subject.rocket.second_stage.payloads.first.orbit_params.periapsis_km).to eq 193.19
@@ -54,20 +47,16 @@ describe SPACEX do
54
47
  expect(subject.rocket.second_stage.payloads.first.orbit_params.epoch).to eq '2018-08-07T06:57:16.000Z'
55
48
  expect(subject.rocket.second_stage.payloads.first.orbit_params.mean_motion).to eq 2.80734018
56
49
  expect(subject.rocket.second_stage.payloads.first.orbit_params.raan).to eq 227.0228
57
-
58
50
  expect(subject.telemetry.flight_club).to eq nil
59
51
  expect(subject.reuse.core).to eq true
60
52
  expect(subject.reuse.sire_core1).to eq nil
61
53
  expect(subject.reuse.side_core2).to eq false
62
54
  expect(subject.reuse.fairings).to eq false
63
55
  expect(subject.reuse.capsule).to eq false
64
-
65
56
  expect(subject.launch_site.site_id).to eq 'ccafs_slc_40'
66
57
  expect(subject.launch_site.site_name).to eq 'CCAFS SLC 40'
67
58
  expect(subject.launch_site.site_name_long).to eq 'Cape Canaveral Air Force Station Space Launch Complex 40'
68
-
69
59
  expect(subject.launch_success).to eq true
70
-
71
60
  expect(subject.links.mission_patch).to eq 'https://images2.imgbox.com/a8/f5/ZgdsrbqW_o.png'
72
61
  expect(subject.links.mision_patch_small).to eq nil
73
62
  expect(subject.links.reddit_campaign).to eq 'https://www.reddit.com/r/spacex/comments/91gwfg/merah_putih_telkom4_launch_campaign_thread/'
@@ -78,10 +67,585 @@ describe SPACEX do
78
67
  expect(subject.links.article_link).to eq 'https://spaceflightnow.com/2018/08/07/indonesian-communications-satellite-deployed-in-orbit-by-spacex/'
79
68
  expect(subject.links.wikipedia).to eq 'https://en.wikipedia.org/wiki/Telkom_Indonesia'
80
69
  expect(subject.links.video_link).to eq 'https://www.youtube.com/watch?v=FjfQNBYv2IY'
81
-
82
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.'
83
71
  expect(subject.upcoming).to eq false
84
72
  expect(subject.static_fire_date_utc).to eq '2018-08-02T15:53:00.000Z'
85
73
  end
86
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_i).to be >= 2018
410
+ expect(launch.rocket.first_stage.cores.first.land_success).to be nil
411
+ expect(launch.launch_success).to be nil
412
+ end
413
+ end
414
+
415
+ context 'returns upcoming launches' do
416
+ it 'returns the next upcoming launch' do
417
+ expect(subject.first.flight_number).to eq 70
418
+ expect(subject.first.mission_name).to eq 'Es’hail 2'
419
+ expect(subject.first.mission_id).to eq []
420
+ expect(subject.first.launch_year).to eq '2018'
421
+ expect(subject.first.launch_date_unix).to eq 1_542_228_360
422
+ expect(subject.first.launch_date_utc).to eq '2018-11-14T20:46:00.000Z'
423
+ expect(subject.first.launch_date_local).to eq '2018-11-14T15:46:00-05:00'
424
+ expect(subject.first.is_tentative).to eq true
425
+ expect(subject.first.tentative_max_precision).to eq 'hour'
426
+ expect(subject.first.rocket.rocket_id).to eq 'falcon9'
427
+ expect(subject.first.rocket.rocket_name).to eq 'Falcon 9'
428
+ expect(subject.first.rocket.rocket_type).to eq 'FT'
429
+ expect(subject.first.rocket.first_stage.cores).to be_an(Array)
430
+ expect(subject.first.rocket.first_stage.cores.first).to eq(
431
+ 'core_serial' => nil,
432
+ 'flight' => nil,
433
+ 'block' => 5,
434
+ 'gridfins' => true,
435
+ 'legs' => true,
436
+ 'reused' => false,
437
+ 'land_success' => nil,
438
+ 'landing_intent' => true,
439
+ 'landing_type' => 'ASDS',
440
+ 'landing_vehicle' => 'OCISLY'
441
+ )
442
+ expect(subject.first.rocket.second_stage.block).to eq 5
443
+ expect(subject.first.rocket.second_stage.payloads).to be_an(Array)
444
+ expect(subject.first.rocket.second_stage.payloads.first).to eq(
445
+ 'payload_id' => 'Es’hail 2',
446
+ 'norad_id' => [],
447
+ 'reused' => false,
448
+ 'customers' => ['Es’hailSat'],
449
+ 'nationality' => 'Qatar',
450
+ 'manufacturer' => 'Mitsubishi Electric',
451
+ 'payload_type' => 'Satellite',
452
+ 'payload_mass_kg' => 3000,
453
+ 'payload_mass_lbs' => 6613.868,
454
+ 'orbit' => 'GTO',
455
+ 'orbit_params' => {
456
+ 'reference_system' => 'geocentric',
457
+ 'regime' => 'geostationary',
458
+ 'longitude' => 25.5,
459
+ 'semi_major_axis_km' => nil,
460
+ 'eccentricity' => nil,
461
+ 'periapsis_km' => nil,
462
+ 'apoapsis_km' => nil,
463
+ 'inclination_deg' => nil,
464
+ 'period_min' => nil,
465
+ 'lifespan_years' => 15,
466
+ 'epoch' => nil,
467
+ 'mean_motion' => nil,
468
+ 'raan' => nil,
469
+ 'arg_of_pericenter' => nil,
470
+ 'mean_anomaly' => nil
471
+ }
472
+ )
473
+ expect(subject.first.rocket.fairings).to eq(
474
+ 'reused' => false,
475
+ 'recovery_attempt' => false,
476
+ 'recovered' => false,
477
+ 'ship' => nil
478
+ )
479
+ expect(subject.first.ships).to eq []
480
+ expect(subject.first.telemetry.flight_club).to eq nil
481
+ expect(subject.first.launch_site).to eq(
482
+ 'site_id' => 'ccafs_slc_40',
483
+ 'site_name' => 'CCAFS SLC 40',
484
+ 'site_name_long' => 'Cape Canaveral Air Force Station Space Launch Complex 40'
485
+ )
486
+ expect(subject.first.launch_success).to eq nil
487
+ expect(subject.first.links).to eq(
488
+ 'mission_patch' => nil,
489
+ 'mission_patch_small' => nil,
490
+ 'reddit_campaign' => 'https://www.reddit.com/r/spacex/comments/9p82jt/eshail_2_launch_campaign_thread/',
491
+ 'reddit_launch' => nil,
492
+ 'reddit_recovery' => nil,
493
+ 'reddit_media' => nil,
494
+ 'presskit' => nil,
495
+ 'article_link' => nil,
496
+ 'wikipedia' => nil,
497
+ 'video_link' => nil,
498
+ 'flickr_images' => []
499
+ )
500
+ expect(subject.first.details).to eq 'SpaceX\'s eighteenth flight of 2018 will '\
501
+ 'be its first for Es\'hailSat. Es\'hail-2 is a communications satellite '\
502
+ 'that will deliver television and internet to Qatar and the surrounding '\
503
+ 'region. It will be launched into a geostationary transfer orbit from '\
504
+ 'LC-39A at Kennedy Space Center. The booster is expected to land on OCISLY.'
505
+ expect(subject.first.upcoming).to eq true
506
+ expect(subject.first.static_fire_date_utc).to eq nil
507
+ expect(subject.first.static_fire_date_unix).to eq nil
508
+ end
509
+
510
+ it 'returns the last upcoming launch' do
511
+ expect(subject.last.flight_number).to eq 91
512
+ expect(subject.last.mission_name).to eq 'GPS IIIA-3'
513
+ expect(subject.last.mission_id).to eq []
514
+ expect(subject.last.launch_year).to eq '2019'
515
+ expect(subject.last.launch_date_unix).to eq 1_569_888_000
516
+ expect(subject.last.launch_date_utc).to eq '2019-10-01T00:00:00.000Z'
517
+ expect(subject.last.launch_date_local).to eq '2019-09-30T20:00:00-04:00'
518
+ expect(subject.last.is_tentative).to eq true
519
+ expect(subject.last.tentative_max_precision).to eq 'month'
520
+ expect(subject.last.rocket.rocket_id).to eq 'falcon9'
521
+ expect(subject.last.rocket.rocket_name).to eq 'Falcon 9'
522
+ expect(subject.last.rocket.rocket_type).to eq 'FT'
523
+ expect(subject.last.rocket.first_stage.cores).to be_an(Array)
524
+ expect(subject.last.rocket.first_stage.cores.first).to eq(
525
+ 'core_serial' => nil,
526
+ 'flight' => nil,
527
+ 'block' => nil,
528
+ 'gridfins' => nil,
529
+ 'legs' => nil,
530
+ 'reused' => false,
531
+ 'land_success' => nil,
532
+ 'landing_intent' => nil,
533
+ 'landing_type' => nil,
534
+ 'landing_vehicle' => nil
535
+ )
536
+ expect(subject.last.rocket.second_stage.block).to eq nil
537
+ expect(subject.last.rocket.second_stage.payloads).to be_an(Array)
538
+ expect(subject.last.rocket.second_stage.payloads.first).to eq(
539
+ 'payload_id' => 'GPS IIIA-3',
540
+ 'norad_id' => [],
541
+ 'reused' => false,
542
+ 'customers' => ['USAF'],
543
+ 'nationality' => 'United States',
544
+ 'manufacturer' => 'Lockheed Martin',
545
+ 'payload_type' => 'Satellite',
546
+ 'payload_mass_kg' => 3880,
547
+ 'payload_mass_lbs' => 8553.94,
548
+ 'orbit' => 'MEO',
549
+ 'orbit_params' => {
550
+ 'reference_system' => nil,
551
+ 'regime' => nil,
552
+ 'longitude' => nil,
553
+ 'semi_major_axis_km' => nil,
554
+ 'eccentricity' => nil,
555
+ 'periapsis_km' => nil,
556
+ 'apoapsis_km' => nil,
557
+ 'inclination_deg' => nil,
558
+ 'period_min' => nil,
559
+ 'lifespan_years' => 15,
560
+ 'epoch' => nil,
561
+ 'mean_motion' => nil,
562
+ 'raan' => nil,
563
+ 'arg_of_pericenter' => nil,
564
+ 'mean_anomaly' => nil
565
+ }
566
+ )
567
+ expect(subject.last.rocket.fairings).to eq(
568
+ 'reused' => false,
569
+ 'recovery_attempt' => nil,
570
+ 'recovered' => nil,
571
+ 'ship' => nil
572
+ )
573
+ expect(subject.last.ships).to eq []
574
+ expect(subject.last.telemetry.flight_club).to eq nil
575
+ expect(subject.last.launch_site).to eq(
576
+ 'site_id' => 'ccafs_slc_40',
577
+ 'site_name' => 'CCAFS SLC 40',
578
+ 'site_name_long' => 'Cape Canaveral Air Force Station Space Launch Complex 40'
579
+ )
580
+ expect(subject.last.launch_success).to eq nil
581
+ expect(subject.last.links).to eq(
582
+ 'mission_patch' => nil,
583
+ 'mission_patch_small' => nil,
584
+ 'reddit_campaign' => nil,
585
+ 'reddit_launch' => nil,
586
+ 'reddit_recovery' => nil,
587
+ 'reddit_media' => nil,
588
+ 'presskit' => nil,
589
+ 'article_link' => nil,
590
+ 'wikipedia' => nil,
591
+ 'video_link' => nil,
592
+ 'flickr_images' => []
593
+ )
594
+ expect(subject.last.details).to eq nil
595
+ expect(subject.last.upcoming).to eq true
596
+ expect(subject.last.static_fire_date_utc).to eq nil
597
+ expect(subject.last.static_fire_date_unix).to eq nil
598
+ end
599
+ end
600
+ end
601
+
602
+ context '#all', vcr: { cassette_name: 'launches/all' } do
603
+ subject do
604
+ SPACEX::Launches.all
605
+ end
606
+
607
+ it 'returns all launches' do
608
+ expect(subject.first.flight_number).to eq 1
609
+ expect(subject.first.mission_name).to eq 'FalconSat'
610
+ end
611
+ end
612
+
613
+ context '#past', vcr: { cassette_name: 'launches/past' } do
614
+ subject do
615
+ SPACEX::Launches.past
616
+ end
617
+
618
+ it 'returns and array of launch hashes' do
619
+ expect(subject).to be_an Array
620
+ expect(subject.first).to be_a Hash
621
+ end
622
+
623
+ it 'returns the correct number of launches' do
624
+ expect(subject.count).to eq 69
625
+ end
626
+
627
+ context 'returns past launches' do
628
+ it 'returns the first launch' do
629
+ expect(subject.first.flight_number).to eq(1)
630
+ expect(subject.first.mission_name).to eq('FalconSat')
631
+ expect(subject.first.rocket.rocket_name).to eq('Falcon 1')
632
+ expect(subject.first.rocket.first_stage.cores.first.core_serial).to eq('Merlin1A')
633
+ expect(subject.first.rocket.second_stage.payloads.first.payload_id).to eq('FalconSAT-2')
634
+ expect(subject.first.rocket.second_stage.payloads.first.orbit_params.regime).to eq('low-earth')
635
+ expect(subject.first.launch_site.site_id).to eq('kwajalein_atoll')
636
+ expect(subject.first.launch_success).to eq(false)
637
+ end
638
+
639
+ it 'returns the last past launch' do
640
+ expect(subject.last.flight_number).to eq(69)
641
+ expect(subject.last.mission_name).to eq('SAOCOM 1A')
642
+ expect(subject.last.rocket.rocket_name).to eq('Falcon 9')
643
+ expect(subject.last.rocket.first_stage.cores.first.core_serial).to eq('B1048')
644
+ expect(subject.last.rocket.second_stage.payloads.first.payload_id).to eq('SAOCOM 1A')
645
+ expect(subject.last.rocket.second_stage.payloads.first.orbit_params.regime).to eq('sun-synchronous')
646
+ expect(subject.last.launch_site.site_id).to eq('vafb_slc_4e')
647
+ expect(subject.last.launch_success).to eq(true)
648
+ end
649
+ end
650
+ end
87
651
  end