Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lib/warframe/models/cambion_drift.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require_relative './base'
require_relative 'attributes/id'
require_relative 'attributes/expiry'
require_relative 'attributes/active'

module Warframe
module Models
# Model for Cambion Drift Data {https://api.warframestat.us/pc/cambionCycle> /:platform/cambionCycle}
class CambionDrift < Warframe::Models::Base
include Warframe::Models::Attributes::ID
include Warframe::Models::Attributes::Activation
include Warframe::Models::Attributes::Expiry

# Current active state of the world, either 'vome' or 'fass'.
# @return [String]
attr_reader :active

# The time remaining until world state switches.
# @return [String]
attr_reader :time_left
end
end
end
41 changes: 41 additions & 0 deletions lib/warframe/models/cetus.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# frozen_string_literal: true

require_relative './base'
require_relative 'attributes/id'
require_relative 'attributes/active'
require_relative 'attributes/expiry'

module Warframe
module Models
# Model for CetusCycle Data {https://api.warframestat.us/pc/cetusCycle> /:platform/cetusCycle}
# TODO: Replace above documentation path with correct one.
class Cetus < Warframe::Models::Base
include Warframe::Models::Attributes::ID
include Warframe::Models::Attributes::Activation
include Warframe::Models::Attributes::Expiry

# Whether or not it is currently day.
# @return [Boolean]
attr_reader :is_day
alias day? is_day

# Current world state of Cetus.
# @return [String]
attr_reader :state

# Whether or not this is Cetus.
# @return [Boolean]
attr_reader :is_cetus
alias cetus? is_cetus

# Time left until state change.
# @return [String]
attr_reader :time_left

# A short string of the time left until state change.
# @return [String]
attr_reader :short_string

end
end
end
4 changes: 4 additions & 0 deletions lib/warframe/rest/api.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require_relative 'api/alerts'
require_relative 'api/cambion_drift'
require_relative 'api/cetus'
require_relative 'api/conclave_challenges'
require_relative 'api/global_upgrades'
require_relative 'api/invasions'
Expand All @@ -20,6 +22,8 @@ module REST
# Module names are 'routes' to this API. See {Warframe::REST::API::Alerts Alerts} for example.
module API
include Warframe::REST::API::Alerts
include Warframe::REST::API::CambionDrift
include Warframe::REST::API::Cetus
include Warframe::REST::API::ConclaveChallenges
include Warframe::REST::API::GlobalUpgrades
include Warframe::REST::API::Invasions
Expand Down
23 changes: 23 additions & 0 deletions lib/warframe/rest/api/cambion_cycle.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

require 'warframe/models/cambion_cycle'
require_relative '../utils'

module Warframe
module REST
module API
# API endpoint for getting information on current CambionCycle data.
#
# {https://api.warframestat.us/pc/cambionCycle Example Response}
module CambionCycle
include Warframe::REST::Utils

# Gets the current cambionCycle Data.
# @return TODO: [Warframe::Models::CambionCycle] OR [Array<Warframe::Models::CambionCycle>]
def cambion_cycle
get('/cambionCycle', Warframe::Models::CambionCycle)
end
end
end
end
end
23 changes: 23 additions & 0 deletions lib/warframe/rest/api/cambion_drift.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

require 'warframe/models/cambion_drift'
require_relative '../utils'

module Warframe
module REST
module API
# API endpoint for getting information on current CambionDrift data.
#
# {https://api.warframestat.us/pc/cambionDrift Example Response}
module CambionDrift
include Warframe::REST::Utils

# Gets the current cambionDrift Data.
# @return Warframe::Models::CambionDrift
def cambion_drift
get('/cambionCycle', Warframe::Models::CambionDrift)
end
end
end
end
end
23 changes: 23 additions & 0 deletions lib/warframe/rest/api/cetus.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

require 'warframe/models/cetus'
require_relative '../utils'

module Warframe
module REST
module API
# API endpoint for getting information on current Cetus data.
#
# {https://api.warframestat.us/pc/cetusCycle Example Response}
module Cetus
include Warframe::REST::Utils

# Gets the current cetusCycle Data.
# @return [Warframe::Models::Cetus]
def cetus
get('/cetusCycle', Warframe::Models::Cetus)
end
end
end
end
end
7 changes: 7 additions & 0 deletions spec/fixtures/cambion_drift.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "cambionCycle1637607900000",
"activation": "2021-11-22T18:15:00.000Z",
"expiry": "2021-11-22T19:05:00.000Z",
"timeLeft": "12m 25s",
"active": "vome"
}
10 changes: 10 additions & 0 deletions spec/fixtures/cetus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "cetusCycle1637607900000",
"expiry": "2021-11-22T19:05:00.000Z",
"activation": "2021-11-22T18:15:00.000Z",
"isDay": false,
"state": "night",
"timeLeft": "12m 25s",
"isCetus": true,
"shortString": "12m to Day"
}
21 changes: 21 additions & 0 deletions spec/models/cambion_drift_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'rspec'

RSpec.describe Warframe::Models::Alert do
let(:json) { load_json_file 'cambion_drift' }
let(:drift) { Warframe::Models::CambionDrift.new json }

it 'can be instantiated from JSON' do
expect { drift }.to_not raise_error
end

it 'can be instantiated from JSON Array' do
json_arr = Array.new(6, json)
expect { Warframe::Models::CambionDrift.new json_arr }.to_not raise_error
end

it 'can read the newly created objects attributes' do
expect(drift.active).to be_a String
end
end
22 changes: 22 additions & 0 deletions spec/models/cetus_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# frozen_string_literal: true

require 'rspec'

RSpec.describe Warframe::Models::Cetus do
let(:json) { load_json_file 'cetus' }
let(:cetus) { Warframe::Models::Cetus.new json }

it 'can be instantiated from JSON' do
expect { cetus }.to_not raise_error
end

it 'can be instantiated from JSON Array' do
json_arr = Array.new(6, json)
expect { Warframe::Models::Cetus.new json_arr }.to_not raise_error
end

it 'can read the newly created objects attributes' do
expect(cetus.day?).to be_a_boolean
end
end
68 changes: 40 additions & 28 deletions spec/rest/rest_spec.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,48 @@
# frozen_string_literal: true

require 'rspec'
require 'active_support/core_ext/string/inflections'

RSpec.describe Warframe::REST::API do
let(:default_client) { Warframe::REST::Client.new }

routes = Warframe::REST::API.constants

context 'Routes' do
routes.each do |route|
method = route.to_s.underscore.downcase
describe "##{method}" do
it 'responds to method call' do
expect(default_client.send(method))
end

it 'properly loads data' do
sent = default_client.send(method)
model_instance = Warframe::Models.const_get(route.to_s.singularize)
if sent.is_a? Array
expect(sent.count).to be_positive
expect(sent[0].id).to_not be nil

sent.each do |obj|
expect(obj).to be_a model_instance
end
else
expect(sent).to be_a model_instance
end
end
end
let(:client) { Warframe::REST::Client.new }

context '#alerts' do
it 'does not raise error on call' do
expect { client.alerts }.to_not raise_error
end

it 'properly loads data into model' do
expect(client.alerts).to be_a Warframe::Models::Alert
end
end

context '#cambion_drift' do
it 'does not raise error on call' do
expect { client.cambion_drift }.to_not raise_error
end

it 'properly loads data into model' do
expect(client.cambion_drift).to be_a Warframe::Models::CambionDrift
end
end

context '#cetus' do
it 'does not raise error on call' do
expect { client.cetus }.to_not raise_error
end

it 'properly loads data into model' do
expect(client.cetus).to be_a Warframe::Models::Cetus
end
end

context '#nightwave' do
it 'does not raise error on call' do
expect { client.nightwave }.to_not raise_error
end

it 'properly loads data into model' do
expect(client.nightwave).to be_a Warframe::Models::Nightwave
end
end

end
9 changes: 8 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

require 'warframe'
require 'json'
require 'rspec'
require 'warframe'

module SpecUtils
def load_json_file(file_name)
Expand All @@ -22,3 +23,9 @@ def load_json_file(file_name)

config.include SpecUtils
end

RSpec::Matchers.define :be_a_boolean do
match do |real|
expect(real).to be(true).or be(false)
end
end