starwars 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +26 -0
- data/Gemfile +17 -0
- data/Guardfile +16 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +27 -0
- data/lib/starwars.rb +19 -0
- data/lib/starwars/base.rb +54 -0
- data/lib/starwars/fetcher.rb +40 -0
- data/lib/starwars/film.rb +35 -0
- data/lib/starwars/person.rb +39 -0
- data/lib/starwars/planet.rb +37 -0
- data/lib/starwars/specie.rb +38 -0
- data/lib/starwars/starship.rb +40 -0
- data/lib/starwars/vehicle.rb +38 -0
- data/lib/starwars/version.rb +4 -0
- data/spec/fixtures/films_1.json +1 -0
- data/spec/fixtures/people_1.json +1 -0
- data/spec/fixtures/people_2.json +1 -0
- data/spec/fixtures/planets_1.json +1 -0
- data/spec/fixtures/species_1.json +1 -0
- data/spec/fixtures/starships_10.json +1 -0
- data/spec/fixtures/starships_5.json +1 -0
- data/spec/fixtures/vehicles_14.json +1 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/starwars/film_spec.rb +132 -0
- data/spec/starwars/person_spec.rb +150 -0
- data/spec/starwars/planet_spec.rb +128 -0
- data/spec/starwars/species_spec.rb +125 -0
- data/spec/starwars/starship_spec.rb +144 -0
- data/spec/starwars/vehicle_spec.rb +130 -0
- data/starwars.gemspec +26 -0
- metadata +166 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
module Starwars
|
2
|
+
#
|
3
|
+
# A Film resource is an single film.
|
4
|
+
#
|
5
|
+
class Specie < Starwars::Base
|
6
|
+
#
|
7
|
+
# Define the source name in the starwars api
|
8
|
+
#
|
9
|
+
RESOURCE_NAME = 'species'
|
10
|
+
|
11
|
+
include Starwars::Fetcher
|
12
|
+
|
13
|
+
# @return [String]
|
14
|
+
property :name
|
15
|
+
property :classification
|
16
|
+
property :designation
|
17
|
+
property :skin_colors
|
18
|
+
property :hair_colors
|
19
|
+
property :eye_colors
|
20
|
+
property :language
|
21
|
+
property :url
|
22
|
+
|
23
|
+
# @return [Starwars::Planet]
|
24
|
+
property :homeworld, class: Starwars::Planet, deserialize: ->(_, fragment, _) { Planet.new(url: fragment) }
|
25
|
+
|
26
|
+
# @return [Integer]
|
27
|
+
property :average_height, type: Integer
|
28
|
+
property :average_lifespan, type: Integer
|
29
|
+
|
30
|
+
# @return [Time]
|
31
|
+
property :created, type: Time
|
32
|
+
property :edited, type: Time
|
33
|
+
|
34
|
+
# @return [Array]
|
35
|
+
collection :people, class: Starwars::Person, deserialize: ->(_, fragment, _) { Person.new(url: fragment) }
|
36
|
+
collection :films, class: Starwars::Film, deserialize: ->(_, fragment, _) { Film.new(url: fragment) }
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Starwars
|
2
|
+
#
|
3
|
+
# A Film resource is an single film.
|
4
|
+
#
|
5
|
+
class Starship < Starwars::Base
|
6
|
+
#
|
7
|
+
# Define the source name in the starwars api
|
8
|
+
#
|
9
|
+
RESOURCE_NAME = 'starships'
|
10
|
+
|
11
|
+
include Starwars::Fetcher
|
12
|
+
|
13
|
+
# @return [String]
|
14
|
+
property :name
|
15
|
+
property :model
|
16
|
+
property :manufacturer
|
17
|
+
property :starship_class
|
18
|
+
property :consumables
|
19
|
+
|
20
|
+
# @return [Integer]
|
21
|
+
property :cost_in_credits, type: Integer
|
22
|
+
property :length, type: Integer
|
23
|
+
property :max_atmosphering_speed, type: Integer
|
24
|
+
property :crew, type: Integer
|
25
|
+
property :passengers, type: Integer
|
26
|
+
property :cargo_capacity, type: Integer
|
27
|
+
# property :MGLT, as: :mglt
|
28
|
+
|
29
|
+
# @return [Float]
|
30
|
+
property :hyperdrive_rating, type: Float
|
31
|
+
|
32
|
+
# @return [Time]
|
33
|
+
property :created, type: Time
|
34
|
+
property :edited, type: Time
|
35
|
+
|
36
|
+
# @return [Array]
|
37
|
+
collection :pilots, class: Starwars::Person, deserialize: ->(_, fragment, _) { Person.new(url: fragment) }
|
38
|
+
collection :films, class: Starwars::Film, deserialize: ->(_, fragment, _) { Film.new(url: fragment) }
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Starwars
|
2
|
+
#
|
3
|
+
# A Film resource is an single film.
|
4
|
+
#
|
5
|
+
class Vehicle < Starwars::Base
|
6
|
+
#
|
7
|
+
# Define the source name in the starwars api
|
8
|
+
#
|
9
|
+
RESOURCE_NAME = 'vehicles'
|
10
|
+
|
11
|
+
include Starwars::Fetcher
|
12
|
+
|
13
|
+
# @return [String]
|
14
|
+
property :name
|
15
|
+
property :model
|
16
|
+
property :manufacturer
|
17
|
+
property :consumables
|
18
|
+
property :vehicle_class
|
19
|
+
property :cost_in_credits
|
20
|
+
|
21
|
+
# @return [Integer]
|
22
|
+
property :max_atmosphering_speed, type: Integer
|
23
|
+
property :crew, type: Integer
|
24
|
+
property :passengers, type: Integer
|
25
|
+
property :cargo_capacity, type: Integer
|
26
|
+
|
27
|
+
# @return [Float]
|
28
|
+
property :length, type: Float
|
29
|
+
|
30
|
+
# @return [Time]
|
31
|
+
property :created, type: Time
|
32
|
+
property :edited, type: Time
|
33
|
+
|
34
|
+
# @return [Array]
|
35
|
+
collection :pilots, class: Starwars::Person, deserialize: ->(_, fragment, _) { Person.new(url: fragment) }
|
36
|
+
collection :films, class: Starwars::Film, deserialize: ->(_, fragment, _) { Film.new(url: fragment) }
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"title":"A New Hope","episode_id":4,"opening_crawl":"It is a period of civil war.\r\nRebel spaceships, striking\r\nfrom a hidden base, have won\r\ntheir first victory against\r\nthe evil Galactic Empire.\r\n\r\nDuring the battle, Rebel\r\nspies managed to steal secret\r\nplans to the Empire's\r\nultimate weapon, the DEATH\r\nSTAR, an armored space\r\nstation with enough power\r\nto destroy an entire planet.\r\n\r\nPursued by the Empire's\r\nsinister agents, Princess\r\nLeia races home aboard her\r\nstarship, custodian of the\r\nstolen plans that can save her\r\npeople and restore\r\nfreedom to the galaxy....","director":"George Lucas","producer":"Gary Kurtz, Rick McCallum","characters":["http://swapi.co/api/people/1/","http://swapi.co/api/people/2/","http://swapi.co/api/people/3/","http://swapi.co/api/people/4/","http://swapi.co/api/people/5/","http://swapi.co/api/people/6/","http://swapi.co/api/people/7/","http://swapi.co/api/people/8/","http://swapi.co/api/people/9/","http://swapi.co/api/people/10/","http://swapi.co/api/people/12/","http://swapi.co/api/people/13/","http://swapi.co/api/people/14/","http://swapi.co/api/people/15/","http://swapi.co/api/people/16/","http://swapi.co/api/people/18/","http://swapi.co/api/people/19/","http://swapi.co/api/people/81/"],"planets":["http://swapi.co/api/planets/2/","http://swapi.co/api/planets/3/","http://swapi.co/api/planets/1/"],"starships":["http://swapi.co/api/starships/2/","http://swapi.co/api/starships/3/","http://swapi.co/api/starships/5/","http://swapi.co/api/starships/9/","http://swapi.co/api/starships/10/","http://swapi.co/api/starships/11/","http://swapi.co/api/starships/12/","http://swapi.co/api/starships/13/"],"vehicles":["http://swapi.co/api/vehicles/4/","http://swapi.co/api/vehicles/6/","http://swapi.co/api/vehicles/7/","http://swapi.co/api/vehicles/8/"],"species":["http://swapi.co/api/species/1/","http://swapi.co/api/species/2/","http://swapi.co/api/species/3/","http://swapi.co/api/species/4/","http://swapi.co/api/species/5/"],"created":"2014-12-10T14:23:31.880000Z","edited":"2014-12-20T19:49:45.256000Z","url":"http://swapi.co/api/films/1/"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"name":"Luke Skywalker","height":"172","mass":"77","hair_color":"blond","skin_color":"fair","eye_color":"blue","birth_year":"19BBY","gender":"male","homeworld":"http://swapi.co/api/planets/1/","films":["http://swapi.co/api/films/1/","http://swapi.co/api/films/2/","http://swapi.co/api/films/3/","http://swapi.co/api/films/6/"],"species":[],"vehicles":["http://swapi.co/api/vehicles/14/","http://swapi.co/api/vehicles/30/"],"starships":["http://swapi.co/api/starships/12/","http://swapi.co/api/starships/22/"],"created":"2014-12-09T13:50:51.644000Z","edited":"2014-12-20T21:17:56.891000Z","url":"http://swapi.co/api/people/1/"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"name":"C-3PO","height":"167","mass":"75","hair_color":"n/a","skin_color":"gold","eye_color":"yellow","birth_year":"112BBY","gender":"n/a","homeworld":"http://swapi.co/api/planets/1/","films":["http://swapi.co/api/films/1/","http://swapi.co/api/films/2/","http://swapi.co/api/films/3/","http://swapi.co/api/films/4/","http://swapi.co/api/films/5/","http://swapi.co/api/films/6/"],"species":["http://swapi.co/api/species/2/"],"vehicles":[],"starships":[],"created":"2014-12-10T15:10:51.357000Z","edited":"2014-12-20T21:17:50.309000Z","url":"http://swapi.co/api/people/2/"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"name":"Tatooine","rotation_period":"23","orbital_period":"304","diameter":"10465","climate":"arid","gravity":"1 standard","terrain":"desert","surface_water":"1","population":"200000","residents":["http://swapi.co/api/people/1/","http://swapi.co/api/people/2/","http://swapi.co/api/people/4/","http://swapi.co/api/people/6/","http://swapi.co/api/people/7/","http://swapi.co/api/people/8/","http://swapi.co/api/people/9/","http://swapi.co/api/people/11/","http://swapi.co/api/people/43/","http://swapi.co/api/people/62/"],"films":["http://swapi.co/api/films/1/","http://swapi.co/api/films/3/","http://swapi.co/api/films/4/","http://swapi.co/api/films/5/","http://swapi.co/api/films/6/"],"created":"2014-12-09T13:50:49.641000Z","edited":"2014-12-21T20:48:04.175778Z","url":"http://swapi.co/api/planets/1/"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"name":"Human","classification":"mammal","designation":"sentient","average_height":"180","skin_colors":"caucasian, black, asian, hispanic","hair_colors":"blonde, brown, black, red","eye_colors":"brown, blue, green, hazel, grey, amber","average_lifespan":"120","homeworld":"http://swapi.co/api/planets/9/","language":"Galactic Basic","people":["http://swapi.co/api/people/66/","http://swapi.co/api/people/67/","http://swapi.co/api/people/68/","http://swapi.co/api/people/74/"],"films":["http://swapi.co/api/films/1/","http://swapi.co/api/films/2/","http://swapi.co/api/films/3/","http://swapi.co/api/films/4/","http://swapi.co/api/films/5/","http://swapi.co/api/films/6/"],"created":"2014-12-10T13:52:11.567000Z","edited":"2014-12-20T21:36:42.136000Z","url":"http://swapi.co/api/species/1/"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"name":"Millennium Falcon","model":"YT-1300 light freighter","manufacturer":"Corellian Engineering Corporation","cost_in_credits":"100000","length":"34.37","max_atmosphering_speed":"1050","crew":"4","passengers":"6","cargo_capacity":"100000","consumables":"2 months","hyperdrive_rating":"0.5","MGLT":"75","starship_class":"Light freighter","pilots":["http://swapi.co/api/people/13/","http://swapi.co/api/people/14/","http://swapi.co/api/people/25/","http://swapi.co/api/people/31/"],"films":["http://swapi.co/api/films/1/","http://swapi.co/api/films/2/","http://swapi.co/api/films/3/"],"created":"2014-12-10T16:59:45.094000Z","edited":"2014-12-22T17:35:44.464156Z","url":"http://swapi.co/api/starships/10/"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"name":"Sentinel-class landing craft","model":"Sentinel-class landing craft","manufacturer":"Sienar Fleet Systems, Cyngus Spaceworks","cost_in_credits":"240000","length":"38","max_atmosphering_speed":"1000","crew":"5","passengers":"75","cargo_capacity":"180000","consumables":"1 month","hyperdrive_rating":"1.0","MGLT":"70","starship_class":"landing craft","pilots":[],"films":["http://swapi.co/api/films/1/"],"created":"2014-12-10T15:48:00.586000Z","edited":"2014-12-22T17:35:44.431407Z","url":"http://swapi.co/api/starships/5/"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"name":"Snowspeeder","model":"t-47 airspeeder","manufacturer":"Incom corporation","cost_in_credits":"unknown","length":"4.5","max_atmosphering_speed":"650","crew":"2","passengers":"0","cargo_capacity":"10","consumables":"none","vehicle_class":"airspeeder","pilots":["http://swapi.co/api/people/1/","http://swapi.co/api/people/18/"],"films":["http://swapi.co/api/films/2/"],"created":"2014-12-15T12:22:12Z","edited":"2014-12-22T18:21:15.623033Z","url":"http://swapi.co/api/vehicles/14/"}
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
|
4
|
+
SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
|
5
|
+
SimpleCov.start do
|
6
|
+
add_filter '/spec/'
|
7
|
+
minimum_coverage(90)
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'starwars'
|
11
|
+
require 'rspec'
|
12
|
+
require 'webmock/rspec'
|
13
|
+
|
14
|
+
WebMock.disable_net_connect!(allow: 'coveralls.io')
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.expect_with :rspec do |expectations|
|
18
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
19
|
+
expectations.syntax = :expect
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def a_get(path)
|
24
|
+
a_request(:get, Starwars::Base::BASE_URL + path)
|
25
|
+
end
|
26
|
+
|
27
|
+
def stub_get(path)
|
28
|
+
stub_request(:get, Starwars::Base::BASE_URL + path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def fixture_path
|
32
|
+
File.expand_path('../fixtures', __FILE__)
|
33
|
+
end
|
34
|
+
|
35
|
+
def fixture(file)
|
36
|
+
File.new(fixture_path + '/' + file)
|
37
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
describe Starwars::Film do
|
2
|
+
before do
|
3
|
+
stub_get('/films/1/').to_return(body: fixture('films_1.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
4
|
+
end
|
5
|
+
describe '#==' do
|
6
|
+
it 'returns true when objects IDs and URLS are the same' do
|
7
|
+
planet = Starwars::Film.new(id: 1, title: 'foo')
|
8
|
+
other = Starwars::Film.new(id: 1, title: 'bar')
|
9
|
+
expect(planet == other).to be true
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns false when objects IDs are different' do
|
13
|
+
planet = Starwars::Film.new(id: 1)
|
14
|
+
other = Starwars::Film.new(id: 2)
|
15
|
+
expect(planet == other).to be false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'getters' do
|
20
|
+
subject(:film) { Starwars::Film.fetch(1) }
|
21
|
+
describe '#created' do
|
22
|
+
it 'returns a Time when updated is set' do
|
23
|
+
expect(film.created).to be_a Time
|
24
|
+
end
|
25
|
+
end
|
26
|
+
describe '#edited' do
|
27
|
+
it 'returns a Time when edited is set' do
|
28
|
+
expect(film.edited).to be_a Time
|
29
|
+
end
|
30
|
+
end
|
31
|
+
describe '#title' do
|
32
|
+
it 'should have the correct value' do
|
33
|
+
expect(film.title).to eq 'A New Hope'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
describe '#opening_crawl' do
|
37
|
+
it 'should have the correct value' do
|
38
|
+
expect(film.opening_crawl.include?('It is a period of civil war')).to eq true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
describe '#director' do
|
42
|
+
it 'should have the correct value' do
|
43
|
+
expect(film.director).to eq 'George Lucas'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
describe '#producer' do
|
47
|
+
it 'should have the correct value' do
|
48
|
+
expect(film.producer).to eq 'Gary Kurtz, Rick McCallum'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
describe '#url' do
|
52
|
+
it 'should have the correct value' do
|
53
|
+
expect(film.url).to eq 'http://swapi.co/api/films/1/'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#episode_id' do
|
58
|
+
it 'should be an integer' do
|
59
|
+
expect(film.episode_id).to be_an Integer
|
60
|
+
end
|
61
|
+
it 'should should have the correct value' do
|
62
|
+
expect(film.episode_id).to eq 4
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#starships' do
|
67
|
+
it 'should return an Array' do
|
68
|
+
expect(film.starships).to be_an Array
|
69
|
+
end
|
70
|
+
it 'should should the correct number of starships' do
|
71
|
+
expect(film.starships.size).to eq 8
|
72
|
+
end
|
73
|
+
it 'should contain an array of starships correctly parsed' do
|
74
|
+
starship = film.starships.first
|
75
|
+
expect(starship).to be_a Starwars::Starship
|
76
|
+
expect(starship.url).to eq 'http://swapi.co/api/starships/2/'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
describe '#vehicles' do
|
80
|
+
it 'should return an Array' do
|
81
|
+
expect(film.vehicles).to be_an Array
|
82
|
+
end
|
83
|
+
it 'should should the correct number of vehicles' do
|
84
|
+
expect(film.vehicles.size).to eq 4
|
85
|
+
end
|
86
|
+
it 'should contain an array of films correctly parsed' do
|
87
|
+
vehicle = film.vehicles.first
|
88
|
+
expect(vehicle).to be_a Starwars::Vehicle
|
89
|
+
expect(vehicle.url).to eq 'http://swapi.co/api/vehicles/4/'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
describe '#species' do
|
93
|
+
it 'should return an Array' do
|
94
|
+
expect(film.species).to be_an Array
|
95
|
+
end
|
96
|
+
it 'should should the correct number of species' do
|
97
|
+
expect(film.species.size).to eq 5
|
98
|
+
end
|
99
|
+
it 'should contain an array of films correctly parsed' do
|
100
|
+
specie = film.species.first
|
101
|
+
expect(specie).to be_a Starwars::Specie
|
102
|
+
expect(specie.url).to eq 'http://swapi.co/api/species/1/'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
describe '#characters' do
|
106
|
+
it 'should return an Array' do
|
107
|
+
expect(film.characters).to be_an Array
|
108
|
+
end
|
109
|
+
it 'should should the correct number of characters' do
|
110
|
+
expect(film.characters.size).to eq 18
|
111
|
+
end
|
112
|
+
it 'should contain an array of characters correctly parsed' do
|
113
|
+
person = film.characters.first
|
114
|
+
expect(person).to be_a Starwars::Person
|
115
|
+
expect(person.url).to eq 'http://swapi.co/api/people/1/'
|
116
|
+
end
|
117
|
+
end
|
118
|
+
describe '#planets' do
|
119
|
+
it 'should return an Array' do
|
120
|
+
expect(film.planets).to be_an Array
|
121
|
+
end
|
122
|
+
it 'should should the correct number of planets' do
|
123
|
+
expect(film.planets.size).to eq 3
|
124
|
+
end
|
125
|
+
it 'should contain an array of planets correctly parsed' do
|
126
|
+
planet = film.planets.first
|
127
|
+
expect(planet).to be_a Starwars::Planet
|
128
|
+
expect(planet.url).to eq 'http://swapi.co/api/planets/2/'
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
describe Starwars::Person do
|
2
|
+
before do
|
3
|
+
stub_get('/people/2/').to_return(body: fixture('people_2.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
4
|
+
stub_get('/people/1/').to_return(body: fixture('people_1.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
5
|
+
end
|
6
|
+
|
7
|
+
describe '#==' do
|
8
|
+
it 'returns true when objects IDs and URLS are the same' do
|
9
|
+
planet = Starwars::Person.new(id: 1, name: 'foo')
|
10
|
+
other = Starwars::Person.new(id: 1, name: 'bar')
|
11
|
+
expect(planet == other).to be true
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns false when objects IDs are different' do
|
15
|
+
planet = Starwars::Person.new(id: 1)
|
16
|
+
other = Starwars::Person.new(id: 2)
|
17
|
+
expect(planet == other).to be false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'getters' do
|
22
|
+
subject(:person_2) { Starwars::Person.fetch(2) }
|
23
|
+
subject(:person_1) { Starwars::Person.fetch(1) }
|
24
|
+
describe '#created' do
|
25
|
+
it 'returns a Time when updated is set' do
|
26
|
+
expect(person_2.created).to be_a Time
|
27
|
+
end
|
28
|
+
end
|
29
|
+
describe '#edited' do
|
30
|
+
it 'returns a Time when edited is set' do
|
31
|
+
expect(person_2.edited).to be_a Time
|
32
|
+
end
|
33
|
+
end
|
34
|
+
describe '#name' do
|
35
|
+
it 'should have the correct value' do
|
36
|
+
expect(person_2.name).to eq 'C-3PO'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
describe '#skin_color' do
|
40
|
+
it 'should have the correct value' do
|
41
|
+
expect(person_2.skin_color).to eq 'gold'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
describe '#eye_color' do
|
45
|
+
it 'should have the correct value' do
|
46
|
+
expect(person_2.eye_color).to eq 'yellow'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
describe '#hair_color' do
|
50
|
+
it 'should have the correct value' do
|
51
|
+
expect(person_2.hair_color).to eq 'n/a'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
describe '#birth_year' do
|
55
|
+
it 'should have the correct value' do
|
56
|
+
expect(person_2.birth_year).to eq '112BBY'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
describe '#gender' do
|
60
|
+
it 'should have the correct value' do
|
61
|
+
expect(person_2.gender).to eq 'n/a'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
describe '#url' do
|
65
|
+
it 'should have the correct value' do
|
66
|
+
expect(person_2.url).to eq 'http://swapi.co/api/people/2/'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#height' do
|
71
|
+
it 'should be an integer' do
|
72
|
+
expect(person_2.height).to be_an Integer
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should should have the correct value' do
|
76
|
+
expect(person_2.height).to eq 167
|
77
|
+
end
|
78
|
+
end
|
79
|
+
describe '#mass' do
|
80
|
+
it 'should be an integer' do
|
81
|
+
expect(person_2.mass).to be_an Integer
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should should have the correct value' do
|
85
|
+
expect(person_2.mass).to eq 75
|
86
|
+
end
|
87
|
+
end
|
88
|
+
describe '#homeworld' do
|
89
|
+
it 'should return a Starwars::Planet object' do
|
90
|
+
expect(person_2.homeworld).to be_an Starwars::Planet
|
91
|
+
end
|
92
|
+
it 'should contains the correct resouce url' do
|
93
|
+
expect(person_2.homeworld.url).to eq 'http://swapi.co/api/planets/1/'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#films' do
|
98
|
+
it 'should return an Array' do
|
99
|
+
expect(person_2.films).to be_an Array
|
100
|
+
end
|
101
|
+
it 'should should the correct number of residents' do
|
102
|
+
expect(person_2.films.size).to eq 6
|
103
|
+
end
|
104
|
+
it 'should contain an array of films correctly parsed' do
|
105
|
+
film = person_2.films.first
|
106
|
+
expect(film).to be_a Starwars::Film
|
107
|
+
expect(film.url).to eq 'http://swapi.co/api/films/1/'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
describe '#species' do
|
111
|
+
it 'should return an Array' do
|
112
|
+
expect(person_2.species).to be_an Array
|
113
|
+
end
|
114
|
+
it 'should should the correct number of residents' do
|
115
|
+
expect(person_2.species.size).to eq 1
|
116
|
+
end
|
117
|
+
it 'should contain an array of films correctly parsed' do
|
118
|
+
specie = person_2.species.first
|
119
|
+
expect(specie).to be_a Starwars::Specie
|
120
|
+
expect(specie.url).to eq 'http://swapi.co/api/species/2/'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
describe '#vehicles' do
|
124
|
+
it 'should return an Array' do
|
125
|
+
expect(person_1.vehicles).to be_an Array
|
126
|
+
end
|
127
|
+
it 'should should the correct number of residents' do
|
128
|
+
expect(person_1.vehicles.size).to eq 2
|
129
|
+
end
|
130
|
+
it 'should contain an array of films correctly parsed' do
|
131
|
+
vehicle = person_1.vehicles.first
|
132
|
+
expect(vehicle).to be_a Starwars::Vehicle
|
133
|
+
expect(vehicle.url).to eq 'http://swapi.co/api/vehicles/14/'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
describe '#starships' do
|
137
|
+
it 'should return an Array' do
|
138
|
+
expect(person_1.starships).to be_an Array
|
139
|
+
end
|
140
|
+
it 'should should the correct number of residents' do
|
141
|
+
expect(person_1.starships.size).to eq 2
|
142
|
+
end
|
143
|
+
it 'should contain an array of films correctly parsed' do
|
144
|
+
starship = person_1.starships.first
|
145
|
+
expect(starship).to be_a Starwars::Starship
|
146
|
+
expect(starship.url).to eq 'http://swapi.co/api/starships/12/'
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|