steam-api 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe Steam::Store do
5
+ let(:appid) { 976730 }
6
+
7
+ describe '.app_details' do
8
+ let (:result) { Steam::Store.app_details(appid) }
9
+
10
+ it 'returns the details of an application' do
11
+ expect(result).to_not be_nil
12
+ end
13
+
14
+ it 'returns a JSON structure containing details of the returned app' do
15
+ expect(result).to include("976730")
16
+ end
17
+ end
18
+ end
@@ -2,84 +2,95 @@ require 'spec_helper'
2
2
 
3
3
  describe Steam::UserStats do
4
4
  describe '.achievement_percentages' do
5
- it 'should return achievement information' do
6
- Steam::UserStats.achievement_percentages(440)
7
- .should_not be_nil
5
+ let(:result) { Steam::UserStats.achievement_percentages(440) }
6
+
7
+ it 'returns achievement information' do
8
+ expect(result).to_not be_nil
8
9
  end
9
10
 
10
- it 'should return all achievements for a game' do
11
- achs = Steam::UserStats.achievement_percentages(440)
12
- achs.first.should have_key('name')
13
- achs.first.should have_key('percent')
11
+ it 'returns all achievements for a game' do
12
+ expect(result.first).to have_key('name')
13
+ expect(result.first).to have_key('percent')
14
14
  end
15
15
  end
16
16
 
17
17
  describe '.game_schema' do
18
- it 'should return global game stats' do
19
- Steam::UserStats.game_schema(440)
20
- .should_not be_nil
21
- end
18
+ let(:result) { Steam::UserStats.game_schema(440) }
22
19
 
23
- it 'should return global game stats with proper schema' do
24
- Steam::UserStats.game_schema(440)
25
- .should have_key('gameName')
20
+ it 'returns global game stats' do
21
+ expect(result).to_not be_nil
26
22
  end
27
23
 
28
- it 'should return global game stats with proper schema' do
29
- Steam::UserStats.game_schema(440)
30
- .should have_key('gameName')
24
+ it 'returns global game stats with a gameName' do
25
+ expect(result).to have_key('gameName')
31
26
  end
32
27
 
33
- it 'should return global game stats with proper schema' do
34
- Steam::UserStats.game_schema(440)
35
- .should have_key('gameVersion')
28
+ it 'returns global game stats with a gameVersion' do
29
+ expect(result).to have_key('gameVersion')
36
30
  end
37
31
 
38
- it 'should return global game stats with proper schema' do
39
- Steam::UserStats.game_schema(440)
40
- .should have_key('availableGameStats')
32
+ it 'returns global game stats with availableGameStats' do
33
+ expect(result).to have_key('availableGameStats')
41
34
  end
42
35
  end
43
36
 
44
37
  describe '.global_for_game' do
45
- it 'should return global game stats' do
46
- Steam::UserStats.global_for_game(201830,
47
- params: { 'name[0]' => 'totalDeaths',
48
- count: 10 })
38
+ it 'returns global game stats' do
39
+ Steam::UserStats.global_for_game(201830, params: { 'name[0]' => 'totalDeaths', count: 10 })
49
40
  end
50
41
  end
51
42
 
52
43
  describe '.player_count' do
53
- it 'should return a player count' do
54
- Steam::UserStats.player_count(440)
55
- .should be_a(Fixnum)
44
+ it 'returns a player count' do
45
+ expect(Steam::UserStats.player_count(440)).to be_a(Integer)
56
46
  end
57
47
  end
58
48
 
59
49
  describe '.get_player_achievements' do
60
- it 'should return player achievements' do
61
- Steam::UserStats.player_achievements(440, 76561197969622382)
62
- .should have_key('achievements')
50
+ let(:achs) { Steam::UserStats.player_achievements(440, 76561197993276293) }
51
+
52
+ it 'returns a list of player achievements' do
53
+ expect(achs).to have_key('achievements')
54
+ end
55
+
56
+ it 'returns a gameName' do
57
+ expect(achs).to have_key('gameName')
58
+ end
59
+
60
+ it 'returns correct gameName' do
61
+ expect(achs['gameName']).to eq('Team Fortress 2')
62
+ end
63
+
64
+ it 'returns a steamID' do
65
+ expect(achs).to have_key('steamID')
66
+ end
67
+
68
+ it 'returns the correct steamID' do
69
+ expect(achs['steamID']).to eq('76561197993276293')
70
+ end
71
+ end
72
+
73
+ describe '.player_stats' do
74
+ let(:stats) { Steam::UserStats.player_stats(440, 76561197993276293) }
75
+
76
+ it 'returns player stats' do
77
+ expect(stats).to have_key('stats')
63
78
  end
64
79
 
65
- it 'should return player achievements' do
66
- Steam::UserStats.player_achievements(440, 76561197969622382)
67
- .should have_key('gameName')
80
+ it 'returns a gameName' do
81
+ expect(stats).to have_key('gameName')
68
82
  end
69
83
 
70
- it 'should return player achievements' do
71
- Steam::UserStats.player_achievements(440, 76561197969622382)['gameName']
72
- .should == 'Team Fortress 2'
84
+ it 'returns the correct gameName' do
85
+ expect(stats['gameName']).to eq('Team Fortress 2')
73
86
  end
74
87
 
75
- it 'should return player achievements' do
76
- Steam::UserStats.player_achievements(440, 76561197969622382)
77
- .should have_key('steamID')
88
+ it 'returns a steamID' do
89
+ expect(stats).to have_key('steamID')
78
90
  end
79
91
 
80
- it 'should return player achievements' do
81
- Steam::UserStats.player_achievements(440, 76561197969622382)['steamID']
82
- .should == '76561197969622382'
92
+ it 'returns a correct steamID' do
93
+ expect(stats['steamID']).to eq('76561197993276293')
83
94
  end
84
95
  end
85
96
  end
@@ -1,86 +1,80 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Steam::User do
4
+ let(:playerid) { 76561197993276293 }
5
+ let(:playerid2) { 76561197969622382 }
4
6
 
5
7
  describe '.friends' do
6
- it 'should allow users to check a friends for a user' do
7
- response = Steam::User.friends(76561197993276293)
8
- response.should_not be_nil
8
+ let(:result) { Steam::User.friends(playerid) }
9
+
10
+ it 'allows users to check a friends for a user' do
11
+ expect(result).to_not be_nil
9
12
  end
10
13
 
11
- it 'should allow users to check a friends for a user' do
12
- Steam::User.friends(76561197993276293)
13
- .map {|f| f.first.last }
14
- .should include('76561197969622382')
14
+ it 'returns a list of friends of a user' do
15
+ expect(result.map { |friend| friend.first.last }).to include(playerid2.to_s)
15
16
  end
16
17
 
17
- it 'should return an error on a bad friend id' do
18
- lambda { Steam::User.friends('765611') }
19
- .should raise_error
18
+ it 'raises an error on a bad friend id' do
19
+ expect { Steam::User.friends('765611') }.to raise_error(Steam::JSONError)
20
20
  end
21
21
 
22
- it 'should return the same content for :friends and :all' do
23
- Steam::User.friends('76561197969622382', relationship: :friend)
24
- .should == Steam::User.friends('76561197969622382', relationship: :all)
22
+ it 'returns the same content for :friends and :all' do
23
+ friends = Steam::User.friends(playerid2, relationship: :friend)
24
+ all_friends = Steam::User.friends(playerid2, relationship: :all)
25
+ expect(friends).to eq(all_friends)
25
26
  end
26
27
 
27
- it 'should return an error on a bad friend id' do
28
- lambda { Steam::User.friends('76561197969622382', relationship: :sadsad) }
29
- .should raise_error(Steam::JSONError)
28
+ it 'returns an error on a bad friend relationship' do
29
+ expect { Steam::User.friends(playerid2, relationship: :sadsad) }.to raise_error(Steam::JSONError)
30
30
  end
31
31
  end
32
32
 
33
33
  describe '.bans' do
34
- it 'should allow users to check bans for a user' do
35
- Steam::User.bans(76561197993276293)
36
- .should_not be_nil
34
+ it 'allows users to check bans for a user' do
35
+ expect(Steam::User.bans(playerid)).to_not be_nil
37
36
  end
38
37
 
39
- it 'should return a blank list for bad ids' do
40
- Steam::User.bans(7993276293)
41
- .should == { 'players' => [] }
38
+ it 'returns a blank list for bad ids' do
39
+ expect(Steam::User.bans(7993276293)).to eq({ 'players' => [] })
42
40
  end
43
41
 
44
- it 'should allow users to check a bans for multiple steamids' do
45
- Steam::User.bans([76561197993276293, 76561197966796383])
46
- .should_not be_nil
42
+ it 'allow users to check bans for multiple steamids' do
43
+ expect(Steam::User.bans([playerid, playerid2])).to_not be_nil
47
44
  end
48
45
  end
49
46
 
50
47
  describe '.summary' do
51
- it 'should allow users to get a summary for a user' do
52
- Steam::User.summary(76561197993276293)
53
- .should_not be_nil
48
+ it 'allows users to get a summary for a user' do
49
+ expect(Steam::User.summary(playerid)).to_not be_nil
54
50
  end
55
51
 
56
- it 'should allow users to check summaries for multiple accounts' do
57
- Steam::User.summaries([76561197993276293, 76561197966796383])
58
- .should_not be_nil
52
+ it 'allows users to check summaries for multiple accounts' do
53
+ expect(Steam::User.summaries([playerid, playerid2])).to_not be_nil
59
54
  end
60
55
  end
61
56
 
62
57
  describe '.vanity_to_steamid' do
63
- it 'should return values when they look up vanity urls' do
64
- Steam::User.vanity_to_steamid('asmeroth')
65
- .should_not be_nil
58
+ let(:result) { Steam::User.vanity_to_steamid('theasmer') }
59
+
60
+ it 'return values when they look up vanity urls' do
61
+ expect(result).to_not be_nil
66
62
  end
67
63
 
68
- it 'should return the correct id when users look up vanity urls' do
69
- Steam::User.vanity_to_steamid('asmeroth')
70
- .should == '76561197993276293'
64
+ it 'returns the correct id when users look up vanity urls' do
65
+ expect(result).to eq(playerid.to_s)
71
66
  end
72
67
  end
73
68
 
74
69
  describe '.groups' do
75
- it 'should allow users to look groups a player is a member of' do
76
- Steam::User.groups(76561197993276293)
77
- .should_not be_nil
70
+ let(:result) { Steam::User.groups(playerid) }
71
+
72
+ it 'allow users to look up a users groups' do
73
+ expect(result).to_not be_nil
78
74
  end
79
75
 
80
- it 'should return an accurate list of groups a player is a member of' do
81
- response = Steam::User.groups(76561197993276293)
82
- response.map { |g| g.values.first }
83
- .should include '3640974'
76
+ it 'returns an accurate list of groups a player is a member of' do
77
+ expect(result.map { |g| g.values.first }).to include('3640974')
84
78
  end
85
79
  end
86
80
  end
@@ -1,33 +1,38 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Steam do
4
- before(:all) do
5
- @apikey = Steam.apikey
6
- end
4
+ describe '.apikey' do
5
+ before(:all) do
6
+ @apikey = Steam.apikey
7
+ end
7
8
 
8
- after(:each) do
9
- Steam.apikey = @apikey
10
- end
9
+ after(:each) do
10
+ Steam.apikey = @apikey
11
+ end
11
12
 
12
- it 'should return a Steam API key if one is defined' do
13
- Steam.apikey.should_not be_nil
14
- end
13
+ it 'returns a Steam API key if one is defined' do
14
+ expect(Steam.apikey).to_not be_nil
15
+ end
15
16
 
16
- it 'should return an error if the Steam Key is missing' do
17
- Steam.apikey = nil
18
- lambda { Steam.apikey }
19
- .should raise_error(ArgumentError, /Please set your Steam API key/)
20
- end
17
+ it 'returns an error if the Steam Key is missing' do
18
+ Steam.apikey = nil
19
+ ENV['STEAM_API_KEY'] = nil
20
+ expect { Steam.apikey }.to raise_error(ArgumentError, /Please set your Steam API key/)
21
+ end
21
22
 
22
- it 'should return a new value if set to a different API key' do
23
- old = Steam.apikey
24
- Steam.apikey = 'blah'
25
- Steam.apikey.should_not == old
26
- Steam.apikey.should == 'blah'
27
- end
23
+ it 'returns a new value if set to a different API key' do
24
+ old = Steam.apikey
25
+ Steam.apikey = 'blah'
26
+ expect(Steam.apikey).to_not eq(old)
27
+ expect(Steam.apikey).to eq('blah')
28
+ end
28
29
 
29
- it 'should update the ENV variable if set' do
30
- Steam.apikey = 'test'
31
- ENV['STEAM_API_KEY'].should == 'test'
30
+ it 'allows users to set the apikey post init using ENV' do
31
+ Steam.apikey = nil
32
+ ENV['STEAM_API_KEY'] = nil
33
+ expect { Steam.apikey }.to raise_error(ArgumentError, /Please set your Steam API key/)
34
+ ENV['STEAM_API_KEY'] = @apikey
35
+ expect(Steam.apikey).to eq(@apikey)
36
+ end
32
37
  end
33
38
  end
@@ -1,5 +1,4 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'steam-api/version'
5
4
 
@@ -8,23 +7,19 @@ Gem::Specification.new do |gem|
8
7
  gem.version = Steam::VERSION
9
8
  gem.authors = ['Brian Haberer']
10
9
  gem.email = ['bhaberer@gmail.com']
11
- gem.description = %q{Simple Steam Gem}
12
- gem.summary = %q{Simple Gem to interact witht the Steam Web API}
10
+ gem.description = 'Simple Steam Gem'
11
+ gem.summary = 'Simple Gem to interact with the Steam Web API'
13
12
  gem.homepage = 'https://github.com/bhaberer/steam-api'
13
+ gem.license = 'MIT'
14
14
 
15
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.files = `git ls-files`.split($RS)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ['lib']
19
19
 
20
- gem.required_ruby_version = '>= 2.0.0'
20
+ gem.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
21
+ gem.add_development_dependency 'rake', '~> 13.0'
22
+ gem.add_development_dependency 'rspec', '~> 3.9'
21
23
 
22
- gem.add_development_dependency 'rake'
23
- gem.add_development_dependency 'rspec'
24
- gem.add_development_dependency 'coveralls'
25
-
26
- gem.add_dependency 'weary', '1.1.3'
27
- gem.add_dependency 'faraday'
28
- gem.add_dependency 'multi_json', '1.7.7'
29
- gem.add_dependency 'json', '~> 1.7.7'
24
+ gem.add_dependency 'faraday', '~> 1.0'
30
25
  end
metadata CHANGED
@@ -1,113 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steam-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Haberer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-27 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: codeclimate-test-reporter
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: coveralls
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3.9'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: weary
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '='
60
- - !ruby/object:Gem::Version
61
- version: 1.1.3
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '='
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: 1.1.3
54
+ version: '3.9'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: faraday
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: multi_json
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '='
88
- - !ruby/object:Gem::Version
89
- version: 1.7.7
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '='
95
- - !ruby/object:Gem::Version
96
- version: 1.7.7
97
- - !ruby/object:Gem::Dependency
98
- name: json
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ~>
59
+ - - "~>"
102
60
  - !ruby/object:Gem::Version
103
- version: 1.7.7
61
+ version: '1.0'
104
62
  type: :runtime
105
63
  prerelease: false
106
64
  version_requirements: !ruby/object:Gem::Requirement
107
65
  requirements:
108
- - - ~>
66
+ - - "~>"
109
67
  - !ruby/object:Gem::Version
110
- version: 1.7.7
68
+ version: '1.0'
111
69
  description: Simple Steam Gem
112
70
  email:
113
71
  - bhaberer@gmail.com
@@ -115,8 +73,9 @@ executables: []
115
73
  extensions: []
116
74
  extra_rdoc_files: []
117
75
  files:
118
- - .gitignore
119
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
120
79
  - Gemfile
121
80
  - LICENSE.txt
122
81
  - README.md
@@ -133,6 +92,7 @@ files:
133
92
  - lib/steam-api/steam/news.rb
134
93
  - lib/steam-api/steam/player.rb
135
94
  - lib/steam-api/steam/remote_storage.rb
95
+ - lib/steam-api/steam/store.rb
136
96
  - lib/steam-api/steam/user.rb
137
97
  - lib/steam-api/steam/user_stats.rb
138
98
  - lib/steam-api/version.rb
@@ -142,12 +102,14 @@ files:
142
102
  - spec/steam/news_spec.rb
143
103
  - spec/steam/player_spec.rb
144
104
  - spec/steam/remote-storage_spec.rb
105
+ - spec/steam/store_spec.rb
145
106
  - spec/steam/users-stats_spec.rb
146
107
  - spec/steam/users_spec.rb
147
108
  - spec/steam_spec.rb
148
109
  - steam-api.gemspec
149
110
  homepage: https://github.com/bhaberer/steam-api
150
- licenses: []
111
+ licenses:
112
+ - MIT
151
113
  metadata: {}
152
114
  post_install_message:
153
115
  rdoc_options: []
@@ -155,20 +117,20 @@ require_paths:
155
117
  - lib
156
118
  required_ruby_version: !ruby/object:Gem::Requirement
157
119
  requirements:
158
- - - '>='
120
+ - - ">="
159
121
  - !ruby/object:Gem::Version
160
- version: 2.0.0
122
+ version: '0'
161
123
  required_rubygems_version: !ruby/object:Gem::Requirement
162
124
  requirements:
163
- - - '>='
125
+ - - ">="
164
126
  - !ruby/object:Gem::Version
165
127
  version: '0'
166
128
  requirements: []
167
129
  rubyforge_project:
168
- rubygems_version: 2.0.3
130
+ rubygems_version: 2.7.7
169
131
  signing_key:
170
132
  specification_version: 4
171
- summary: Simple Gem to interact witht the Steam Web API
133
+ summary: Simple Gem to interact with the Steam Web API
172
134
  test_files:
173
135
  - spec/spec_helper.rb
174
136
  - spec/steam/apps_spec.rb
@@ -176,7 +138,7 @@ test_files:
176
138
  - spec/steam/news_spec.rb
177
139
  - spec/steam/player_spec.rb
178
140
  - spec/steam/remote-storage_spec.rb
141
+ - spec/steam/store_spec.rb
179
142
  - spec/steam/users-stats_spec.rb
180
143
  - spec/steam/users_spec.rb
181
144
  - spec/steam_spec.rb
182
- has_rdoc: