Skip to content

Commit

Permalink
Add a history endpoint
Browse files Browse the repository at this point in the history
This is a very basic history endpoint as described in the issue #39

This doesn't support all the filters that are described in the
documentation provided here
https://documenter.getpostman.com/view/2025350/RWaEzAiG#9f1dfdc0-fbe8-4ae5-9209-7f3d649a627c
but it does support the basic functionality of retrieving all the
historical events or a specific historical event by passing an id
  • Loading branch information
invacuo committed Oct 16, 2018
1 parent d82752a commit 163aa69
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/spacex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
require 'hashie'

require_relative 'spacex/base_request'
require_relative 'spacex/version'
require_relative 'spacex/launches'
require_relative 'spacex/capsules'
require_relative 'spacex/company_info'
require_relative 'spacex/roadster'
require_relative 'spacex/cores'
require_relative 'spacex/dragon_capsules'
require_relative 'spacex/ships'
require_relative 'spacex/history'
require_relative 'spacex/launches'
require_relative 'spacex/missions'
require_relative 'spacex/roadster'
require_relative 'spacex/rockets'
require_relative 'spacex/capsules'
require_relative 'spacex/cores'
require_relative 'spacex/ships'
require_relative 'spacex/version'
7 changes: 7 additions & 0 deletions lib/spacex/history.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module SPACEX
module History
def self.info(id = nil)
SPACEX::BaseRequest.info("history/#{id}")
end
end
end
62 changes: 62 additions & 0 deletions spec/fixtures/spacex/history/info.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions spec/fixtures/spacex/history/info/4.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions spec/spacex/history_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
require 'spec_helper'

describe SPACEX::History do
context '#info', vcr: { cassette_name: 'history/info' } do
subject do
SPACEX::History.info
end

it 'returns all historical events when no id is passed' do
first_subject = subject.first
expect(first_subject.id).to eq 1
expect(first_subject.title).to eq 'Falcon 1 Makes History'
expect(first_subject.event_date_utc).to eq '2008-09-28T23:15:00Z'
expect(first_subject.event_date_unix).to eq 1_222_643_700
expect(first_subject.flight_number).to eq 4
expect(first_subject.details).to eq(
'Falcon 1 becomes the first privately '\
'developed liquid fuel rocket to reach Earth orbit.'
)
expect(first_subject.links).to eq(
'reddit' => nil,
'article' => 'http://www.spacex.com/news/2013/02/11/flight-4-launch-update-0',
'wikipedia' => 'https://en.wikipedia.org/wiki/Falcon_1'
)
end
end

context "#info('4')", vcr: { cassette_name: 'history/info/4' } do
subject do
SPACEX::History.info(4)
end

it 'returns Historical event info for event id 4' do
expect(subject.id).to eq 4
expect(subject.title).to eq 'Falcon 9 First Flight'
expect(subject.event_date_utc).to eq '2010-06-04T18:45:00Z'
expect(subject.event_date_unix).to eq 1_275_677_100
expect(subject.flight_number).to eq 6
expect(subject.details).to eq(
'Met 100% of mission objectives on the first flight!'
)
expect(subject.links).to eq(
'reddit' => nil,
'article' => 'http://www.bbc.com/news/10209704',
'wikipedia' =>
'https://en.wikipedia.org/wiki/Dragon_Spacecraft_Qualification_Unit'
)
end
end
end

0 comments on commit 163aa69

Please sign in to comment.