unchained 0.0.2 → 0.0.3
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 +4 -4
- data/README.md +0 -1
- data/lib/unchained/client.rb +8 -0
- data/lib/unchained/client/archetypes.rb +10 -2
- data/lib/unchained/client/attributes.rb +12 -4
- data/lib/unchained/client/factions.rb +9 -1
- data/lib/unchained/client/mixins/resource.rb +13 -1
- data/lib/unchained/client/patcher.rb +10 -2
- data/lib/unchained/client/races.rb +10 -2
- data/lib/unchained/client/servers.rb +9 -2
- data/lib/unchained/request.rb +14 -2
- data/lib/unchained/version.rb +1 -1
- data/test/_fixtures/vcr_cassettes/archetypes.yml +380 -2
- data/test/_fixtures/vcr_cassettes/attribute_offsets.yml +3446 -2
- data/test/_fixtures/vcr_cassettes/faction.yml +45 -0
- data/test/_fixtures/vcr_cassettes/races.yml +254 -2
- data/test/unchained/client/archetypes_test.rb +35 -1
- data/test/unchained/client/attributes_test.rb +36 -0
- data/test/unchained/client/factions_test.rb +28 -0
- data/test/unchained/client/mixins/resource_test.rb +85 -5
- data/test/unchained/client/motd_test.rb +5 -0
- data/test/unchained/client/patcher_test.rb +19 -0
- data/test/unchained/client/races_test.rb +36 -0
- data/test/unchained/client/servers_test.rb +8 -0
- data/test/unchained/client_test.rb +55 -0
- data/test/unchained/configuration_test.rb +54 -0
- data/test/unchained_test.rb +24 -0
- metadata +6 -2
@@ -11,6 +11,11 @@ describe Unchained::Client::MOTD do
|
|
11
11
|
VCR.use_cassette('motd') do
|
12
12
|
motd = @client.motd
|
13
13
|
|
14
|
+
assert(
|
15
|
+
motd.is_a?(Unchained::Client::MOTD::Message),
|
16
|
+
'Expected `motd` to be a Message.',
|
17
|
+
)
|
18
|
+
|
14
19
|
assert_equal('56ff1eeda7b0a02aa0e464cb', motd.id)
|
15
20
|
assert_equal('Welcome to Camelot Unchained!', motd.message)
|
16
21
|
assert_equal(30, motd.duration)
|
@@ -11,6 +11,16 @@ describe Unchained::Client::Patcher do
|
|
11
11
|
VCR.use_cassette('patcher_hero_contents') do
|
12
12
|
contents = @client.patcher_hero_contents
|
13
13
|
assert_equal(4, contents.count)
|
14
|
+
|
15
|
+
content = contents.first
|
16
|
+
assert(
|
17
|
+
content.is_a?(Unchained::Client::Patcher::HeroContent),
|
18
|
+
'Expected `contents` to return HeroContents.',
|
19
|
+
)
|
20
|
+
|
21
|
+
assert_equal('56e8299ba7b0a06214e5602e', content.id)
|
22
|
+
assert_match(/videos\/archer.jpg/, content.content)
|
23
|
+
assert_equal(7, content.priority)
|
14
24
|
end
|
15
25
|
end
|
16
26
|
end
|
@@ -20,6 +30,15 @@ describe Unchained::Client::Patcher do
|
|
20
30
|
VCR.use_cassette('patcher_alerts') do
|
21
31
|
alerts = @client.patcher_alerts
|
22
32
|
assert_equal(1, alerts.count)
|
33
|
+
|
34
|
+
alert = alerts.first
|
35
|
+
assert(
|
36
|
+
alert.is_a?(Unchained::Client::Patcher::Alert),
|
37
|
+
'Expected `alerts` to return Alerts.',
|
38
|
+
)
|
39
|
+
|
40
|
+
assert_equal('56a98f8965fe574304e0a193', alert.id)
|
41
|
+
assert_equal('A test message, please ignore', alert.message)
|
23
42
|
end
|
24
43
|
end
|
25
44
|
end
|
@@ -11,6 +11,42 @@ describe Unchained::Client::Races do
|
|
11
11
|
VCR.use_cassette('races') do
|
12
12
|
races = @client.races
|
13
13
|
assert_equal(6, races.count)
|
14
|
+
|
15
|
+
race = races.first
|
16
|
+
assert(
|
17
|
+
race.is_a?(Unchained::Client::Races::Race),
|
18
|
+
'Expected `races` to return Races,',
|
19
|
+
)
|
20
|
+
|
21
|
+
assert_equal('Luchorpan', race.description)
|
22
|
+
assert_equal(2, race.id)
|
23
|
+
assert_equal('Luchorpan', race.name)
|
24
|
+
|
25
|
+
assert(
|
26
|
+
race.faction.is_a?(Unchained::Client::Factions::Faction),
|
27
|
+
'Expected `faction` to be expanded on a Race.',
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '.race' do
|
34
|
+
it 'should fetch from the API' do
|
35
|
+
VCR.use_cassette('races') do
|
36
|
+
race = @client.race(2)
|
37
|
+
assert(
|
38
|
+
race.is_a?(Unchained::Client::Races::Race),
|
39
|
+
'Expected `races` to return Races,',
|
40
|
+
)
|
41
|
+
|
42
|
+
assert_equal('Luchorpan', race.description)
|
43
|
+
assert_equal(2, race.id)
|
44
|
+
assert_equal('Luchorpan', race.name)
|
45
|
+
|
46
|
+
assert(
|
47
|
+
race.faction.is_a?(Unchained::Client::Factions::Faction),
|
48
|
+
'Expected `faction` to be expanded on a Race.',
|
49
|
+
)
|
14
50
|
end
|
15
51
|
end
|
16
52
|
end
|
@@ -11,6 +11,14 @@ describe Unchained::Client::Servers do
|
|
11
11
|
VCR.use_cassette('servers') do
|
12
12
|
servers = @client.servers
|
13
13
|
assert_equal(4, servers.count)
|
14
|
+
|
15
|
+
server = servers.first
|
16
|
+
assert_equal(6, server.access_level)
|
17
|
+
assert_equal(4, server.channel_id)
|
18
|
+
assert_equal('wyrmlingprep.camelotunchained.com', server.host)
|
19
|
+
assert_equal('WyrmlingPrep', server.name)
|
20
|
+
assert_equal(1000, server.player_maximum)
|
21
|
+
assert_equal(1, server.shard_id)
|
14
22
|
end
|
15
23
|
end
|
16
24
|
end
|
@@ -1,4 +1,59 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
3
|
describe Unchained::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Unchained::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
Unchained::Configuration::KEYS.each do |k|
|
10
|
+
it "should set up an accessor for #{k}" do
|
11
|
+
assert(
|
12
|
+
@client.respond_to?(k),
|
13
|
+
"Expected `@client` to respond to `#{k}`.",
|
14
|
+
)
|
15
|
+
|
16
|
+
assert(
|
17
|
+
@client.respond_to?("#{k}="),
|
18
|
+
"Expected `@client` to respond to `#{k}=`.",
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'initialization' do
|
24
|
+
it 'should initialize the cache' do
|
25
|
+
refute_nil(@client.cache)
|
26
|
+
assert(@client.cache.is_a?(Hash))
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should initialize from the configuration' do
|
30
|
+
Unchained.configure {|c| c.login_token = 'init_token'}
|
31
|
+
client = Unchained::Client.new
|
32
|
+
assert_equal('init_token', client.login_token)
|
33
|
+
Unchained.reset!
|
34
|
+
client = Unchained::Client.new
|
35
|
+
assert_nil(client.login_token)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#base_url' do
|
40
|
+
it 'should be set correctly' do
|
41
|
+
assert_equal(
|
42
|
+
'http://api.camelotunchained.com/v1',
|
43
|
+
@client.base_url,
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#clear_cache!' do
|
49
|
+
it 'clears the cache' do
|
50
|
+
cache = {foo: 'bar'}
|
51
|
+
@client.instance_variable_set("@cache", cache)
|
52
|
+
assert_equal(cache, @client.cache)
|
53
|
+
|
54
|
+
@client.clear_cache!
|
55
|
+
assert_empty(@client.cache)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
4
59
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
describe Unchained::Configuration do
|
4
|
+
|
5
|
+
class SampleClass
|
6
|
+
extend Unchained::Configuration
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
SampleClass.reset!
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'accessors' do
|
14
|
+
Unchained::Configuration::KEYS.each do |k|
|
15
|
+
it "should create an accessor for #{k}" do
|
16
|
+
assert(
|
17
|
+
SampleClass.respond_to?(k),
|
18
|
+
"Expected `SampleClass` to respond to `#{k}`.",
|
19
|
+
)
|
20
|
+
|
21
|
+
assert(
|
22
|
+
SampleClass.respond_to?("#{k}="),
|
23
|
+
"Expected `SampleClass` to respond to `#{k}=`.",
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
it 'should create an accessor for every KEY' do
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '.configure' do
|
32
|
+
it 'should allow you to configure SampleClass' do
|
33
|
+
SampleClass.configure {|c| c.login_token = 'abc123'}
|
34
|
+
assert_equal('abc123', SampleClass.login_token)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '.configuration' do
|
39
|
+
it 'should return the configuration' do
|
40
|
+
assert_equal({login_token: nil}, SampleClass.configuration)
|
41
|
+
SampleClass.login_token = 'abc123'
|
42
|
+
assert_equal({login_token: 'abc123'}, SampleClass.configuration)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '.reset!' do
|
47
|
+
it 'should reset the configuration' do
|
48
|
+
SampleClass.login_token = 'abc1234'
|
49
|
+
assert_equal('abc1234', SampleClass.login_token)
|
50
|
+
SampleClass.reset!
|
51
|
+
assert_nil(SampleClass.login_token)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/test/unchained_test.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative './test_helper'
|
2
|
+
|
3
|
+
describe Unchained do
|
4
|
+
|
5
|
+
it 'should extend Configuration' do
|
6
|
+
assert(
|
7
|
+
(class << Unchained; self end)
|
8
|
+
.included_modules
|
9
|
+
.include?(Unchained::Configuration),
|
10
|
+
'Expected `Unchained` to extend `Unchained::Configuration`.',
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.new' do
|
15
|
+
it 'should return a new Unchained::Client' do
|
16
|
+
client = Unchained.new
|
17
|
+
assert(
|
18
|
+
client.is_a?(Unchained::Client),
|
19
|
+
'Expected `Unchained.new` to return an `Unchained::Client`.',
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unchained
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Thorp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- test/_fixtures/vcr_cassettes/archetypes.yml
|
122
122
|
- test/_fixtures/vcr_cassettes/attribute_offsets.yml
|
123
123
|
- test/_fixtures/vcr_cassettes/attributes.yml
|
124
|
+
- test/_fixtures/vcr_cassettes/faction.yml
|
124
125
|
- test/_fixtures/vcr_cassettes/factions.yml
|
125
126
|
- test/_fixtures/vcr_cassettes/motd.yml
|
126
127
|
- test/_fixtures/vcr_cassettes/patcher_alerts.yml
|
@@ -137,6 +138,7 @@ files:
|
|
137
138
|
- test/unchained/client/races_test.rb
|
138
139
|
- test/unchained/client/servers_test.rb
|
139
140
|
- test/unchained/client_test.rb
|
141
|
+
- test/unchained/configuration_test.rb
|
140
142
|
- test/unchained_test.rb
|
141
143
|
- unchained.gemspec
|
142
144
|
homepage: http://github.com/andrewpthorp/unchained
|
@@ -167,6 +169,7 @@ test_files:
|
|
167
169
|
- test/_fixtures/vcr_cassettes/archetypes.yml
|
168
170
|
- test/_fixtures/vcr_cassettes/attribute_offsets.yml
|
169
171
|
- test/_fixtures/vcr_cassettes/attributes.yml
|
172
|
+
- test/_fixtures/vcr_cassettes/faction.yml
|
170
173
|
- test/_fixtures/vcr_cassettes/factions.yml
|
171
174
|
- test/_fixtures/vcr_cassettes/motd.yml
|
172
175
|
- test/_fixtures/vcr_cassettes/patcher_alerts.yml
|
@@ -183,5 +186,6 @@ test_files:
|
|
183
186
|
- test/unchained/client/races_test.rb
|
184
187
|
- test/unchained/client/servers_test.rb
|
185
188
|
- test/unchained/client_test.rb
|
189
|
+
- test/unchained/configuration_test.rb
|
186
190
|
- test/unchained_test.rb
|
187
191
|
has_rdoc:
|