steam_stats 0.0.1

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.
@@ -0,0 +1,85 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ require 'webmock/rspec'
5
+ require 'nokogiri'
6
+ require 'open-uri'
7
+ require 'json'
8
+
9
+ require 'steam_stats'
10
+
11
+ RSpec.configure do |config|
12
+ config.expect_with :rspec do |expectations|
13
+ # This option will default to `true` in RSpec 4. It makes the `description`
14
+ # and `failure_message` of custom matchers include text for helper methods
15
+ # defined using `chain`, e.g.:
16
+ # be_bigger_than(2).and_smaller_than(4).description
17
+ # # => "be bigger than 2 and smaller than 4"
18
+ # ...rather than:
19
+ # # => "be bigger than 2"
20
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
21
+ end
22
+
23
+ # rspec-mocks config goes here. You can use an alternate test double
24
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
25
+ config.mock_with :rspec do |mocks|
26
+ # Prevents you from mocking or stubbing a method that does not exist on
27
+ # a real object. This is generally recommended, and will default to
28
+ # `true` in RSpec 4.
29
+ mocks.verify_partial_doubles = true
30
+ end
31
+
32
+ # The settings below are suggested to provide a good initial experience
33
+ # with RSpec, but feel free to customize to your heart's content.
34
+ =begin
35
+ # These two settings work together to allow you to limit a spec run
36
+ # to individual examples or groups you care about by tagging them with
37
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
38
+ # get run.
39
+ config.filter_run :focus
40
+ config.run_all_when_everything_filtered = true
41
+
42
+ # Allows RSpec to persist some state between runs in order to support
43
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
44
+ # you configure your source control system to ignore this file.
45
+ config.example_status_persistence_file_path = "spec/examples.txt"
46
+
47
+ # Limits the available syntax to the non-monkey patched syntax that is
48
+ # recommended. For more details, see:
49
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
50
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
51
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
52
+ config.disable_monkey_patching!
53
+
54
+ # This setting enables warnings. It's recommended, but in some cases may
55
+ # be too noisy due to issues in dependencies.
56
+ config.warnings = true
57
+
58
+ # Many RSpec users commonly either run the entire suite or an individual
59
+ # file, and it's useful to allow more verbose output when running an
60
+ # individual spec file.
61
+ if config.files_to_run.one?
62
+ # Use the documentation formatter for detailed output,
63
+ # unless a formatter has already been configured
64
+ # (e.g. via a command-line flag).
65
+ config.default_formatter = 'doc'
66
+ end
67
+
68
+ # Print the 10 slowest examples and example groups at the
69
+ # end of the spec run, to help surface which specs are running
70
+ # particularly slow.
71
+ config.profile_examples = 10
72
+
73
+ # Run specs in random order to surface order dependencies. If you find an
74
+ # order dependency and want to debug it, you can fix the order by providing
75
+ # the seed, which is printed after each run.
76
+ # --seed 1234
77
+ config.order = :random
78
+
79
+ # Seed global randomization in this process using the `--seed` CLI option.
80
+ # Setting this allows you to use `--seed` to deterministically reproduce
81
+ # test failures related to randomization by passing the same `--seed` value
82
+ # as the one that triggered the failure.
83
+ Kernel.srand config.seed
84
+ =end
85
+ end
data/spec/user_spec.rb ADDED
@@ -0,0 +1,49 @@
1
+ RSpec.describe SteamStats::User do
2
+ let (:user) { user = SteamStats::User.new 'pewdie' }
3
+
4
+ before do
5
+ Dir.chdir(File.dirname(__FILE__))
6
+
7
+ user_response_file = File.new('data/user.html')
8
+ stub_request(:any, 'http://steamcommunity.com/id/pewdie').
9
+ to_return(body: user_response_file.read, status: 200)
10
+
11
+ games_response_file = File.new('data/games.html')
12
+ stub_request(:any, 'http://steamcommunity.com/id/pewdie/games/?tab=all').
13
+ to_return(body: games_response_file.read, status: 200)
14
+ end
15
+
16
+ it 'gets user name' do
17
+ expect(user.name).to eq 'Poods'
18
+ end
19
+
20
+ it 'gets user real name' do
21
+ expect(user.real_name).to eq 'Felix Kjellberg'
22
+ end
23
+
24
+ it 'gets user avatar' do
25
+ expect(user.avatar).to eq 'http://cdn.akamai.steamstatic.com/steamcommunity/public/images/avatars/b9/b9a781a894d319c1a1331a35fc17adf9b02fee76_full.jpg'
26
+ end
27
+
28
+ it 'gets user country' do
29
+ expect(user.country).to eq 'SE'
30
+ end
31
+
32
+ it 'gets user level' do
33
+ expect(user.level).to eq 12
34
+ end
35
+
36
+ it 'checks if user online' do
37
+ expect(user.is_online?).to be false
38
+ end
39
+
40
+ it 'gets games' do
41
+ expect(user.games).to include({ name: 'Call of Duty: Modern Warfare 2 - Multiplayer', played_hours: 914 }, { name: 'VVVVVV', played_hours: 0.1 })
42
+ end
43
+
44
+ context 'not played game' do
45
+ it 'returns 0 played_hours' do
46
+ expect(user.games).to include({ name: 'LIMBO', played_hours: 0 })
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'steam_stats/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'steam_stats'
8
+ spec.version = SteamStats::VERSION
9
+ spec.authors = ['Krzysztof Zbudniewek']
10
+ spec.email = ['krzysztof.zbudniewek@gmail.com']
11
+ spec.summary = %q{Get players' games stats from Ruby.}
12
+ spec.homepage = 'https://github.com/neonowy/steam-stats'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.7'
21
+ spec.add_development_dependency 'rake', '~> 10.0'
22
+ spec.add_development_dependency 'rspec', '~> 3.0'
23
+ spec.add_development_dependency 'webmock'
24
+
25
+ spec.add_dependency "nokogiri"
26
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: steam_stats
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Krzysztof Zbudniewek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ 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
+ description:
84
+ email:
85
+ - krzysztof.zbudniewek@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".coveralls.yml"
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - LICENSE
96
+ - README.md
97
+ - Rakefile
98
+ - lib/steam_stats.rb
99
+ - lib/steam_stats/user.rb
100
+ - lib/steam_stats/version.rb
101
+ - spec/data/games.html
102
+ - spec/data/user.html
103
+ - spec/spec_helper.rb
104
+ - spec/user_spec.rb
105
+ - steam_stats.gemspec
106
+ homepage: https://github.com/neonowy/steam-stats
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.5
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Get players' games stats from Ruby.
130
+ test_files:
131
+ - spec/data/games.html
132
+ - spec/data/user.html
133
+ - spec/spec_helper.rb
134
+ - spec/user_spec.rb