stew 0.5.3 → 0.6.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.
- checksums.yaml +6 -6
- data/.gitignore +1 -0
- data/lib/stew.rb +6 -9
- data/lib/stew/community/profile.rb +2 -2
- data/lib/stew/community/profile_friends.rb +1 -1
- data/lib/stew/community/profile_game.rb +23 -6
- data/lib/stew/community/steam_id.rb +6 -21
- data/lib/stew/community/steam_id_resolver.rb +34 -0
- data/lib/stew/community/web_api_client.rb +29 -0
- data/lib/stew/community/web_client.rb +29 -0
- data/lib/stew/version.rb +1 -1
- data/spec/config.yml.example +1 -0
- data/spec/fixtures/profiles/76561197992917668.json +24 -0
- data/spec/fixtures/profiles/friends/76561197992917668.json +167 -0
- data/spec/fixtures/profiles/friends/76561197994486912.json +8 -0
- data/spec/fixtures/profiles/games/76561197992917668.json +789 -0
- data/spec/fixtures/profiles/games/76561197994486912.json +5 -0
- data/spec/fixtures/profiles/vanity/Phucked.json +6 -0
- data/spec/integration/community_web_api_integration_spec.rb +32 -0
- data/spec/lib/stew/community/profile_friends_spec.rb +3 -24
- data/spec/lib/stew/community/profile_game_spec.rb +20 -12
- data/spec/lib/stew/community/profile_games_spec.rb +2 -3
- data/spec/lib/stew/community/profile_spec.rb +2 -2
- data/spec/lib/stew/community/steam_id_resolver_spec.rb +82 -0
- data/spec/lib/stew/community/steam_id_spec.rb +22 -83
- data/spec/lib/stew/community/web_api_client_spec.rb +61 -0
- data/spec/lib/stew/community/web_client_spec.rb +17 -0
- data/spec/spec_helper.rb +12 -0
- data/stew.gemspec +7 -5
- metadata +98 -92
- data/lib/stew/community/community_client.rb +0 -53
- data/lib/stew/community/xml_client/xml_client.rb +0 -50
- data/lib/stew/community/xml_client/xml_client_response_friends.rb +0 -20
- data/lib/stew/community/xml_client/xml_client_response_games.rb +0 -20
- data/lib/stew/community/xml_client/xml_client_response_profile.rb +0 -14
- data/spec/fixtures/profiles/friends/76561197992917668.yml +0 -36
- data/spec/fixtures/profiles/friends/76561197994486912.yml +0 -5
- data/spec/fixtures/profiles/games/76561197992917668.yml +0 -616
- data/spec/fixtures/profiles/games/76561197994486912.yml +0 -5
- data/spec/integration/community_integration_spec.rb +0 -50
- data/spec/lib/stew/community/community_client_spec.rb +0 -118
- data/spec/lib/stew/community/xml_client/xml_client_spec.rb +0 -36
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Community", :vcr do
|
4
|
-
describe "Creation of a steam profile with data" do
|
5
|
-
subject{Stew::Community::SteamId.create(76561197992917668)}
|
6
|
-
|
7
|
-
describe "profile" do
|
8
|
-
it "sets the nickname" do
|
9
|
-
subject.profile.nickname.should eq 'MrCheese'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "games" do
|
14
|
-
it "creates games" do
|
15
|
-
subject.games.collect(&:name).include?('Shank').should be_true
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "friends" do
|
20
|
-
it "creates friends" do
|
21
|
-
subject.friends.collect(&:id).include?(76561197972211787.to_s).should be_true
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "Attempted creation of a non-existing Steam ID" do
|
27
|
-
subject{Stew::Community::SteamId.create("www.google.com/nisse")}
|
28
|
-
|
29
|
-
it "raises a Stew::XmlClient::ObjectNotFoundError" do
|
30
|
-
expect{subject.profile.nickname}.to raise_error(Stew::Community::SteamIdNotFoundError)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "Creation of a steam id that has a set vanity url" do
|
35
|
-
it "properly follows redirects and parses the data" do
|
36
|
-
profile = Stew::Community::SteamId.create(76561197960889223)
|
37
|
-
profile.id.should eq 76561197960889223
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "Creation of a steam id from a URL" do
|
42
|
-
let(:id){76561197992917668}
|
43
|
-
let(:url){"http://steamcommunity.com/profiles/#{id}"}
|
44
|
-
|
45
|
-
it "creates the steam id" do
|
46
|
-
steam_id = Stew::Community::SteamId.create(url)
|
47
|
-
steam_id.id.should eq id
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Stew::CommunityClient" do
|
4
|
-
let(:client){double('xml_client')}
|
5
|
-
subject{Stew::Community::CommunityClient.new({:client => client})}
|
6
|
-
let(:id){76561197992917668}
|
7
|
-
|
8
|
-
describe "#steam_id_from_vanity_name" do
|
9
|
-
let(:vanity_name){"foobar"}
|
10
|
-
|
11
|
-
it "calls steam_id_from_vanity_name on a new instance" do
|
12
|
-
Stew::Community::CommunityClient.any_instance.should_receive(:steam_id_from_vanity_name).with(vanity_name)
|
13
|
-
Stew::Community::CommunityClient.steam_id_from_vanity_name(vanity_name)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
describe ".steam_id_from_vanity_name" do
|
19
|
-
let(:response){YAML.load_file("spec/fixtures/profiles/#{id}.yml")}
|
20
|
-
let(:name){"Somename"}
|
21
|
-
|
22
|
-
before :each do
|
23
|
-
client.should_receive(:get).with("/id/#{name}").and_return(response)
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when the vanity name exists" do
|
27
|
-
it "returns the 64-bit id" do
|
28
|
-
subject.steam_id_from_vanity_name(name).should eq id
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "setting the base path" do
|
34
|
-
context "when the base path is not set" do
|
35
|
-
let(:results){YAML.load_file("spec/fixtures/profiles/#{id}.yml")}
|
36
|
-
|
37
|
-
it "should perform requests to the 'profile'" do
|
38
|
-
client.should_receive(:get).with("/profiles/#{id}/").and_return(results)
|
39
|
-
subject.profile(id)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context "when the base path is set to 'id'" do
|
44
|
-
let(:results){YAML.load_file("spec/fixtures/profiles/#{id}.yml")}
|
45
|
-
subject{Stew::Community::CommunityClient.new({:client => client, :base_path => 'id'})}
|
46
|
-
|
47
|
-
it "should perform profile-requests to the 'id'" do
|
48
|
-
client.should_receive(:get).with("/id/#{id}/").and_return(results)
|
49
|
-
subject.profile(id)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe ".profile" do
|
55
|
-
let(:results){YAML.load_file("spec/fixtures/profiles/#{id}.yml")}
|
56
|
-
|
57
|
-
it "sends the correct message to its client" do
|
58
|
-
client.should_receive(:get).with("/profiles/#{id}/").and_return(results)
|
59
|
-
subject.profile(id)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "creates a profile object" do
|
63
|
-
client.stub(:get).with("/profiles/#{id}/").and_return(results)
|
64
|
-
Stew::Community::Profile.should_receive(:new).with(results['profile'])
|
65
|
-
subject.profile(id)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe ".profile_games" do
|
70
|
-
let(:results){YAML.load_file("spec/fixtures/profiles/games/#{id}.yml")}
|
71
|
-
|
72
|
-
it "sends the correct message to its client" do
|
73
|
-
client.should_receive(:get).with("/profiles/#{id}/games").and_return(results)
|
74
|
-
subject.profile_games(id)
|
75
|
-
end
|
76
|
-
|
77
|
-
it "creates a ProfileGames object" do
|
78
|
-
client.stub(:get).with("/profiles/#{id}/games").and_return(results)
|
79
|
-
Stew::Community::ProfileGames.should_receive(:new).with(results['gamesList']['games']['game'])
|
80
|
-
subject.profile_games(id)
|
81
|
-
end
|
82
|
-
|
83
|
-
context "when the profile has no games" do
|
84
|
-
let(:id){76561197994486912}
|
85
|
-
|
86
|
-
it "creates an empty ProfileGames instance if the profile has no games" do
|
87
|
-
client.stub(:get).with("/profiles/#{id}/games").and_return(results)
|
88
|
-
profile_games = subject.profile_games(id)
|
89
|
-
profile_games.entries.count.should eq 0
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe ".profile_friends" do
|
95
|
-
let(:results){YAML.load_file("spec/fixtures/profiles/friends/#{id}.yml")}
|
96
|
-
|
97
|
-
it "sends the correct message to its client" do
|
98
|
-
client.should_receive(:get).with("/profiles/#{id}/friends").and_return(results)
|
99
|
-
subject.profile_friends(id)
|
100
|
-
end
|
101
|
-
|
102
|
-
it "creates a ProfileFriends object" do
|
103
|
-
client.stub(:get).with("/profiles/#{id}/friends").and_return(results)
|
104
|
-
Stew::Community::ProfileFriends.should_receive(:new).with(results['friendsList']['friends']['friend'])
|
105
|
-
subject.profile_friends(id)
|
106
|
-
end
|
107
|
-
|
108
|
-
context "when the profile has no friends" do
|
109
|
-
let(:id){76561197994486912}
|
110
|
-
|
111
|
-
it "creates an empty ProfileFriends instance if the profile has no friends" do
|
112
|
-
client.stub(:get).with("/profiles/#{id}/friends").and_return(results)
|
113
|
-
profile_friends = subject.profile_friends(id)
|
114
|
-
profile_friends.entries.count.should eq 0
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Stew::Community::XmlClient" do
|
4
|
-
let(:uri){'http://steamcommunity.com'}
|
5
|
-
let(:results){YAML.load_file("spec/fixtures/profiles/#{id}.yml")}
|
6
|
-
let(:id){76561197992917668}
|
7
|
-
|
8
|
-
subject{Stew::Community::XmlClient.new(uri)}
|
9
|
-
|
10
|
-
describe "#get" do
|
11
|
-
context "when no error is found in the reply" do
|
12
|
-
let(:path){"/profiles/#{id}"}
|
13
|
-
|
14
|
-
before :each do
|
15
|
-
stub_request(:get, "http://steamcommunity.com/profiles/#{id}?xml=1").to_return(File.new("spec/fixtures/profiles/#{id}.txt"))
|
16
|
-
end
|
17
|
-
|
18
|
-
it "returns the response" do
|
19
|
-
subject.get(path).should eq results
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "when an error is found in the reply" do
|
24
|
-
let(:id){"4d"}
|
25
|
-
let(:path){"/profiles/#{id}"}
|
26
|
-
|
27
|
-
before :each do
|
28
|
-
stub_request(:get, "http://steamcommunity.com/profiles/#{id}?xml=1").to_return(File.new("spec/fixtures/profiles/#{id}.txt"))
|
29
|
-
end
|
30
|
-
|
31
|
-
it "throws an ObjectNotFound error" do
|
32
|
-
expect{subject.get(path).should}.to raise_error(Stew::Community::XmlClient::ObjectNotFoundError)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|