backpack_tf 0.8.1 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/backpack_tf.gemspec +4 -4
- data/lib/backpack_tf/assets/attribute_controlled_attached_particles.json +667 -0
- data/lib/backpack_tf/client.rb +5 -5
- data/lib/backpack_tf/item.rb +29 -19
- data/lib/backpack_tf/item_price.rb +100 -16
- data/lib/backpack_tf/response.rb +3 -0
- data/lib/backpack_tf/version.rb +1 -1
- data/spec/backpack_tf/client_spec.rb +7 -0
- data/spec/backpack_tf/currency_spec.rb +62 -58
- data/spec/backpack_tf/inherited_class_methods_spec.rb +100 -0
- data/spec/backpack_tf/item_price_spec.rb +106 -42
- data/spec/backpack_tf/item_spec.rb +89 -128
- data/spec/backpack_tf/price_spec.rb +7 -22
- data/spec/backpack_tf/response_spec.rb +16 -3
- data/spec/backpack_tf/special_item_spec.rb +34 -29
- data/spec/backpack_tf/user_listing_spec.rb +22 -24
- data/spec/backpack_tf/user_spec.rb +28 -30
- data/spec/fixtures/item_crate.json +65 -0
- data/spec/fixtures/item_typical.json +1 -1
- data/spec/fixtures/item_unusual.json +1 -1
- data/spec/fixtures/item_with_unconventional_structure.json +1 -1
- data/spec/fixtures/item_without_defindex.json +1 -1
- data/spec/spec_helper.rb +47 -0
- metadata +9 -24
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module BackpackTF
|
4
|
+
|
5
|
+
shared_examples 'a class inheriting methods from Response' do |file|
|
6
|
+
let(:bp) { Client.new }
|
7
|
+
let(:json_obj) {
|
8
|
+
fixture = file_fixture(file)
|
9
|
+
fixture = JSON.parse(fixture)['response']
|
10
|
+
Response.hash_keys_to_sym(fixture)
|
11
|
+
}
|
12
|
+
|
13
|
+
before :all do
|
14
|
+
mock_alias
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should respond to these inherited methods' do
|
18
|
+
expect(described_class).to respond_to :responses, :interface, :to_sym, :hash_keys_to_sym
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should respond to this aliased method (for testing only)' do
|
22
|
+
expect(described_class).to respond_to :data_storage
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '::to_sym' do
|
26
|
+
it 'returns a Symbol of the name of the name of the class' do
|
27
|
+
expect(described_class.to_sym).to eq described_class.to_s.to_sym
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '::responses' do
|
32
|
+
before :all do
|
33
|
+
expect(Response.responses).to be_empty
|
34
|
+
end
|
35
|
+
|
36
|
+
after :all do
|
37
|
+
Response.responses(:reset => :confirm)
|
38
|
+
expect(Response.responses).to be_empty
|
39
|
+
expect(described_class.response).to be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it "Response class can access response for #{described_class} by calling the key #{described_class}" do
|
43
|
+
stub_http_response_with(file)
|
44
|
+
fetched_data = bp.fetch(make_fetch_sym)
|
45
|
+
bp.update(described_class, fetched_data)
|
46
|
+
expect(Response.responses[described_class.to_sym]).to eq json_obj
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '::response' do
|
51
|
+
before :all do
|
52
|
+
expect(described_class.response).to be_nil
|
53
|
+
end
|
54
|
+
|
55
|
+
before :each do
|
56
|
+
stub_http_response_with(file)
|
57
|
+
fetched_data = bp.fetch(make_fetch_sym)
|
58
|
+
bp.update(described_class, fetched_data)
|
59
|
+
end
|
60
|
+
|
61
|
+
after :all do
|
62
|
+
Response.responses(:reset => :confirm)
|
63
|
+
expect(Response.responses).to be_empty
|
64
|
+
expect(described_class.response).to be_nil
|
65
|
+
expect(described_class.data_storage).to be_nil
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'can access response information' do
|
69
|
+
expect(described_class.response).to eq json_obj
|
70
|
+
end
|
71
|
+
|
72
|
+
it "returns same info as the Response class calling Price key" do
|
73
|
+
result = Response.responses[described_class.to_sym]
|
74
|
+
expect(described_class.response).to eq result
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
describe Price do
|
81
|
+
it_behaves_like('a class inheriting methods from Response', 'prices.json')
|
82
|
+
end
|
83
|
+
|
84
|
+
describe Currency do
|
85
|
+
it_behaves_like('a class inheriting methods from Response', 'currencies.json')
|
86
|
+
end
|
87
|
+
|
88
|
+
describe SpecialItem do
|
89
|
+
it_behaves_like('a class inheriting methods from Response', 'special_items.json')
|
90
|
+
end
|
91
|
+
|
92
|
+
describe User do
|
93
|
+
it_behaves_like('a class inheriting methods from Response', 'users.json')
|
94
|
+
end
|
95
|
+
|
96
|
+
describe UserListing do
|
97
|
+
it_behaves_like('a class inheriting methods from Response', 'user_listing.json')
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -1,53 +1,117 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module BackpackTF
|
4
|
-
describe
|
5
|
-
describe 'instance of ItemPrice' do
|
6
|
-
context "A typical item that does NOT have the quality 'Unusual'" do
|
7
|
-
let(:item_price_key) { 'Unique_Tradable_Craftable' }
|
8
|
-
let(:item_price_attr) { '{"currency":"metal","value":0.05,"last_update":1336410088,"difference":0}' }
|
9
|
-
let (:item_price) { ItemPrice.new(item_price_key, item_price_attr) }
|
4
|
+
describe ItemPrice do
|
10
5
|
|
11
|
-
|
12
|
-
|
6
|
+
describe '::quality_name_to_index' do
|
7
|
+
it 'returns Quality Index of the name of Quality' do
|
8
|
+
expect(described_class.quality_name_to_index('Strange')).to eq 11
|
9
|
+
end
|
10
|
+
it 'returns nil when you ask for index of `nil`' do
|
11
|
+
expect(described_class.quality_name_to_index(nil)).to be_nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '::hash_particle_effects' do
|
16
|
+
it 'creates a key value pair for each id & name' do
|
17
|
+
expect(described_class.hash_particle_effects[17]).to eq 'Sunbeams'
|
18
|
+
expect(described_class.hash_particle_effects[5]).to eq 'Holy Glow'
|
19
|
+
end
|
20
|
+
it 'is nil if it cannot find that key' do
|
21
|
+
expect(described_class.hash_particle_effects[nil]).to be_nil
|
22
|
+
end
|
23
|
+
|
24
|
+
context '@@particle_effects' do
|
25
|
+
it 'same thing can be accessed through class variable' do
|
26
|
+
expect(described_class.particle_effects[17]).to eq 'Sunbeams'
|
27
|
+
expect(described_class.particle_effects[5]).to eq 'Holy Glow'
|
28
|
+
end
|
29
|
+
it 'is nil if it cannot find that key' do
|
30
|
+
expect(described_class.particle_effects[nil]).to be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#initialize' do
|
36
|
+
base_json = JSON.parse(file_fixture('item_typical.json'))['Kritzkrieg']
|
37
|
+
ok_json = base_json['prices']['6']['Tradable']['Craftable'][0]
|
38
|
+
wrong_level = base_json['prices']['6']['Tradable']
|
39
|
+
|
40
|
+
context 'validating first parameter' do
|
41
|
+
|
42
|
+
it 'will raise ArgumentError if there is not enough information' do
|
43
|
+
expect{described_class.new('Unique_Tradable', ok_json)}.to raise_error ArgumentError
|
44
|
+
end
|
45
|
+
it 'will raise NameError if any one of the info bits is incorrect' do
|
46
|
+
expect{described_class.new('xx_Tradable_Craftable', ok_json)}.to raise_error NameError
|
47
|
+
end
|
48
|
+
it 'will raise a NameError if name has correct info but is out of order' do
|
49
|
+
expect{described_class.new('Craftable_Tradable_Strange', ok_json)}.to raise_error NameError
|
50
|
+
end
|
51
|
+
end
|
52
|
+
context 'validating 2nd parameter' do
|
53
|
+
it 'will raise a KeyError if JSON does not have required keys' do
|
54
|
+
expect{described_class.new('Unique_Tradable_Craftable', wrong_level)}.to raise_error KeyError
|
13
55
|
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
shared_examples 'an ItemPrice object' do
|
60
|
+
it 'should respond to these methods' do
|
61
|
+
expect(subject).to respond_to :quality, :tradability, :craftability, :priceindex, :currency, :value, :value_high, :value_raw, :value_high_raw, :last_update, :difference
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'A price for a typical item' do
|
66
|
+
item_price_attr = JSON.parse(file_fixture('item_typical.json'))['Kritzkrieg']['prices']['6']['Tradable']['Craftable'][0]
|
67
|
+
|
68
|
+
subject {
|
69
|
+
described_class.new('Unique_Tradable_Craftable', item_price_attr)
|
70
|
+
}
|
71
|
+
|
72
|
+
it_behaves_like('an ItemPrice object')
|
73
|
+
|
74
|
+
context 'item-specific tests' do
|
14
75
|
it 'should have these values' do
|
15
|
-
expect(
|
16
|
-
expect(
|
17
|
-
expect(
|
18
|
-
expect(
|
19
|
-
expect(
|
20
|
-
expect(
|
21
|
-
expect(
|
22
|
-
expect(
|
23
|
-
expect(
|
24
|
-
expect(
|
25
|
-
expect(
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
context "An item with the quality 'Unusual'" do
|
30
|
-
# the Unusual item being tested is the 'Barnstormer'
|
31
|
-
let(:item_price_key) { 'Unusual_Tradable_Craftable' }
|
32
|
-
#let(:item_price_attr) {'{"6":{"currency":"keys","value":18,"last_update":1418795322,"difference":280,"value_high":22}}'}
|
33
|
-
let(:item_price_attr) {'{"currency":"keys","value":18,"last_update":1418795322,"difference":280,"value_high":22}'}
|
34
|
-
let(:item_price) { ItemPrice.new(item_price_key, item_price_attr, 6) }
|
35
|
-
|
36
|
-
it 'should respond to these methods' do
|
37
|
-
expect(item_price).to respond_to :quality, :tradability, :craftability, :priceindex, :currency, :value, :value_high, :value_raw, :value_high_raw, :last_update, :difference
|
76
|
+
expect(subject.quality).to eq :Unique
|
77
|
+
expect(subject.tradability).to eq :Tradable
|
78
|
+
expect(subject.craftability).to eq :Craftable
|
79
|
+
expect(subject.currency).to eq :metal
|
80
|
+
expect(subject.value).to eq 0.05
|
81
|
+
expect(subject.value_high).to be_nil
|
82
|
+
expect(subject.value_raw).to be_nil
|
83
|
+
expect(subject.value_high_raw).to be_nil
|
84
|
+
expect(subject.last_update).to eq 1336410088
|
85
|
+
expect(subject.difference).to eq 0
|
86
|
+
expect(subject.priceindex).to be_nil
|
87
|
+
expect(subject.effect).to be_nil
|
38
88
|
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "A price for an item with 'Unusual' quality" do
|
93
|
+
item_price_attr = JSON.parse(file_fixture('item_unusual.json'))['Barnstormer']['prices']['5']['Tradable']['Craftable']['6']
|
94
|
+
|
95
|
+
subject {
|
96
|
+
described_class.new('Unusual_Tradable_Craftable', item_price_attr, 6)
|
97
|
+
}
|
98
|
+
|
99
|
+
it_behaves_like('an ItemPrice object')
|
100
|
+
|
101
|
+
context 'item-specific tests' do
|
39
102
|
it 'should have these values' do
|
40
|
-
expect(
|
41
|
-
expect(
|
42
|
-
expect(
|
43
|
-
expect(
|
44
|
-
expect(
|
45
|
-
expect(
|
46
|
-
expect(
|
47
|
-
expect(
|
48
|
-
expect(
|
49
|
-
expect(
|
50
|
-
expect(
|
103
|
+
expect(subject.quality).to eq :Unusual
|
104
|
+
expect(subject.tradability).to eq :Tradable
|
105
|
+
expect(subject.craftability).to eq :Craftable
|
106
|
+
expect(subject.currency).to eq :keys
|
107
|
+
expect(subject.value).to eq 18
|
108
|
+
expect(subject.value_high).to eq 22
|
109
|
+
expect(subject.value_raw).to be_nil
|
110
|
+
expect(subject.value_high_raw).to be_nil
|
111
|
+
expect(subject.last_update).to eq 1418795322
|
112
|
+
expect(subject.difference).to eq 280
|
113
|
+
expect(subject.priceindex).to eq 6
|
114
|
+
expect(subject.effect).to eq 'Green Confetti'
|
51
115
|
end
|
52
116
|
end
|
53
117
|
end
|
@@ -1,165 +1,126 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module BackpackTF
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
describe Item do
|
5
|
+
shared_examples 'a common item' do |passed_item_attr|
|
6
|
+
it 'should respond to these methods' do
|
7
|
+
expect(subject).to respond_to :item_name, :defindex, :prices, :generate_prices_hash
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
let(:item_name) { 'Kritzkrieg' }
|
12
|
-
let(:stub) do
|
13
|
-
JSON.parse '{"defindex":[35],"prices":{"11":{"Tradable":{"Craftable":[{"currency":"keys","value":18,"last_update":1430665867,"difference":-18.495}]}},"14":{"Tradable":{"Craftable":[{"currency":"keys","value":9,"last_update":1416841372,"difference":11.385}]}},"3":{"Tradable":{"Craftable":[{"currency":"metal","value":0.66,"last_update":1426439779,"difference":0.33}]}},"6":{"Tradable":{"Craftable":[{"currency":"metal","value":0.05,"last_update":1336410088,"difference":0}],"Non-Craftable":[{"currency":"metal","value":0.05,"last_update":1362791812,"difference":0.03}]}}}}'
|
14
|
-
end
|
15
|
-
let(:item) { Item.new(item_name, stub) }
|
16
|
-
let(:prices_hash) { item.gen_prices_hash(stub) }
|
10
|
+
describe '#generate_prices_hash' do
|
11
|
+
let(:prices_hash) { subject.generate_prices_hash(passed_item_attr) }
|
17
12
|
|
18
|
-
it '
|
19
|
-
expect(
|
13
|
+
it 'generates a Hash' do
|
14
|
+
expect(prices_hash).to be_instance_of Hash
|
20
15
|
end
|
21
|
-
|
22
|
-
|
23
|
-
expect(item.item_name).to eq 'Kritzkrieg'
|
24
|
-
expect(item.defindex).to eq 35
|
16
|
+
it 'each key is a String' do
|
17
|
+
expect(prices_hash.keys).to all be_a String
|
25
18
|
end
|
26
|
-
|
27
|
-
|
28
|
-
it 'generates a Hash' do
|
29
|
-
expect(prices_hash).to be_instance_of Hash
|
30
|
-
end
|
31
|
-
it 'each key is a String' do
|
32
|
-
expect(prices_hash.keys).to all be_a String
|
33
|
-
end
|
34
|
-
it 'includes these keys' do
|
35
|
-
prices_hash.keys.each{ |key| expect(expected_keys).to include(key) }
|
36
|
-
end
|
37
|
-
it 'value of each key is an ItemPrice object' do
|
38
|
-
expect(prices_hash.values).to all be_an ItemPrice
|
39
|
-
end
|
19
|
+
it 'value of each key is an ItemPrice object' do
|
20
|
+
expect(prices_hash.values).to all be_an ItemPrice
|
40
21
|
end
|
22
|
+
end
|
41
23
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
xit 'has all of these keys' do
|
50
|
-
expect(item.prices.keys).to eq expected_keys
|
51
|
-
end
|
52
|
-
it 'each value is an ItemPrice object' do
|
53
|
-
expect(item.prices.values).to all be_an ItemPrice
|
54
|
-
end
|
24
|
+
describe 'the @prices instance variable' do
|
25
|
+
it 'is a Hash' do
|
26
|
+
expect(subject.prices).to be_a Hash
|
27
|
+
end
|
28
|
+
it 'each value is an ItemPrice object' do
|
29
|
+
expect(subject.prices.values).to all be_an ItemPrice
|
55
30
|
end
|
56
31
|
end
|
32
|
+
end
|
57
33
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
34
|
+
describe 'A typical item' do
|
35
|
+
item_attr = JSON.parse(file_fixture('item_typical.json'))['Kritzkrieg']
|
36
|
+
item = described_class.new('Kritzkrieg', item_attr)
|
37
|
+
subject { item }
|
38
|
+
it_behaves_like('a common item', item_attr)
|
63
39
|
|
64
|
-
|
65
|
-
|
40
|
+
context 'item-specific tests' do
|
41
|
+
it 'should have these values' do
|
42
|
+
expect(subject.item_name).to eq 'Kritzkrieg'
|
43
|
+
expect(subject.defindex).to eq 35
|
66
44
|
end
|
45
|
+
xit '@prices should have these keys' do
|
46
|
+
ans = ['Strange_Tradable_Craftable',
|
47
|
+
"Collector's_Tradable_Craftable",
|
48
|
+
'Vintage_Tradable_Craftable',
|
49
|
+
'Unique_Tradable_Craftable',
|
50
|
+
'Unique_Tradable_Non-Craftable']
|
51
|
+
expect(subject.prices.keys).to match_array ans
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "An item with the quality of 'Unusual'" do
|
57
|
+
item_attr = JSON.parse(file_fixture('item_unusual.json'))['Barnstormer']
|
58
|
+
item = described_class.new('Barnstormer', item_attr)
|
59
|
+
subject { item }
|
60
|
+
it_behaves_like('a common item', item_attr)
|
61
|
+
|
62
|
+
context 'item-specific tests' do
|
67
63
|
it 'should have these values' do
|
68
64
|
expect(item.item_name).to eq 'Barnstormer'
|
69
65
|
expect(item.defindex).to eq 988
|
70
66
|
end
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
expect(prices_hash).to be_instance_of Hash
|
75
|
-
end
|
76
|
-
it 'each key is a String' do
|
77
|
-
expect(prices_hash.keys).to all be_a String
|
78
|
-
end
|
79
|
-
it 'value of each key is an ItemPrice object' do
|
80
|
-
expect(prices_hash.values).to all be_an ItemPrice
|
81
|
-
end
|
82
|
-
end
|
83
|
-
describe 'the @prices instance variable' do
|
84
|
-
it 'is a Hash' do
|
85
|
-
expect(item.prices).to be_a Hash
|
86
|
-
end
|
87
|
-
it 'each value is an ItemPrice object' do
|
88
|
-
expect(item.prices.values).to all be_an ItemPrice
|
89
|
-
end
|
67
|
+
it '@prices should have these keys' do
|
68
|
+
priceindex_vals = ["Aces High", "Anti-Freeze", "Blizzardy Storm", "Bubbling", "Burning Flames", "Circling Heart", "Circling TF Logo", "Cloud 9", "Dead Presidents", "Death at Dusk", "Disco Beat Down", "Electrostatic", "Green Black Hole", "Green Confetti", "Green Energy", "Haunted Ghosts", "Kill-a-Watt", "Memory Leak", "Miami Nights", "Morning Glory", "Nuts n' Bolts", "Orbiting Fire", "Orbiting Planets", "Overclocked", "Phosphorous", "Power Surge", "Purple Confetti", "Purple Energy", "Roboactive", "Scorching Flames", "Smoking", "Steaming", "Stormy Storm", "Sulphurous", "Terror-Watt", "Time Warp", "Unique_Tradable_Craftable"]
|
69
|
+
expect(subject.prices.keys).to match_array priceindex_vals
|
90
70
|
end
|
91
71
|
end
|
72
|
+
end
|
92
73
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
74
|
+
describe 'An item with many priceindex values (Crate or Unusual)' do
|
75
|
+
item_attr = JSON.parse(file_fixture('item_crate.json'))['Mann Co. Supply Munition']
|
76
|
+
item = described_class.new('Mann Co. Supply Munition', item_attr)
|
77
|
+
subject { item }
|
78
|
+
it_behaves_like('a common item', item_attr)
|
98
79
|
|
99
|
-
|
100
|
-
expect(item).to respond_to :item_name, :defindex, :prices, :gen_prices_hash
|
101
|
-
end
|
80
|
+
context 'item-specific tests' do
|
102
81
|
it 'should have these values' do
|
103
|
-
expect(
|
104
|
-
expect(
|
82
|
+
expect(subject.item_name).to eq 'Mann Co. Supply Munition'
|
83
|
+
expect(subject.defindex).to match_array [5734, 5735, 5742, 5752, 5781, 5802, 5803]
|
84
|
+
end
|
85
|
+
it 'prices array should have these keys' do
|
86
|
+
ans = ['Unique_Tradable_Craftable_#82',
|
87
|
+
'Unique_Tradable_Craftable_#83',
|
88
|
+
'Unique_Tradable_Craftable_#84',
|
89
|
+
'Unique_Tradable_Craftable_#85',
|
90
|
+
'Unique_Tradable_Craftable_#90',
|
91
|
+
'Unique_Tradable_Craftable_#91',
|
92
|
+
'Unique_Tradable_Craftable_#92']
|
93
|
+
expect(subject.prices.keys).to match_array ans
|
105
94
|
end
|
95
|
+
end
|
96
|
+
end
|
106
97
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
end
|
118
|
-
describe 'the @prices instance variable' do
|
119
|
-
it 'is a Hash' do
|
120
|
-
expect(item.prices).to be_a Hash
|
121
|
-
end
|
122
|
-
it 'each value is an ItemPrice object' do
|
123
|
-
expect(item.prices.values).to all be_an ItemPrice
|
124
|
-
end
|
98
|
+
describe 'An item with an unconventional structure' do
|
99
|
+
item_attr = JSON.parse(file_fixture('item_with_unconventional_structure.json'))['Aqua Summer 2013 Cooler']
|
100
|
+
item = described_class.new('Aqua Summer 2013 Cooler', item_attr)
|
101
|
+
subject { item }
|
102
|
+
it_behaves_like('a common item', item_attr)
|
103
|
+
|
104
|
+
context 'item-specific tests' do
|
105
|
+
it 'should have these values' do
|
106
|
+
expect(item.item_name).to eq 'Aqua Summer 2013 Cooler'
|
107
|
+
expect(item.defindex).to eq 5650
|
125
108
|
end
|
126
109
|
end
|
110
|
+
end
|
127
111
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
112
|
+
describe "An item that has a negative 'defindex' or no 'defindex' at all" do
|
113
|
+
item_attr = JSON.parse(file_fixture('item_without_defindex.json'))['Strange Part: Fires Survived']
|
114
|
+
item = described_class.new('Strange Part: Fires Survived', item_attr)
|
115
|
+
subject { item }
|
116
|
+
it_behaves_like('a common item', item_attr)
|
133
117
|
|
134
|
-
|
135
|
-
expect(item).to respond_to :item_name, :defindex, :prices, :gen_prices_hash
|
136
|
-
end
|
118
|
+
context 'item-specific tests' do
|
137
119
|
it 'should have these values' do
|
138
120
|
expect(item.item_name).to eq 'Strange Part: Fires Survived'
|
139
121
|
expect(item.defindex).to eq nil
|
140
122
|
end
|
141
|
-
|
142
|
-
describe '#gen_prices_hash' do
|
143
|
-
it 'generates a Hash' do
|
144
|
-
expect(prices_hash).to be_instance_of Hash
|
145
|
-
end
|
146
|
-
it 'each key is a String' do
|
147
|
-
expect(prices_hash.keys).to all be_a String
|
148
|
-
end
|
149
|
-
it 'value of each key is an ItemPrice object' do
|
150
|
-
expect(prices_hash.values).to all be_an ItemPrice
|
151
|
-
end
|
152
|
-
end
|
153
|
-
describe 'the @prices instance variable' do
|
154
|
-
it 'is a Hash' do
|
155
|
-
expect(item.prices).to be_a Hash
|
156
|
-
end
|
157
|
-
it 'each value is an ItemPrice object' do
|
158
|
-
expect(item.prices.values).to all be_an ItemPrice
|
159
|
-
end
|
160
|
-
end
|
161
123
|
end
|
162
|
-
|
163
124
|
end
|
164
125
|
end
|
165
126
|
end
|