backpack_tf 0.5.0 → 0.8.0

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.
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module BackpackTF
4
-
5
- class Dummy
6
- include BackpackTF::Finder
7
- end
8
-
9
- shared_examples 'Finder' do
10
- let(:dummy) { Dummy.new }
11
-
12
- it 'responds to these inherited class methods' do
13
- expect(Dummy).to respond_to(:get_item_price, :defindex_to_item_name, :find_item_by_name, :is_item_of_type?, :get_name_of_random_item)
14
- end
15
-
16
- end
17
-
18
- describe Prices do
19
- it_behaves_like 'Finder'
20
- end
21
-
22
- describe Item do
23
- it_behaves_like 'Finder'
24
- end
25
-
26
- describe ItemPrice do
27
- it_behaves_like 'Finder'
28
- end
29
-
30
- end
@@ -1,130 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module BackpackTF
4
- describe 'Prices' do
5
-
6
- let(:bp) { Client.new }
7
-
8
- let(:json_obj) {
9
- fixture = file_fixture('prices.json')
10
- fixture = JSON.parse(fixture)['response']
11
- Response.hash_keys_to_sym(fixture)
12
- }
13
-
14
- it 'responds to these methods' do
15
- expect(Prices).to respond_to :responses, :response, :items, :interface, :hash_keys_to_sym
16
- end
17
-
18
- it 'has these default attributes' do
19
- expect(Prices.interface).to eq :IGetPrices
20
- end
21
-
22
- describe '::responses' do
23
-
24
- before :each do
25
- stub_http_response_with('prices.json')
26
- opts = { :app_id => 440, :compress => 1 }
27
- fetched_prices = bp.fetch(:prices, opts)
28
- Response.responses(Prices.to_sym => fetched_prices)
29
- end
30
-
31
- context 'access from Response class' do
32
- it "Prices can be accessed by calling the key, Prices" do
33
- expect(Response.responses[Prices.to_sym]).to eq json_obj
34
- end
35
- end
36
-
37
- context "access from Prices class" do
38
- it 'can access response information via the class method, ::response' do
39
- expect(Prices.response).to eq json_obj
40
- end
41
- end
42
-
43
- it "is the same as calling Prices.response" do
44
- expect(Response.responses[Prices.to_sym]).to eq Prices.response
45
- end
46
- end
47
-
48
- describe '::response' do
49
-
50
- before :each do
51
- stub_http_response_with('prices.json')
52
- opts = { :app_id => 440, :compress => 1 }
53
- fetched_prices = bp.fetch(:prices, opts)
54
- Response.responses(Prices.to_sym => fetched_prices)
55
- end
56
-
57
- it 'the response attribute should have these keys' do
58
- expect(Prices.response.keys).to match_array [:success, :current_time, :raw_usd_value, :usd_currency, :usd_currency_index, :items]
59
- end
60
-
61
- it 'the keys of the response attribute should have these values' do
62
- expect(Prices.response[:success]).to eq 1
63
- expect(Prices.response[:message]).to eq nil
64
- expect(Prices.response[:current_time]).to eq 1430785805
65
- expect(Prices.response[:raw_usd_value]).to eq 0.115
66
- expect(Prices.response[:usd_currency]).to eq 'metal'
67
- expect(Prices.response[:usd_currency_index]).to eq 5002
68
- end
69
-
70
- end
71
-
72
- describe '::items' do
73
-
74
- before :each do
75
- Response.responses(:reset => :confirm)
76
- expect(Response.responses).to be_empty
77
-
78
- stub_http_response_with('prices.json')
79
- opts = { :app_id => 440, :compress => 1 }
80
- fetched_prices = bp.fetch(:prices, opts)
81
- Response.responses(Prices => fetched_prices)
82
- end
83
-
84
- it 'returns the fixture and sets to @@items variable' do
85
- expect(Prices.items).not_to be_nil
86
- end
87
-
88
- context '@@items attribute' do
89
- it 'should be a Hash object' do
90
- expect(Prices.items).to be_instance_of Hash
91
- end
92
- xit 'should have this many keys' do
93
- expect(Prices.items.keys.length).to be 1661
94
- end
95
- it 'each key should be a String' do
96
- expect(Prices.items.keys).to all be_a String
97
- end
98
- it 'each value should be an Item' do
99
- expect(Prices.items.values).to all be_an Item
100
- end
101
- end
102
-
103
- context 'using keys to generate Item objects' do
104
- let(:random_key) { Prices.items.keys.sample }
105
- let(:item) { Prices.items[random_key] }
106
-
107
- it 'generates an Item object' do
108
- expect(item).to be_instance_of Item
109
- end
110
- it 'the Item object responds to these methods' do
111
- expect(item).to respond_to :item_name, :defindex, :prices
112
- end
113
- it 'uses the key to assign a value to the @item_name property of the Item' do
114
- expect(random_key).to eq item.item_name
115
- end
116
- it 'passes itself to be stored in the @prices attribute of the Item object' do
117
- expect(Prices.items[random_key].prices).to eq item.prices
118
- end
119
- end
120
-
121
- end
122
-
123
- describe 'instances of Prices' do
124
- it 'raises an error when trying to instantiate this class' do
125
- expect{Prices.new}.to raise_error RuntimeError
126
- end
127
- end
128
-
129
- end
130
- end