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.
@@ -11,10 +11,6 @@ module BackpackTF
11
11
  Response.hash_keys_to_sym(fixture)
12
12
  }
13
13
 
14
- it 'responds to these inherited class methods' do
15
- expect(described_class).to respond_to :responses, :to_sym, :interface, :hash_keys_to_sym
16
- end
17
-
18
14
  it 'has these default attributes' do
19
15
  expect(described_class.interface).to eq :IGetPrices
20
16
  end
@@ -23,37 +19,24 @@ module BackpackTF
23
19
  expect{described_class.new}.to raise_error RuntimeError
24
20
  end
25
21
 
26
- describe '::responses' do
27
- it "Responses class can access Price response by calling Price key" do
28
- stub_http_response_with('prices.json')
29
- fetched_prices = bp.fetch(:prices)
30
- Response.responses(described_class.to_sym => fetched_prices)
31
- expect(Response.responses[described_class.to_sym]).to eq json_obj
22
+ describe '::response' do
23
+ before :all do
24
+ expect(described_class.response).to be_nil
32
25
  end
33
- end
34
26
 
35
- describe '::response' do
36
27
  before :each do
37
28
  stub_http_response_with('prices.json')
38
29
  fetched_prices = bp.fetch(:prices)
39
- Response.responses(described_class.to_sym => fetched_prices)
30
+ bp.update(described_class, fetched_prices)
40
31
  end
41
32
 
42
33
  after :all do
43
34
  Response.responses(:reset => :confirm)
44
35
  expect(Response.responses).to be_empty
45
36
  expect(described_class.response).to be_nil
37
+ expect(described_class.items).to be_nil
46
38
  end
47
39
 
48
- it 'can access response information' do
49
- expect(described_class.response).to eq json_obj
50
- end
51
- it "returns same info as the Response class calling Price key" do
52
- expect(described_class.response).to eq Response.responses[described_class.to_sym]
53
- end
54
- it 'the response attribute should have these keys' do
55
- expect(described_class.response.keys).to match_array [:success, :current_time, :raw_usd_value, :usd_currency, :usd_currency_index, :items]
56
- end
57
40
  it 'the keys of the response attribute should have these values' do
58
41
  response = described_class.response
59
42
  expect(response[:success]).to eq 1
@@ -75,6 +58,7 @@ module BackpackTF
75
58
  after :all do
76
59
  Response.responses(:reset => :confirm)
77
60
  expect(Response.responses).to be_empty
61
+ described_class.class_eval { @items = nil }
78
62
  end
79
63
 
80
64
  it 'each key of hash is a String' do
@@ -99,6 +83,7 @@ module BackpackTF
99
83
  after :all do
100
84
  Response.responses(:reset => :confirm)
101
85
  expect(Response.responses).to be_empty
86
+ described_class.class_eval { @items = nil }
102
87
  end
103
88
 
104
89
  it 'returns the fixture and sets to @@items variable' do
@@ -8,13 +8,13 @@ module BackpackTF
8
8
  let(:json_obj) {
9
9
  fixture = file_fixture('currencies.json')
10
10
  fixture = JSON.parse(fixture)['response']
11
- Response.hash_keys_to_sym(fixture)
11
+ described_class.hash_keys_to_sym(fixture)
12
12
  }
13
13
 
14
14
  let(:more_json) {
15
15
  fixture = file_fixture('currencies_updated.json')
16
16
  fixture = JSON.parse(fixture)['response']
17
- Response.hash_keys_to_sym(fixture)
17
+ described_class.hash_keys_to_sym(fixture)
18
18
  }
19
19
 
20
20
  describe '::interface' do
@@ -32,6 +32,12 @@ module BackpackTF
32
32
  describe '::responses' do
33
33
  let (:faked_class_sym) { :'BackpackTF::FakedClass' }
34
34
 
35
+ after :all do
36
+ Response.responses(:reset => :confirm)
37
+ expect(Response.responses).to be_empty
38
+ expect(described_class.response).to be_nil
39
+ end
40
+
35
41
  it 'returns a Hash object' do
36
42
  expect(Response.responses).to be_instance_of Hash
37
43
  end
@@ -43,7 +49,7 @@ module BackpackTF
43
49
  end
44
50
  end
45
51
 
46
- context 'reset' do
52
+ context 'resetting' do
47
53
  before :each do
48
54
  Response.responses(faked_class_sym => json_obj)
49
55
  expect(Response.responses[faked_class_sym]).to eq json_obj
@@ -96,6 +102,13 @@ module BackpackTF
96
102
  expect(Response.responses).not_to be_nil
97
103
  end
98
104
  end
105
+
106
+ end
107
+
108
+ describe '::response' do
109
+ it "returns nil when called by #{described_class}" do
110
+ expect(described_class.response).to be_nil
111
+ end
99
112
  end
100
113
 
101
114
  describe '::hash_keys_to_sym' do
@@ -10,64 +10,69 @@ module BackpackTF
10
10
  Response.hash_keys_to_sym(fixture)
11
11
  }
12
12
 
13
- it 'responds to these methods' do
14
- expect(described_class).to respond_to :responses, :interface, :hash_keys_to_sym
15
- end
16
-
17
13
  it 'has these default attributes' do
18
14
  expect(described_class.interface).to eq :IGetSpecialItems
19
15
  end
20
16
 
21
- describe '::responses' do
22
- before :each do
23
- stub_http_response_with('special_items.json')
24
- fetched_special_items = bp.fetch(:special_items, {:app_id=>440, :compress=>1})
25
- Response.responses(described_class.to_sym => fetched_special_items)
26
- end
27
- it "SpecialItem can be accessed by calling the key, SpecialItem" do
28
- expect(Response.responses[described_class.to_sym]).to eq json_obj
17
+ describe '::response' do
18
+ before :all do
19
+ expect(described_class.response).to be_nil
29
20
  end
30
- end
31
21
 
32
- describe '::response' do
33
22
  before :each do
34
23
  stub_http_response_with('special_items.json')
35
- fetched_special_items = bp.fetch(:special_items, {:app_id=>440, :compress=>1})
36
- Response.responses(described_class.to_sym => fetched_special_items)
37
- end
38
- it 'can access response information via the class method, ::response' do
39
- expect(described_class.response).to eq json_obj
40
- end
41
- it "returns same results as calling Response.responses[:'BackpackTF::SpecialItem']" do
42
- expect(described_class.response).to eq Response.responses[described_class.to_sym]
24
+ fetched_special_items = bp.fetch(:special_items)
25
+ bp.update(described_class, fetched_special_items)
43
26
  end
44
- it 'the response attribute should have these keys' do
45
- expect(described_class.response.keys).to match_array [:success, :current_time, :items]
27
+
28
+ after :all do
29
+ Response.responses(:reset => :confirm)
30
+ expect(Response.responses).to be_empty
31
+ expect(described_class.response).to be_nil
32
+ expect(described_class.items).to be_nil
46
33
  end
34
+
47
35
  it 'the keys of the response attribute should have these values' do
48
- expect(described_class.response[:success]).to eq 1
49
- expect(described_class.response[:message]).to eq nil
50
- expect(described_class.response[:current_time]).to eq 1431108270
36
+ response = described_class.response
37
+ expect(response[:success]).to eq 1
38
+ expect(response[:message]).to eq nil
39
+ expect(response[:current_time]).to eq 1431108270
51
40
  end
52
41
  end
53
42
 
54
43
  describe '::items' do
44
+ before :all do
45
+ expect(described_class.response).to be_nil
46
+ expect(described_class.items).to be_nil
47
+ end
48
+
55
49
  before :each do
56
50
  Response.responses(:reset => :confirm)
57
51
  expect(Response.responses).to be_empty
52
+
58
53
  stub_http_response_with('special_items.json')
59
- fetched_special_items = bp.fetch(:special_items, {:app_id=>440, :compress=>1})
60
- Response.responses(described_class.to_sym => fetched_special_items)
54
+ fetched_special_items = bp.fetch(:special_items)
55
+ bp.update(described_class, fetched_special_items)
56
+ end
57
+
58
+ after :all do
59
+ Response.responses(:reset => :confirm)
60
+ expect(Response.responses).to be_empty
61
+ described_class.class_eval { @items = nil }
61
62
  end
63
+
62
64
  it 'returns the fixture and sets to @@items variable' do
63
65
  expect(described_class.items).not_to be_nil
64
66
  end
67
+
65
68
  it 'is a Hash object' do
66
69
  expect(described_class.items).to be_instance_of Hash
67
70
  end
71
+
68
72
  it 'has these 2 keys' do
69
73
  expect(described_class.items.keys).to match_array [':weed:', 'Random Craft Hat']
70
74
  end
75
+
71
76
  it 'each key points to an instance of SpecialItem' do
72
77
  expect(described_class.items.values).to all be_a BackpackTF::SpecialItem
73
78
  end
@@ -10,10 +10,6 @@ module BackpackTF
10
10
  Response.hash_keys_to_sym(fixture)
11
11
  }
12
12
 
13
- it 'responds to these methods' do
14
- expect(described_class).to respond_to :responses, :interface, :hash_keys_to_sym, :response, :listings
15
- end
16
-
17
13
  it 'has these default attributes' do
18
14
  expect(described_class.interface).to eq :IGetUserListings
19
15
  end
@@ -34,35 +30,25 @@ module BackpackTF
34
30
  )
35
31
  end
36
32
 
37
- describe '::responses' do
38
-
39
- before :each do
40
- stub_http_response_with('user_listing.json')
41
- opts = { :compress => 1, :steamid => 76561197978210095 }
42
- fetched_listings = bp.fetch(:user_listings, opts)
43
- Response.responses(described_class.to_sym => fetched_listings)
44
- end
45
- it "can access response by calling the key, UserListing" do
46
- expect(Response.responses[described_class.to_sym]).to eq json_obj
33
+ describe '::response' do
34
+ before :all do
35
+ expect(described_class.response).to be_nil
47
36
  end
48
- end
49
37
 
50
- describe '::response' do
51
38
  before :each do
52
39
  stub_http_response_with('user_listing.json')
53
40
  opts = { :compress => 1, :steamid => 76561197978210095 }
54
41
  fetched_listings = bp.fetch(:user_listings, opts)
55
42
  Response.responses(described_class.to_sym => fetched_listings)
56
43
  end
57
- it 'can access response information via the class method, ::response' do
58
- expect(described_class.response).to eq json_obj
59
- end
60
- it "returns same results as calling Response.responses[:'BackpackTF::UserListing']" do
61
- expect(described_class.response).to eq Response.responses[described_class.to_sym]
62
- end
63
- it 'the response attribute should have these keys' do
64
- expect(described_class.response.keys).to match_array [:success, :current_time, :listings]
44
+
45
+ after :all do
46
+ Response.responses(:reset => :confirm)
47
+ expect(Response.responses).to be_empty
48
+ expect(described_class.response).to be_nil
49
+ expect(described_class.listings).to be_nil
65
50
  end
51
+
66
52
  it 'the keys of the response attribute should have these values' do
67
53
  expect(described_class.response[:success]).to eq 1
68
54
  expect(described_class.response[:message]).to eq nil
@@ -71,12 +57,24 @@ module BackpackTF
71
57
  end
72
58
 
73
59
  describe '::listings' do
60
+ before :all do
61
+ expect(described_class.response).to be_nil
62
+ expect(described_class.listings).to be_nil
63
+ end
64
+
74
65
  before :each do
75
66
  stub_http_response_with('user_listing.json')
76
67
  opts = { :compress => 1, :steamid => 76561197978210095 }
77
68
  fetched_listings = bp.fetch(:user_listings, opts)
78
69
  Response.responses(described_class.to_sym => fetched_listings)
79
70
  end
71
+
72
+ after :all do
73
+ Response.responses(:reset => :confirm)
74
+ expect(Response.responses).to be_empty
75
+ described_class.class_eval { @listings = nil }
76
+ end
77
+
80
78
  it 'returns the fixture and sets to @@listings variable' do
81
79
  expect(described_class.listings).not_to be_nil
82
80
  end
@@ -10,10 +10,6 @@ module BackpackTF
10
10
  Response.hash_keys_to_sym(fixture)
11
11
  }
12
12
 
13
- it 'responds to these methods' do
14
- expect(described_class).to respond_to :responses, :interface, :hash_keys_to_sym
15
- end
16
-
17
13
  it 'has these default attributes' do
18
14
  expect(described_class.interface).to eq :IGetUsers
19
15
  end
@@ -33,35 +29,25 @@ module BackpackTF
33
29
  )
34
30
  end
35
31
 
36
- describe '::responses' do
37
-
38
- before :each do
39
- stub_http_response_with('users.json')
40
- opts = {:compress => 1, :steamids => [76561198012598620,76561198045802942]}
41
- fetched_users = bp.fetch(:special_items, opts)
42
- Response.responses(described_class.to_sym => fetched_users)
43
- end
44
- it "User can be accessed by calling the key, User" do
45
- expect(Response.responses[described_class.to_sym]).to eq json_obj
32
+ describe '::response' do
33
+ before :all do
34
+ expect(described_class.response).to be_nil
46
35
  end
47
- end
48
36
 
49
- describe '::response' do
50
37
  before :each do
51
38
  stub_http_response_with('users.json')
52
- opts = {:compress => 1, :steamids => [76561198012598620,76561198045802942]}
53
- fetched_users = bp.fetch(:special_items, opts)
54
- Response.responses(described_class.to_sym => fetched_users)
39
+ opts = {:steamids => [76561198012598620,76561198045802942]}
40
+ fetched_users = bp.fetch(:users, opts)
41
+ bp.update(described_class, fetched_users)
55
42
  end
56
- it 'can access response information via the class method, ::response' do
57
- expect(described_class.response).to eq json_obj
58
- end
59
- it "returns same results as calling Response.responses[:'BackpackTF::User']" do
60
- expect(described_class.response).to eq Response.responses[described_class.to_sym]
61
- end
62
- it 'the response attribute should have these keys' do
63
- expect(described_class.response.keys).to match_array [:success, :current_time, :players]
43
+
44
+ after :all do
45
+ Response.responses(:reset => :confirm)
46
+ expect(Response.responses).to be_empty
47
+ expect(described_class.response).to be_nil
48
+ expect(described_class.players).to be_nil
64
49
  end
50
+
65
51
  it 'the keys of the response attribute should have these values' do
66
52
  expect(described_class.response[:success]).to eq 1
67
53
  expect(described_class.response[:message]).to eq nil
@@ -70,12 +56,24 @@ module BackpackTF
70
56
  end
71
57
 
72
58
  describe '::players' do
59
+ before :all do
60
+ expect(described_class.response).to be_nil
61
+ expect(described_class.players).to be_nil
62
+ end
63
+
73
64
  before :each do
74
65
  stub_http_response_with('users.json')
75
- opts = {:compress => 1, :steamids => [76561198012598620,76561198045802942]}
76
- fetched_users = bp.fetch(:special_items, opts)
77
- Response.responses(described_class.to_sym => fetched_users)
66
+ opts = {:steamids => [76561198012598620,76561198045802942]}
67
+ fetched_users = bp.fetch(:users, opts)
68
+ bp.update(described_class, fetched_users)
69
+ end
70
+
71
+ after :all do
72
+ Response.responses(:reset => :confirm)
73
+ expect(Response.responses).to be_empty
74
+ described_class.class_eval { @players = nil }
78
75
  end
76
+
79
77
  it 'returns the fixture and sets to @@players variable' do
80
78
  expect(described_class.players).not_to be_nil
81
79
  end
@@ -0,0 +1,65 @@
1
+ {
2
+ "Mann Co. Supply Munition": {
3
+ "defindex": [
4
+ 5734,
5
+ 5735,
6
+ 5742,
7
+ 5752,
8
+ 5781,
9
+ 5802,
10
+ 5803
11
+ ],
12
+ "prices": {
13
+ "6": {
14
+ "Tradable": {
15
+ "Craftable": {
16
+ "82": {
17
+ "currency": "metal",
18
+ "value": 0.01,
19
+ "last_update": 1417567564,
20
+ "difference": -0.03,
21
+ "value_high": 0.03
22
+ },
23
+ "83": {
24
+ "currency": "metal",
25
+ "value": 0.05,
26
+ "last_update": 1422061240,
27
+ "difference": 0.02
28
+ },
29
+ "84": {
30
+ "currency": "metal",
31
+ "value": 0.01,
32
+ "last_update": 1423702834,
33
+ "difference": -0.06,
34
+ "value_high": 0.03
35
+ },
36
+ "85": {
37
+ "currency": "metal",
38
+ "value": 0.01,
39
+ "last_update": 1417904407,
40
+ "difference": -0.01
41
+ },
42
+ "90": {
43
+ "currency": "metal",
44
+ "value": 0.05,
45
+ "last_update": 1429293267,
46
+ "difference": -0.06
47
+ },
48
+ "91": {
49
+ "currency": "metal",
50
+ "value": 0.05,
51
+ "last_update": 1424623531,
52
+ "difference": -0.03
53
+ },
54
+ "92": {
55
+ "currency": "metal",
56
+ "value": 0.05,
57
+ "last_update": 1430304436,
58
+ "difference": -0.06
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }