mtg_sdk 3.2.0 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,82 +1,82 @@
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.color_identity.any?{|color_id| color_id == 'B'}
15
- assert card.types.any?{|type| type == 'Sorcery'}
16
- assert card.subtypes.any?{|subtype| subtype == 'Arcane'}
17
- assert_equal 'Rare', card.rarity
18
- assert_equal 'SOK', card.set
19
- assert_equal 'Saviors of Kamigawa', card.set_name
20
- 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
21
- assert_equal "\"Life is a series of choices between bad and worse.\"\n—Toshiro Umezawa", card.flavor
22
- assert_equal 'Tim Hildebrandt', card.artist
23
- assert_equal '62', card.number
24
- assert_equal 'normal', card.layout
25
- assert_equal 88803, card.multiverse_id
26
- assert_equal 'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=88803&type=card', card.image_url
27
- assert card.rulings.any?{|ruling| ruling.date == Date.parse('2005-06-01')}
28
- 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'}
29
- assert card.printings.any?{|printing| printing == 'SOK'}
30
- 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
31
- assert_equal 'Sorcery — Arcane', card.original_type
32
- assert card.legalities.any?{|legality| legality.format == 'Commander' && legality.legality == 'Legal'}
33
- assert_equal '1c4aab072d52d283e902f2302afa255b39e0794b', card.id
34
- end
35
- end
36
-
37
- def test_find_with_invalid_id_throws_exception
38
- VCR.use_cassette('invalid_id') do
39
- assert_raises ArgumentError do
40
- MTG::Card.find(3239482932)
41
- end
42
- end
43
- end
44
-
45
- def test_where_with_page_size_and_page_returns_cards
46
- VCR.use_cassette('query_cards_pageSize') do
47
- cards = MTG::Card.where(pageSize: 10).where(page: 1).all
48
-
49
- # make sure we got only 10 cards back
50
- assert cards.length == 10
51
- assert cards.kind_of?(Array)
52
- assert cards.first.kind_of?(MTG::Card)
53
- end
54
- end
55
-
56
- def test_all_returns_cards
57
- VCR.use_cassette('all_filtered') do
58
- cards = MTG::Card.where(supertypes: 'legendary')
59
- .where(subtypes: 'elf,warrior')
60
- .all
61
-
62
- first_card = cards[0]
63
- assert first_card.supertypes.include? 'Legendary'
64
- assert first_card.subtypes.include? 'Elf'
65
- assert first_card.subtypes.include? 'Warrior'
66
- end
67
- end
68
-
69
- def test_all_returns_all_cards
70
- VCR.use_cassette('all_cards') do
71
- stub_request(:any, "https://api.magicthegathering.io/v1/cards").
72
- to_return(:body => File.new('test/responses/sample_cards.json'), :status => 200, :headers => {"Content-Type"=> "application/json"})
73
-
74
- stub_request(:any, "https://api.magicthegathering.io/v1/cards?page=2").
75
- to_return(:body => File.new('test/responses/no_cards.json'), :status => 200, :headers => {"Content-Type"=> "application/json"})
76
-
77
- cards = MTG::Card.all
78
-
79
- assert_equal 2, cards.length
80
- end
81
- end
82
- 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.color_identity.any?{|color_id| color_id == 'B'}
15
+ assert card.types.any?{|type| type == 'Sorcery'}
16
+ assert card.subtypes.any?{|subtype| subtype == 'Arcane'}
17
+ assert_equal 'Rare', card.rarity
18
+ assert_equal 'SOK', card.set
19
+ assert_equal 'Saviors of Kamigawa', card.set_name
20
+ 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
21
+ assert_equal "\"Life is a series of choices between bad and worse.\"\n—Toshiro Umezawa", card.flavor
22
+ assert_equal 'Tim Hildebrandt', card.artist
23
+ assert_equal '62', card.number
24
+ assert_equal 'normal', card.layout
25
+ assert_equal 88803, card.multiverse_id
26
+ assert_equal 'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=88803&type=card', card.image_url
27
+ assert card.rulings.any?{|ruling| ruling.date == Date.parse('2005-06-01')}
28
+ 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'}
29
+ assert card.printings.any?{|printing| printing == 'SOK'}
30
+ 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
31
+ assert_equal 'Sorcery — Arcane', card.original_type
32
+ assert card.legalities.any?{|legality| legality.format == 'Commander' && legality.legality == 'Legal'}
33
+ assert_equal '1c4aab072d52d283e902f2302afa255b39e0794b', card.id
34
+ end
35
+ end
36
+
37
+ def test_find_with_invalid_id_throws_exception
38
+ VCR.use_cassette('invalid_id') do
39
+ assert_raises ArgumentError do
40
+ MTG::Card.find(3239482932)
41
+ end
42
+ end
43
+ end
44
+
45
+ def test_where_with_page_size_and_page_returns_cards
46
+ VCR.use_cassette('query_cards_pageSize') do
47
+ cards = MTG::Card.where(pageSize: 10).where(page: 1).all
48
+
49
+ # make sure we got only 10 cards back
50
+ assert cards.length == 10
51
+ assert cards.kind_of?(Array)
52
+ assert cards.first.kind_of?(MTG::Card)
53
+ end
54
+ end
55
+
56
+ def test_all_returns_cards
57
+ VCR.use_cassette('all_filtered') do
58
+ cards = MTG::Card.where(supertypes: 'legendary')
59
+ .where(subtypes: 'elf,warrior')
60
+ .all
61
+
62
+ first_card = cards[0]
63
+ assert first_card.supertypes.include? 'Legendary'
64
+ assert first_card.subtypes.include? 'Elf'
65
+ assert first_card.subtypes.include? 'Warrior'
66
+ end
67
+ end
68
+
69
+ def test_all_returns_all_cards
70
+ VCR.use_cassette('all_cards') do
71
+ stub_request(:any, "https://api.magicthegathering.io/v1/cards").
72
+ to_return(:body => File.new('test/responses/sample_cards.json'), :status => 200, :headers => {"Content-Type"=> "application/json"})
73
+
74
+ stub_request(:any, "https://api.magicthegathering.io/v1/cards?page=2").
75
+ to_return(:body => File.new('test/responses/no_cards.json'), :status => 200, :headers => {"Content-Type"=> "application/json"})
76
+
77
+ cards = MTG::Card.all
78
+
79
+ assert_equal 2, cards.length
80
+ end
81
+ end
82
+ end
@@ -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
@@ -1,20 +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
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
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
20
20
  end
@@ -1,52 +1,64 @@
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
52
- end
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
52
+
53
+ def test_service_unavailable
54
+ VCR.use_cassette('service_unavailable') do
55
+ assert_raises ArgumentError, "Unavailable Service" do
56
+ MTG::Set.find('ktk')
57
+ end
58
+
59
+ assert_raises ArgumentError, "Unavailable Service" do
60
+ MTG::Set.all
61
+ end
62
+ end
63
+ end
64
+ end
@@ -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
@@ -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
@@ -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
@@ -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