mtg_sdk 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +24 -24
- data/.travis.yml +9 -9
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +175 -174
- data/Rakefile +10 -10
- data/lib/mtg_sdk.rb +32 -32
- data/lib/mtg_sdk/card.rb +43 -43
- data/lib/mtg_sdk/changelog.rb +24 -24
- data/lib/mtg_sdk/configuration.rb +8 -8
- data/lib/mtg_sdk/foreign_name.rb +10 -10
- data/lib/mtg_sdk/legality.rb +10 -10
- data/lib/mtg_sdk/query_builder.rb +65 -65
- data/lib/mtg_sdk/representers/card_representer.rb +55 -55
- data/lib/mtg_sdk/representers/changelog_representer.rb +12 -12
- data/lib/mtg_sdk/representers/foreign_name_representer.rb +11 -11
- data/lib/mtg_sdk/representers/legality_representer.rb +9 -9
- data/lib/mtg_sdk/representers/ruling_representer.rb +11 -11
- data/lib/mtg_sdk/representers/set_representer.rb +21 -21
- data/lib/mtg_sdk/rest_client.rb +31 -31
- data/lib/mtg_sdk/ruling.rb +10 -10
- data/lib/mtg_sdk/set.rb +61 -53
- data/lib/mtg_sdk/subtype.rb +11 -11
- data/lib/mtg_sdk/supertype.rb +11 -11
- data/lib/mtg_sdk/type.rb +11 -11
- data/lib/mtg_sdk/version.rb +3 -3
- data/mtg_sdk.gemspec +36 -36
- data/test/card_test.rb +80 -66
- data/test/changelog_test.rb +11 -11
- data/test/configuration_test.rb +19 -9
- data/test/responses/no_cards.json +1 -0
- data/test/responses/sample_cards.json +1 -0
- data/test/set_test.rb +51 -41
- data/test/subtype_test.rb +11 -11
- data/test/supertype_test.rb +11 -11
- data/test/test_helper.rb +21 -21
- data/test/type_test.rb +11 -11
- metadata +7 -3
data/test/card_test.rb
CHANGED
@@ -1,67 +1,81 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require_relative 'test_helper'
|
3
|
-
|
4
|
-
class CardTest < Minitest::Test
|
5
|
-
def test_find_returns_one_card
|
6
|
-
VCR.use_cassette('one_card') do
|
7
|
-
card = MTG::Card.find(88803)
|
8
|
-
|
9
|
-
assert_equal 'Choice of Damnations', card.name
|
10
|
-
assert_equal '{5}{B}', card.mana_cost
|
11
|
-
assert_equal 6, card.cmc
|
12
|
-
assert_equal 'Sorcery — Arcane', card.type
|
13
|
-
assert card.colors.any?{|color| color == 'Black'}
|
14
|
-
assert card.types.any?{|type| type == 'Sorcery'}
|
15
|
-
assert card.subtypes.any?{|subtype| subtype == 'Arcane'}
|
16
|
-
assert_equal 'Rare', card.rarity
|
17
|
-
assert_equal 'SOK', card.set
|
18
|
-
assert_equal 'Saviors of Kamigawa', card.set_name
|
19
|
-
assert_equal "Target opponent chooses a number. You may have that player lose that much life. If you don't, that player sacrifices all but that many permanents.", card.text
|
20
|
-
assert_equal "\"Life is a series of choices between bad and worse.\"\n—Toshiro Umezawa", card.flavor
|
21
|
-
assert_equal 'Tim Hildebrandt', card.artist
|
22
|
-
assert_equal '62', card.number
|
23
|
-
assert_equal 'normal', card.layout
|
24
|
-
assert_equal 88803, card.multiverse_id
|
25
|
-
assert_equal 'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=88803&type=card', card.image_url
|
26
|
-
assert card.rulings.any?{|ruling| ruling.date == Date.parse('2005-06-01')}
|
27
|
-
assert card.foreign_names.any?{|foreign_name| foreign_name.name == '破灭抉择' && foreign_name.image_url == 'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=104898&type=card'}
|
28
|
-
assert card.printings.any?{|printing| printing == 'SOK'}
|
29
|
-
assert_equal "Target opponent chooses a number. You may have that player lose that much life. If you don't, that player sacrifices all but that many permanents.", card.original_text
|
30
|
-
assert_equal 'Sorcery — Arcane', card.original_type
|
31
|
-
assert card.legalities.any?{|legality| legality.format == 'Commander' && legality.legality == 'Legal'}
|
32
|
-
assert_equal '1c4aab072d52d283e902f2302afa255b39e0794b', card.id
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_find_with_invalid_id_throws_exception
|
37
|
-
VCR.use_cassette('invalid_id') do
|
38
|
-
assert_raises ArgumentError do
|
39
|
-
MTG::Card.find(3239482932)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_where_with_page_size_and_page_returns_cards
|
45
|
-
VCR.use_cassette('query_cards_pageSize') do
|
46
|
-
cards = MTG::Card.where(pageSize: 10).where(page: 1).all
|
47
|
-
|
48
|
-
# make sure we got only 10 cards back
|
49
|
-
assert cards.length == 10
|
50
|
-
assert cards.kind_of?(Array)
|
51
|
-
assert cards.first.kind_of?(MTG::Card)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_all_returns_cards
|
56
|
-
VCR.use_cassette('all_filtered') do
|
57
|
-
cards = MTG::Card.where(supertypes: 'legendary')
|
58
|
-
.where(subtypes: 'elf,warrior')
|
59
|
-
.all
|
60
|
-
|
61
|
-
first_card = cards[0]
|
62
|
-
assert first_card.supertypes.include? 'Legendary'
|
63
|
-
assert first_card.subtypes.include? 'Elf'
|
64
|
-
assert first_card.subtypes.include? 'Warrior'
|
65
|
-
end
|
66
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
require_relative 'test_helper'
|
3
|
+
|
4
|
+
class CardTest < Minitest::Test
|
5
|
+
def test_find_returns_one_card
|
6
|
+
VCR.use_cassette('one_card') do
|
7
|
+
card = MTG::Card.find(88803)
|
8
|
+
|
9
|
+
assert_equal 'Choice of Damnations', card.name
|
10
|
+
assert_equal '{5}{B}', card.mana_cost
|
11
|
+
assert_equal 6, card.cmc
|
12
|
+
assert_equal 'Sorcery — Arcane', card.type
|
13
|
+
assert card.colors.any?{|color| color == 'Black'}
|
14
|
+
assert card.types.any?{|type| type == 'Sorcery'}
|
15
|
+
assert card.subtypes.any?{|subtype| subtype == 'Arcane'}
|
16
|
+
assert_equal 'Rare', card.rarity
|
17
|
+
assert_equal 'SOK', card.set
|
18
|
+
assert_equal 'Saviors of Kamigawa', card.set_name
|
19
|
+
assert_equal "Target opponent chooses a number. You may have that player lose that much life. If you don't, that player sacrifices all but that many permanents.", card.text
|
20
|
+
assert_equal "\"Life is a series of choices between bad and worse.\"\n—Toshiro Umezawa", card.flavor
|
21
|
+
assert_equal 'Tim Hildebrandt', card.artist
|
22
|
+
assert_equal '62', card.number
|
23
|
+
assert_equal 'normal', card.layout
|
24
|
+
assert_equal 88803, card.multiverse_id
|
25
|
+
assert_equal 'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=88803&type=card', card.image_url
|
26
|
+
assert card.rulings.any?{|ruling| ruling.date == Date.parse('2005-06-01')}
|
27
|
+
assert card.foreign_names.any?{|foreign_name| foreign_name.name == '破灭抉择' && foreign_name.image_url == 'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=104898&type=card'}
|
28
|
+
assert card.printings.any?{|printing| printing == 'SOK'}
|
29
|
+
assert_equal "Target opponent chooses a number. You may have that player lose that much life. If you don't, that player sacrifices all but that many permanents.", card.original_text
|
30
|
+
assert_equal 'Sorcery — Arcane', card.original_type
|
31
|
+
assert card.legalities.any?{|legality| legality.format == 'Commander' && legality.legality == 'Legal'}
|
32
|
+
assert_equal '1c4aab072d52d283e902f2302afa255b39e0794b', card.id
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_find_with_invalid_id_throws_exception
|
37
|
+
VCR.use_cassette('invalid_id') do
|
38
|
+
assert_raises ArgumentError do
|
39
|
+
MTG::Card.find(3239482932)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_where_with_page_size_and_page_returns_cards
|
45
|
+
VCR.use_cassette('query_cards_pageSize') do
|
46
|
+
cards = MTG::Card.where(pageSize: 10).where(page: 1).all
|
47
|
+
|
48
|
+
# make sure we got only 10 cards back
|
49
|
+
assert cards.length == 10
|
50
|
+
assert cards.kind_of?(Array)
|
51
|
+
assert cards.first.kind_of?(MTG::Card)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_all_returns_cards
|
56
|
+
VCR.use_cassette('all_filtered') do
|
57
|
+
cards = MTG::Card.where(supertypes: 'legendary')
|
58
|
+
.where(subtypes: 'elf,warrior')
|
59
|
+
.all
|
60
|
+
|
61
|
+
first_card = cards[0]
|
62
|
+
assert first_card.supertypes.include? 'Legendary'
|
63
|
+
assert first_card.subtypes.include? 'Elf'
|
64
|
+
assert first_card.subtypes.include? 'Warrior'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_all_returns_all_cards
|
69
|
+
VCR.use_cassette('all_cards') do
|
70
|
+
stub_request(:any, "https://api.magicthegathering.io/v1/cards").
|
71
|
+
to_return(:body => File.new('test/responses/sample_cards.json'), :status => 200, :headers => {"Content-Type"=> "application/json"})
|
72
|
+
|
73
|
+
stub_request(:any, "https://api.magicthegathering.io/v1/cards?page=2").
|
74
|
+
to_return(:body => File.new('test/responses/no_cards.json'), :status => 200, :headers => {"Content-Type"=> "application/json"})
|
75
|
+
|
76
|
+
cards = MTG::Card.all
|
77
|
+
|
78
|
+
assert_equal 2, cards.length
|
79
|
+
end
|
80
|
+
end
|
67
81
|
end
|
data/test/changelog_test.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class ChangelogTest < Minitest::Test
|
4
|
-
def test_all_returns_all_changelogs
|
5
|
-
VCR.use_cassette('all_changelogs') do
|
6
|
-
changelogs = MTG::Changelog.all
|
7
|
-
|
8
|
-
assert changelogs.length > 1
|
9
|
-
assert changelogs.any? {|changelog| changelog.version == '1.0.0'}
|
10
|
-
end
|
11
|
-
end
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class ChangelogTest < Minitest::Test
|
4
|
+
def test_all_returns_all_changelogs
|
5
|
+
VCR.use_cassette('all_changelogs') do
|
6
|
+
changelogs = MTG::Changelog.all
|
7
|
+
|
8
|
+
assert changelogs.length > 1
|
9
|
+
assert changelogs.any? {|changelog| changelog.version == '1.0.0'}
|
10
|
+
end
|
11
|
+
end
|
12
12
|
end
|
data/test/configuration_test.rb
CHANGED
@@ -1,10 +1,20 @@
|
|
1
|
-
#test/client_test.rb
|
2
|
-
require_relative 'test_helper'
|
3
|
-
|
4
|
-
class ConfigurationTest < Minitest::Test
|
5
|
-
def test_defaults
|
6
|
-
config = MTG::Configuration.new
|
7
|
-
|
8
|
-
assert_equal 1, config.api_version
|
9
|
-
end
|
1
|
+
#test/client_test.rb
|
2
|
+
require_relative 'test_helper'
|
3
|
+
|
4
|
+
class ConfigurationTest < Minitest::Test
|
5
|
+
def test_defaults
|
6
|
+
config = MTG::Configuration.new
|
7
|
+
|
8
|
+
assert_equal 1, config.api_version
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_reset
|
12
|
+
MTG.configure do |config|
|
13
|
+
config.api_version = 2
|
14
|
+
end
|
15
|
+
|
16
|
+
MTG.reset
|
17
|
+
|
18
|
+
assert_equal 1, MTG.configuration.api_version
|
19
|
+
end
|
10
20
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"cards":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"cards":[{"name":"Decimator of the Provinces","manaCost":"{10}","cmc":10,"type":"Creature — Eldrazi Boar","types":["Creature"],"subtypes":["Eldrazi","Boar"],"rarity":"Mythic Rare","set":"EMN","setName":"Eldritch Moon","text":"Emerge {6}{G}{G}{G} (You may cast this spell by sacrificing a creature and paying the emerge cost reduced by that creature's converted mana cost.)\nWhen you cast Decimator of the Provinces, creatures you control get +2/+2 and gain trample until end of turn.\nTrample, haste","artist":"Svetlin Velinov","number":"2","power":"7","toughness":"7","layout":"normal","multiverseid":414291,"imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=414291&type=card","foreignNames":[{"name":"屠省野猪","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=414514&type=card","language":"Chinese Simplified","multiverseid":414514},{"name":"屠省野豬","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=414737&type=card","language":"Chinese Traditional","multiverseid":414737},{"name":"Décimateur des provinces","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=415183&type=card","language":"French","multiverseid":415183},{"name":"Dezimierer der Provinzen","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=414960&type=card","language":"German","multiverseid":414960},{"name":"Decimatore delle Province","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=415406&type=card","language":"Italian","multiverseid":415406},{"name":"州民を滅ぼすもの","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=415629&type=card","language":"Japanese","multiverseid":415629},{"name":"민중 대량학살자","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=415852&type=card","language":"Korean","multiverseid":415852},{"name":"Dizimador das Províncias","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=416075&type=card","language":"Portuguese (Brazil)","multiverseid":416075},{"name":"Истребитель Провинций","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=416298&type=card","language":"Russian","multiverseid":416298},{"name":"Diezmador de las provincias","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=416521&type=card","language":"Spanish","multiverseid":416521}],"printings":["EMN"],"originalText":"Emerge {6}{G}{G}{G} (You may cast this spell by sacrificing a creature and paying the emerge cost reduced by that creature's converted mana cost.)\nWhen you cast Decimator of the Provinces, creatures you control get +2/+2 and gain trample until end of turn.\nTrample, haste","originalType":"Creature — Eldrazi Boar","id":"786bca6b6efb3ea1dac22e7be3f970471a17e7a6"},{"name":"Emrakul, the Promised End","manaCost":"{13}","cmc":13,"type":"Legendary Creature — Eldrazi","supertypes":["Legendary"],"types":["Creature"],"subtypes":["Eldrazi"],"rarity":"Mythic Rare","set":"EMN","setName":"Eldritch Moon","text":"Emrakul, the Promised End costs {1} less to cast for each card type among cards in your graveyard. \nWhen you cast Emrakul, you gain control of target opponent during that player's next turn. After that turn, that player takes an extra turn.\nFlying, trample, protection from instants","flavor":"An enigma as vexing as life itself.","artist":"Jaime Jones","number":"6","power":"13","toughness":"13","layout":"normal","multiverseid":414295,"imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=414295&type=card","foreignNames":[{"name":"绝望终局伊莫库","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=414518&type=card","language":"Chinese Simplified","multiverseid":414518},{"name":"絕望終局伊莫庫","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=414741&type=card","language":"Chinese Traditional","multiverseid":414741},{"name":"Emrakul, la Fin promise","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=415187&type=card","language":"French","multiverseid":415187},{"name":"Emrakul, das prophezeite Ende","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=414964&type=card","language":"German","multiverseid":414964},{"name":"Emrakul, la Fine Promessa","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=415410&type=card","language":"Italian","multiverseid":415410},{"name":"約束された終末、エムラクール","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=415633&type=card","language":"Japanese","multiverseid":415633},{"name":"약속된 종말 엠라쿨","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=415856&type=card","language":"Korean","multiverseid":415856},{"name":"Emrakul, o Fim Prometido","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=416079&type=card","language":"Portuguese (Brazil)","multiverseid":416079},{"name":"Эмракул, Обетованная Гибель","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=416302&type=card","language":"Russian","multiverseid":416302},{"name":"Emrakul, el Final Prometido","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=416525&type=card","language":"Spanish","multiverseid":416525}],"printings":["EMN"],"originalText":"Emrakul, the Promised End costs {1} less to cast for each card type among cards in your graveyard. \nWhen you cast Emrakul, you gain control of target opponent during that player's next turn. After that turn, that player takes an extra turn.\nFlying, trample, protection from instants","originalType":"Legendary Creature — Eldrazi","id":"3961b8f27dfebff5024e0d4cea2e5dedcd8ed3cd"}]}
|
data/test/set_test.rb
CHANGED
@@ -1,42 +1,52 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class SetTest < Minitest::Test
|
4
|
-
def test_find_returns_one_set
|
5
|
-
VCR.use_cassette('one_set') do
|
6
|
-
set = MTG::Set.find('ktk')
|
7
|
-
|
8
|
-
assert_equal 'KTK', set.code
|
9
|
-
assert_equal 'Khans of Tarkir', set.name
|
10
|
-
assert_equal 'expansion', set.type
|
11
|
-
assert_equal 'black', set.border
|
12
|
-
assert set.booster.any? {|rarity| rarity == 'common'}
|
13
|
-
assert_equal '2014-09-26', set.release_date
|
14
|
-
assert_equal 'ktk', set.magic_cards_info_code
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_find_with_invalid_code_throws_exception
|
19
|
-
VCR.use_cassette('invalid_code') do
|
20
|
-
assert_raises ArgumentError do
|
21
|
-
MTG::Set.find('invalid')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_all_returns_all_sets
|
27
|
-
VCR.use_cassette('all_sets') do
|
28
|
-
sets = MTG::Set.all
|
29
|
-
|
30
|
-
assert sets.length > 100
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def
|
35
|
-
VCR.use_cassette('
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
assert_equal 'KTK',
|
40
|
-
|
41
|
-
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class SetTest < Minitest::Test
|
4
|
+
def test_find_returns_one_set
|
5
|
+
VCR.use_cassette('one_set') do
|
6
|
+
set = MTG::Set.find('ktk')
|
7
|
+
|
8
|
+
assert_equal 'KTK', set.code
|
9
|
+
assert_equal 'Khans of Tarkir', set.name
|
10
|
+
assert_equal 'expansion', set.type
|
11
|
+
assert_equal 'black', set.border
|
12
|
+
assert set.booster.any? {|rarity| rarity == 'common'}
|
13
|
+
assert_equal '2014-09-26', set.release_date
|
14
|
+
assert_equal 'ktk', set.magic_cards_info_code
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_find_with_invalid_code_throws_exception
|
19
|
+
VCR.use_cassette('invalid_code') do
|
20
|
+
assert_raises ArgumentError do
|
21
|
+
MTG::Set.find('invalid')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_all_returns_all_sets
|
27
|
+
VCR.use_cassette('all_sets') do
|
28
|
+
sets = MTG::Set.all
|
29
|
+
|
30
|
+
assert sets.length > 100
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_all_with_filter_returns_sets
|
35
|
+
VCR.use_cassette('all_sets_filtered') do
|
36
|
+
sets = MTG::Set.where(name: 'khans').all
|
37
|
+
|
38
|
+
set = sets[0]
|
39
|
+
assert_equal 'KTK', set.code
|
40
|
+
assert_equal 'Khans of Tarkir', set.name
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_generate_booster_returns_cards
|
45
|
+
VCR.use_cassette('booster') do
|
46
|
+
cards = MTG::Set.generate_booster('ktk')
|
47
|
+
|
48
|
+
assert cards.length == 15
|
49
|
+
assert_equal 'KTK', cards.first.set
|
50
|
+
end
|
51
|
+
end
|
42
52
|
end
|
data/test/subtype_test.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class SubtypeTest < Minitest::Test
|
4
|
-
def test_all_returns_all_subtypes
|
5
|
-
VCR.use_cassette('all_subtypes') do
|
6
|
-
types = MTG::Subtype.all
|
7
|
-
|
8
|
-
assert types.length > 10
|
9
|
-
assert types.any? {|type| type == 'Warrior'}
|
10
|
-
end
|
11
|
-
end
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class SubtypeTest < Minitest::Test
|
4
|
+
def test_all_returns_all_subtypes
|
5
|
+
VCR.use_cassette('all_subtypes') do
|
6
|
+
types = MTG::Subtype.all
|
7
|
+
|
8
|
+
assert types.length > 10
|
9
|
+
assert types.any? {|type| type == 'Warrior'}
|
10
|
+
end
|
11
|
+
end
|
12
12
|
end
|
data/test/supertype_test.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class SupertypeTest < Minitest::Test
|
4
|
-
def test_all_returns_all_types
|
5
|
-
VCR.use_cassette('all_supertypes') do
|
6
|
-
types = MTG::Supertype.all
|
7
|
-
|
8
|
-
assert types.length == 5
|
9
|
-
assert types.any? {|type| type == 'Legendary'}
|
10
|
-
end
|
11
|
-
end
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class SupertypeTest < Minitest::Test
|
4
|
+
def test_all_returns_all_types
|
5
|
+
VCR.use_cassette('all_supertypes') do
|
6
|
+
types = MTG::Supertype.all
|
7
|
+
|
8
|
+
assert types.length == 5
|
9
|
+
assert types.any? {|type| type == 'Legendary'}
|
10
|
+
end
|
11
|
+
end
|
12
12
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
#test/test_helper.rb
|
2
|
-
require 'simplecov'
|
3
|
-
require 'coveralls'
|
4
|
-
require 'codeclimate-test-reporter'
|
5
|
-
|
6
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
7
|
-
SimpleCov::Formatter::HTMLFormatter,
|
8
|
-
Coveralls::SimpleCov::Formatter,
|
9
|
-
CodeClimate::TestReporter::Formatter
|
10
|
-
])
|
11
|
-
SimpleCov.start
|
12
|
-
|
13
|
-
require_relative '../lib/mtg_sdk'
|
14
|
-
require 'minitest/autorun'
|
15
|
-
require 'webmock/minitest'
|
16
|
-
require 'vcr'
|
17
|
-
|
18
|
-
VCR.configure do |c|
|
19
|
-
c.cassette_library_dir = "test/fixtures"
|
20
|
-
c.hook_into :webmock
|
21
|
-
c.ignore_hosts 'codeclimate.com'
|
1
|
+
#test/test_helper.rb
|
2
|
+
require 'simplecov'
|
3
|
+
require 'coveralls'
|
4
|
+
require 'codeclimate-test-reporter'
|
5
|
+
|
6
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
7
|
+
SimpleCov::Formatter::HTMLFormatter,
|
8
|
+
Coveralls::SimpleCov::Formatter,
|
9
|
+
CodeClimate::TestReporter::Formatter
|
10
|
+
])
|
11
|
+
SimpleCov.start
|
12
|
+
|
13
|
+
require_relative '../lib/mtg_sdk'
|
14
|
+
require 'minitest/autorun'
|
15
|
+
require 'webmock/minitest'
|
16
|
+
require 'vcr'
|
17
|
+
|
18
|
+
VCR.configure do |c|
|
19
|
+
c.cassette_library_dir = "test/fixtures"
|
20
|
+
c.hook_into :webmock
|
21
|
+
c.ignore_hosts 'codeclimate.com'
|
22
22
|
end
|
data/test/type_test.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class TypeTest < Minitest::Test
|
4
|
-
def test_all_returns_all_types
|
5
|
-
VCR.use_cassette('all_types') do
|
6
|
-
types = MTG::Type.all
|
7
|
-
|
8
|
-
assert types.length > 10
|
9
|
-
assert types.any? {|type| type == 'Creature'}
|
10
|
-
end
|
11
|
-
end
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class TypeTest < Minitest::Test
|
4
|
+
def test_all_returns_all_types
|
5
|
+
VCR.use_cassette('all_types') do
|
6
|
+
types = MTG::Type.all
|
7
|
+
|
8
|
+
assert types.length > 10
|
9
|
+
assert types.any? {|type| type == 'Creature'}
|
10
|
+
end
|
11
|
+
end
|
12
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mtg_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Backes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -244,6 +244,8 @@ files:
|
|
244
244
|
- test/card_test.rb
|
245
245
|
- test/changelog_test.rb
|
246
246
|
- test/configuration_test.rb
|
247
|
+
- test/responses/no_cards.json
|
248
|
+
- test/responses/sample_cards.json
|
247
249
|
- test/set_test.rb
|
248
250
|
- test/subtype_test.rb
|
249
251
|
- test/supertype_test.rb
|
@@ -269,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
269
271
|
version: '0'
|
270
272
|
requirements: []
|
271
273
|
rubyforge_project:
|
272
|
-
rubygems_version: 2.5.1
|
274
|
+
rubygems_version: 2.4.5.1
|
273
275
|
signing_key:
|
274
276
|
specification_version: 4
|
275
277
|
summary: 'Magic: The Gathering SDK for magicthegathering.io'
|
@@ -277,6 +279,8 @@ test_files:
|
|
277
279
|
- test/card_test.rb
|
278
280
|
- test/changelog_test.rb
|
279
281
|
- test/configuration_test.rb
|
282
|
+
- test/responses/no_cards.json
|
283
|
+
- test/responses/sample_cards.json
|
280
284
|
- test/set_test.rb
|
281
285
|
- test/subtype_test.rb
|
282
286
|
- test/supertype_test.rb
|