snafu 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/Guardfile +10 -0
- data/LICENSE +7 -0
- data/README.textile +65 -0
- data/Rakefile +6 -0
- data/lib/snafu.rb +6 -0
- data/lib/snafu/client.rb +68 -0
- data/lib/snafu/locations.rb +32 -0
- data/lib/snafu/models.rb +4 -0
- data/lib/snafu/models/glitch_image.rb +17 -0
- data/lib/snafu/models/hub.rb +32 -0
- data/lib/snafu/models/location.rb +17 -0
- data/lib/snafu/models/street.rb +41 -0
- data/lib/snafu/version.rb +3 -0
- data/snafu.gemspec +31 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Client/call_should_accept_a_hash_of_POST_arguments.yml +39 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if.yml +36 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_authenticate.yml +36 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_authenticate_called_with_true.yml +36 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_called_with_authenticate.yml +36 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_called_with_authenticate_true.yml +36 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_called_with_true.yml +36 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Client/call_should_raise_a_GlitchAPIError_if_receiving_an_unsucessful_response_from_the_Glitch_API.yml +36 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Locations/get_hub_should_return_a_valid_hub_if_given_a_valid_Hub_ID.yml +39 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Locations/get_hubs_should_populated_the_returned_Hub_objects_with_an_id_and_name.yml +39 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Locations/get_hubs_should_return_an_array_of_Hub_objects.yml +39 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Locations/get_hubs_should_return_an_array_of_all_hubs.yml +39 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Locations/get_street_should_return_a_complete_street_if_given_a_valid_street_ID.yml +40 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Models_Hub/initialize_should_populate_values_if_given_the_raw_JSON_response_from_HTTParty.yml +39 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Models_Hub/initialize_should_populate_values_if_given_the_raw_response_from_Glitch.yml +39 -0
- data/spec/fixtures/vcr_cassettes/Snafu_Models_Street/initialize_should_populate_values_if_given_the_raw_JSON_response_from_HTTParty.yml +40 -0
- data/spec/fixtures/vcr_cassettes/calendar_getHoldays/valid_calendar.yml +39 -0
- data/spec/snafu/client_spec.rb +41 -0
- data/spec/snafu/locations_spec.rb +55 -0
- data/spec/snafu/models/glitch_image_spec.rb +36 -0
- data/spec/snafu/models/hub_spec.rb +43 -0
- data/spec/snafu/models/street_spec.rb +81 -0
- data/spec/snafu/models_spec.rb +9 -0
- data/spec/snafu_spec.rb +14 -0
- data/spec/spec_helper.rb +28 -0
- metadata +179 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://api.glitch.com:80/simple/locations.getStreets?hub_id=27
|
6
|
+
body: !!null
|
7
|
+
headers: !!null
|
8
|
+
response: !ruby/struct:VCR::Response
|
9
|
+
status: !ruby/struct:VCR::ResponseStatus
|
10
|
+
code: 200
|
11
|
+
message: OK
|
12
|
+
headers:
|
13
|
+
access-control-allow-credentials:
|
14
|
+
- 'false'
|
15
|
+
access-control-allow-methods:
|
16
|
+
- POST, GET, OPTIONS
|
17
|
+
access-control-allow-origin:
|
18
|
+
- ! '*'
|
19
|
+
access-control-max-age:
|
20
|
+
- '1728000'
|
21
|
+
cache-control:
|
22
|
+
- no-cache="set-cookie"
|
23
|
+
content-type:
|
24
|
+
- text/plain; charset=utf-8
|
25
|
+
date:
|
26
|
+
- Thu, 01 Dec 2011 01:35:07 GMT
|
27
|
+
server:
|
28
|
+
- Apache/2.2.17
|
29
|
+
set-cookie:
|
30
|
+
- AWSELB=F7715B6B10BD5947A6E9DAE19D6F6DD7D91A271FB744B8EE156EEC745EF275A9089C697163F6DA6B492CB3CBE399C5977DF92D1F3093BD75659503606D3AB37D325E15FFCF;PATH=/;MAX-AGE=600
|
31
|
+
content-length:
|
32
|
+
- '329'
|
33
|
+
connection:
|
34
|
+
- Close
|
35
|
+
body: ! '{"ok":1,"hub_id":"27","name":"Ix","streets":{"LM416LNIKVLM1":{"name":"Baby
|
36
|
+
Steppes"},"LM413SQ6LRN58":{"name":"East Spice"},"LM410QQ0CHARO":{"name":"Flipside"},"LM4115NJ46G8M":{"name":"Groddle
|
37
|
+
Ladder"},"LM4109NI2R640":{"name":"Guillermo Gamera Way"},"LM410TMR0S2S1":{"name":"Ruta
|
38
|
+
Asuncion"},"LM413RQ6LRG9N":{"name":"West Spice"}}}'
|
39
|
+
http_version: '1.1'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://api.glitch.com:80/simple/locations.streetInfo?street_tsid=LM416LNIKVLM1
|
6
|
+
body: !!null
|
7
|
+
headers: !!null
|
8
|
+
response: !ruby/struct:VCR::Response
|
9
|
+
status: !ruby/struct:VCR::ResponseStatus
|
10
|
+
code: 200
|
11
|
+
message: OK
|
12
|
+
headers:
|
13
|
+
access-control-allow-credentials:
|
14
|
+
- 'false'
|
15
|
+
access-control-allow-methods:
|
16
|
+
- POST, GET, OPTIONS
|
17
|
+
access-control-allow-origin:
|
18
|
+
- ! '*'
|
19
|
+
access-control-max-age:
|
20
|
+
- '1728000'
|
21
|
+
cache-control:
|
22
|
+
- no-cache="set-cookie"
|
23
|
+
content-type:
|
24
|
+
- text/plain; charset=utf-8
|
25
|
+
date:
|
26
|
+
- Thu, 01 Dec 2011 02:08:10 GMT
|
27
|
+
server:
|
28
|
+
- Apache/2.2.17
|
29
|
+
set-cookie:
|
30
|
+
- AWSELB=F7715B6B10BD5947A6E9DAE19D6F6DD7D91A271FB7C65A13E6B150AA38A20996585FE1291DCF151568D701ED5E98FEE24FF052B412CF84A57C93B1B6B2555103165F28F773;PATH=/;MAX-AGE=600
|
31
|
+
content-length:
|
32
|
+
- '685'
|
33
|
+
connection:
|
34
|
+
- Close
|
35
|
+
body: ! '{"ok":1,"tsid":"LM416LNIKVLM1","name":"Baby Steppes","hub":{"id":27,"name":"Ix"},"mote":{"id":9,"name":"Ur"},"active_project":false,"features":["<b>5
|
36
|
+
Piggies<\/b>, <b>2 Butterflies<\/b>, <b>9 Chickens<\/b>, <b>5 Spice Plants<\/b>,
|
37
|
+
and <b>1 Gas Plant<\/b>."],"connections":{"LM4115NJ46G8M":{"name":"Groddle Ladder","hub":{"id":27,"name":"Ix"},"mote":{"id":9,"name":"Ur"}},"LM410TMR0S2S1":{"name":"Ruta
|
38
|
+
Asuncion","hub":{"id":27,"name":"Ix"},"mote":{"id":9,"name":"Ur"}},"LM4109NI2R640":{"name":"Guillermo
|
39
|
+
Gamera Way","hub":{"id":27,"name":"Ix"},"mote":{"id":9,"name":"Ur"}}},"image":{"url":"http:\/\/c2.glitch.bz\/streets\/2011-11-27\/LM416LNIKVLM1_main_1322382945.jpg","w":720,"h":120}}'
|
40
|
+
http_version: '1.1'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://api.glitch.com:80/simple/calendar.getHolidays
|
6
|
+
body: !!null
|
7
|
+
headers: !!null
|
8
|
+
response: !ruby/struct:VCR::Response
|
9
|
+
status: !ruby/struct:VCR::ResponseStatus
|
10
|
+
code: 200
|
11
|
+
message: OK
|
12
|
+
headers:
|
13
|
+
access-control-allow-credentials:
|
14
|
+
- 'false'
|
15
|
+
access-control-allow-methods:
|
16
|
+
- POST, GET, OPTIONS
|
17
|
+
access-control-allow-origin:
|
18
|
+
- ! '*'
|
19
|
+
access-control-max-age:
|
20
|
+
- '1728000'
|
21
|
+
cache-control:
|
22
|
+
- no-cache="set-cookie"
|
23
|
+
content-type:
|
24
|
+
- text/plain; charset=utf-8
|
25
|
+
date:
|
26
|
+
- Thu, 01 Dec 2011 01:34:57 GMT
|
27
|
+
server:
|
28
|
+
- Apache/2.2.17
|
29
|
+
set-cookie:
|
30
|
+
- AWSELB=F7715B6B10BD5947A6E9DAE19D6F6DD7D91A271FB7C136A73584C8A9C7D99844891B9CE40943A67B18C55CD05576680FE8CB8ED1442E532BB1DB467DE7995571EE672126B5;PATH=/;MAX-AGE=600
|
31
|
+
content-length:
|
32
|
+
- '438'
|
33
|
+
connection:
|
34
|
+
- Close
|
35
|
+
body: ! '{"ok":1,"days":[{"month":1,"day":5,"name":"AlphCon"},{"month":2,"day":2,"name":"Lemadan"},{"month":3,"day":3,"name":"Pot
|
36
|
+
Twoday"},{"month":4,"day":2,"name":"Root"},{"month":4,"day":3,"name":"Root"},{"month":4,"day":4,"name":"Root"},{"month":4,"day":11,"name":"Sprinkling"},{"month":6,"day":17,"name":"Croppaday"},{"month":7,"day":1,"name":"Belabor
|
37
|
+
Day"},{"month":8,"day":37,"name":"Zilloween"},{"month":11,"day":11,"name":"Recurse
|
38
|
+
Eve"}]}'
|
39
|
+
http_version: '1.1'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Snafu::Client do
|
4
|
+
before(:each) do
|
5
|
+
@snafu = Snafu.new(:api_key => GLITCH_API_KEY, :oauth_token => GLITCH_OAUTH_TOKEN)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'call()' do
|
9
|
+
it 'should receive a successful response from the Glitch API if given an valid method', :vcr do
|
10
|
+
VCR.use_cassette "calendar.getHoldays/valid_calendar" do
|
11
|
+
result = @snafu.call("calendar.getHolidays")
|
12
|
+
result['ok'].should eql(1)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should raise a GlitchAPIError if receiving an unsucessful response from the Glitch API', :vcr do
|
17
|
+
expect { @snafu.call("badmethod") }.to raise_error(Snafu::GlitchAPIError)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should accept a hash of POST arguments', :vcr do
|
21
|
+
hub_id = "27"
|
22
|
+
hub_name = "Ix"
|
23
|
+
result = @snafu.call("locations.getStreets", {:hub_id => "27"})
|
24
|
+
result["name"].should eql(hub_name)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should automatically pass in the oauth token if called with authenticate", :vcr do
|
28
|
+
expect { response = @snafu.call("players.stats", :authenticate => true) }.to_not raise_exception
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "authentication" do
|
33
|
+
describe "call()" do
|
34
|
+
context "without oauth token"
|
35
|
+
it "should raise a GlitchAPIError if trying to do an authenticated call without an oauth token" do
|
36
|
+
snafu = Snafu.new()
|
37
|
+
expect { snafu.call("secureMethod", :authenticate => true) }.to raise_error(Snafu::GlitchAPIError, /oauth token/)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Snafu::Locations do
|
4
|
+
before(:each) do
|
5
|
+
@snafu = Snafu.new(:api_key => GLITCH_API_KEY, :oauth_token => GLITCH_OAUTH_TOKEN)
|
6
|
+
@test_hub_id = 27
|
7
|
+
@test_hub_name = "Ix"
|
8
|
+
@test_street_id = "LM416LNIKVLM1"
|
9
|
+
@test_street_name = "Baby Steppes"
|
10
|
+
end
|
11
|
+
|
12
|
+
context "get_hubs()" do
|
13
|
+
before(:each) do
|
14
|
+
@hubs = @snafu.get_hubs
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return an array of all hubs", :vcr do
|
18
|
+
@hubs.should_not be_empty
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return an array of Hub objects", :vcr do
|
22
|
+
@hubs.first.should be_a Snafu::Models::Hub
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should populated the returned Hub objects with an id and name", :vcr do
|
26
|
+
first_hub = @hubs.first
|
27
|
+
first_hub.id.should_not be_nil
|
28
|
+
first_hub.name.should_not be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "get_hub" do
|
33
|
+
it "should return a valid hub if given a valid Hub ID", :vcr do
|
34
|
+
hub = @snafu.get_hub(@test_hub_id)
|
35
|
+
hub.name.should eql(@test_hub_name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "get_street" do
|
40
|
+
before(:each) do
|
41
|
+
@test_street = @snafu.get_street(@test_street_id)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should return a complete street if given a valid street ID", :vcr do
|
45
|
+
@test_street.id.should_not be_nil
|
46
|
+
@test_street.name.should_not be_nil
|
47
|
+
@test_street.mote.should_not be_nil
|
48
|
+
@test_street.active_project?.should_not be_nil
|
49
|
+
@test_street.connections.should_not be_empty
|
50
|
+
@test_street.image.url.should_not be_nil
|
51
|
+
@test_street.image.width.should_not be_nil
|
52
|
+
@test_street.image.height.should_not be_nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Snafu
|
4
|
+
module Models
|
5
|
+
describe Snafu::Models::GlitchImage do
|
6
|
+
before(:each) do
|
7
|
+
@valid_image = GlitchImage.new(
|
8
|
+
:url => "http://example.com",
|
9
|
+
:width => 100,
|
10
|
+
:height => 100
|
11
|
+
)
|
12
|
+
end
|
13
|
+
context "initialize()" do
|
14
|
+
it "should retain all parameters" do
|
15
|
+
@valid_image.url.should_not be_nil
|
16
|
+
@valid_image.height.should be > 0
|
17
|
+
@valid_image.width.should be > 0
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should convert a string width argument into an integer" do
|
21
|
+
glitch_image = GlitchImage.new(
|
22
|
+
:width => "100"
|
23
|
+
)
|
24
|
+
glitch_image.width.should be_a Integer
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should convert a string height argument into an integer" do
|
28
|
+
glitch_image = GlitchImage.new(
|
29
|
+
:height => "100"
|
30
|
+
)
|
31
|
+
glitch_image.height.should be_a Integer
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Snafu
|
4
|
+
module Models
|
5
|
+
describe Snafu::Models::Hub do
|
6
|
+
context "initialize()" do
|
7
|
+
it "should populate values if given an options hash" do
|
8
|
+
expected_id = "1"
|
9
|
+
expected_name = "Some Hub"
|
10
|
+
expected_street = {:id => "2", :name => "Some Street"}
|
11
|
+
new_hub = Hub.new(
|
12
|
+
:id => expected_id,
|
13
|
+
:name => expected_name,
|
14
|
+
:streets => expected_street
|
15
|
+
)
|
16
|
+
new_hub.id.should eql(expected_id)
|
17
|
+
new_hub.name.should eql(expected_name)
|
18
|
+
new_hub.streets.first.should eql(expected_street)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should populate values if given the raw JSON response from HTTParty", :vcr do
|
22
|
+
glitch_client = Snafu.new(:api_key => GLITCH_API_KEY, :oauth_token => GLITCH_OAUTH_TOKEN)
|
23
|
+
glitch_response = glitch_client.call("locations.getStreets", :hub_id => 27)
|
24
|
+
new_hub = Hub.new(glitch_response)
|
25
|
+
new_hub.streets.should_not be_nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should accept an array for the :streets parameter" do
|
29
|
+
expected_value = [{:id => "2", :name => "Some Street"}]
|
30
|
+
new_hub = Hub.new(:streets => expected_value)
|
31
|
+
new_hub.streets.should eql(expected_value)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should accept a hash for the :streets parameter" do
|
35
|
+
street_hash = {:id => "2", :name => "Some Street"}
|
36
|
+
expected_value = [street_hash]
|
37
|
+
new_hub = Hub.new(:streets => street_hash)
|
38
|
+
new_hub.streets.should eql(expected_value)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Snafu
|
4
|
+
module Models
|
5
|
+
describe Snafu::Models::Street do
|
6
|
+
before(:each) do
|
7
|
+
@snafu = Snafu.new(:api_key => GLITCH_API_KEY, :oauth_token => GLITCH_OAUTH_TOKEN)
|
8
|
+
@test_hub_id = 27
|
9
|
+
@test_hub_name = "Ix"
|
10
|
+
@test_street_id = "LM416LNIKVLM1"
|
11
|
+
@test_street_name = "Baby Steppes"
|
12
|
+
end
|
13
|
+
context "initialize()" do
|
14
|
+
it "should populate values if given an options hash", :vcr do
|
15
|
+
expected_id = "1"
|
16
|
+
expected_name = "Some street"
|
17
|
+
expected_hub = Hub.new(:id => "2", :name => "Some Hub")
|
18
|
+
expected_connections = [Street.new(:id => "3", :name => "Connected Street")]
|
19
|
+
expected_mote = Hub.new(:id => "4", :name => "Some Mote")
|
20
|
+
expected_features = "some features"
|
21
|
+
expected_image = GlitchImage.new(:url => "http://example.com/image.png", :width => "100", :height => "100")
|
22
|
+
expected_active_project = false
|
23
|
+
new_street = Street.new(
|
24
|
+
:id => expected_id,
|
25
|
+
:name => expected_name,
|
26
|
+
:hub => expected_hub,
|
27
|
+
:features => expected_features,
|
28
|
+
:connections => expected_connections,
|
29
|
+
:active_project => expected_active_project,
|
30
|
+
:mote => expected_mote,
|
31
|
+
:image => expected_image,
|
32
|
+
)
|
33
|
+
|
34
|
+
new_street.id.should eql(expected_id)
|
35
|
+
new_street.name.should eql(expected_name)
|
36
|
+
new_street.hub.should eql(expected_hub)
|
37
|
+
new_street.features.should eql(expected_features)
|
38
|
+
new_street.connections.should eql(expected_connections)
|
39
|
+
new_street.mote.should eql(expected_mote)
|
40
|
+
new_street.image.should eql(expected_image)
|
41
|
+
new_street.active_project.should eql(expected_active_project)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should populate values if given the raw JSON response from HTTParty", :vcr do
|
45
|
+
response = @snafu.call("locations.streetInfo", :street_tsid => @test_street_id)
|
46
|
+
expected_id = response["tsid"]
|
47
|
+
expected_name = response["name"]
|
48
|
+
expected_hub = Hub.new(:id => response["hub"]["id"], :name => response["hub"]["name"])
|
49
|
+
expected_features = response["features"]
|
50
|
+
expected_connections = []
|
51
|
+
response["connections"].each do |street_id, street|
|
52
|
+
expected_connections << Street.new(
|
53
|
+
:id => street_id,
|
54
|
+
:name => street["name"],
|
55
|
+
:hub => Hub.new(:id => response["hub"]["id"], :name => response["hub"]["name"]),
|
56
|
+
:mote => Hub.new(:id => response["mote"]["id"], :name => response["mote"]["name"]),
|
57
|
+
)
|
58
|
+
end
|
59
|
+
expected_mote = Hub.new(:id => response["mote"]["id"], :name => response["mote"]["name"])
|
60
|
+
expected_image = GlitchImage.new(
|
61
|
+
:url => response["image"]["url"],
|
62
|
+
:width => response["image"]["w"],
|
63
|
+
:height => response["image"]["h"]
|
64
|
+
)
|
65
|
+
expected_active_project = response["active_project"]
|
66
|
+
|
67
|
+
new_street = Street.new(response)
|
68
|
+
|
69
|
+
new_street.id.should eql(expected_id)
|
70
|
+
new_street.name.should eql(expected_name)
|
71
|
+
new_street.hub.name.should eql(expected_hub.name)
|
72
|
+
new_street.features.should eql(expected_features)
|
73
|
+
new_street.connections.count.should eql(expected_connections.count)
|
74
|
+
new_street.mote.name.should eql(expected_mote.name)
|
75
|
+
new_street.image.url.should eql(expected_image.url)
|
76
|
+
new_street.active_project.should eql(expected_active_project)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Snafu::Models::Hub do
|
4
|
+
it "should retain the ID & Name of the hub if given a valid " do
|
5
|
+
hub = Snafu::Models::Hub.new(:id => @test_hub_id, :name => @test_hub_name)
|
6
|
+
hub.id.should eql(@test_hub_id)
|
7
|
+
hub.name.should eql(@test_hub_name)
|
8
|
+
end
|
9
|
+
end
|
data/spec/snafu_spec.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Snafu do
|
4
|
+
|
5
|
+
it "should return a Snafu::Client object if supplied with valid parameters" do
|
6
|
+
glitch_client = Snafu.new({:oauth_token => GLITCH_OAUTH_TOKEN})
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should retain the Oauth Token" do
|
10
|
+
test_oauth_token = GLITCH_OAUTH_TOKEN
|
11
|
+
glitch_client = Snafu.new(:api_key => GLITCH_API_KEY, :oauth_token => GLITCH_OAUTH_TOKEN)
|
12
|
+
glitch_client.oauth_token.should eql(test_oauth_token)
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'snafu'
|
2
|
+
require 'vcr'
|
3
|
+
require 'api_key' if File.exists?(File.dirname(__FILE__) + "/api_key.rb")
|
4
|
+
|
5
|
+
VCR.config do |config|
|
6
|
+
TWO_WEEKS = 14 * 24 * 60 * 60 # or use 7.days if you're using ActiveSupport
|
7
|
+
config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
8
|
+
config.stub_with :fakeweb
|
9
|
+
config.default_cassette_options = { :re_record_interval => TWO_WEEKS }
|
10
|
+
#config.allow_http_connections_when_no_cassette = true
|
11
|
+
end
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.filter_run_excluding :broken => true
|
15
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
16
|
+
config.around(:each, :vcr) do |example|
|
17
|
+
name = example.metadata[:full_description].split(/\s+/, 2).join("/").gsub(/[^\w\/]+/, "_")
|
18
|
+
VCR.use_cassette(name) { example.call }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if !defined? GLITCH_API_KEY
|
23
|
+
GLITCH_API_KEY = "testing-key"
|
24
|
+
end
|
25
|
+
|
26
|
+
if !defined? GLITCH_OAUTH_TOKEN
|
27
|
+
GLITCH_OAUTH_TOKEN = "testing-token"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: snafu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jeff Browning
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-02 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70150468761000 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70150468761000
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: guard-rspec
|
27
|
+
requirement: &70150468759880 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70150468759880
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: vcr
|
38
|
+
requirement: &70150468758380 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70150468758380
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: fakeweb
|
49
|
+
requirement: &70150468757000 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70150468757000
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rake
|
60
|
+
requirement: &70150468755220 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70150468755220
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: httparty
|
71
|
+
requirement: &70150468753980 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.8'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70150468753980
|
80
|
+
description: ! "Snafu is an interface to the Glitch API. Glitch is an online \n multi-player
|
81
|
+
game created by Tiny Speck."
|
82
|
+
email:
|
83
|
+
- jeff@jkbrowning.com
|
84
|
+
executables: []
|
85
|
+
extensions: []
|
86
|
+
extra_rdoc_files: []
|
87
|
+
files:
|
88
|
+
- .gitignore
|
89
|
+
- Gemfile
|
90
|
+
- Guardfile
|
91
|
+
- LICENSE
|
92
|
+
- README.textile
|
93
|
+
- Rakefile
|
94
|
+
- lib/snafu.rb
|
95
|
+
- lib/snafu/client.rb
|
96
|
+
- lib/snafu/locations.rb
|
97
|
+
- lib/snafu/models.rb
|
98
|
+
- lib/snafu/models/glitch_image.rb
|
99
|
+
- lib/snafu/models/hub.rb
|
100
|
+
- lib/snafu/models/location.rb
|
101
|
+
- lib/snafu/models/street.rb
|
102
|
+
- lib/snafu/version.rb
|
103
|
+
- snafu.gemspec
|
104
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_accept_a_hash_of_POST_arguments.yml
|
105
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if.yml
|
106
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_authenticate.yml
|
107
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_authenticate_called_with_true.yml
|
108
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_called_with_authenticate.yml
|
109
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_called_with_authenticate_true.yml
|
110
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_called_with_true.yml
|
111
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_raise_a_GlitchAPIError_if_receiving_an_unsucessful_response_from_the_Glitch_API.yml
|
112
|
+
- spec/fixtures/vcr_cassettes/Snafu_Locations/get_hub_should_return_a_valid_hub_if_given_a_valid_Hub_ID.yml
|
113
|
+
- spec/fixtures/vcr_cassettes/Snafu_Locations/get_hubs_should_populated_the_returned_Hub_objects_with_an_id_and_name.yml
|
114
|
+
- spec/fixtures/vcr_cassettes/Snafu_Locations/get_hubs_should_return_an_array_of_Hub_objects.yml
|
115
|
+
- spec/fixtures/vcr_cassettes/Snafu_Locations/get_hubs_should_return_an_array_of_all_hubs.yml
|
116
|
+
- spec/fixtures/vcr_cassettes/Snafu_Locations/get_street_should_return_a_complete_street_if_given_a_valid_street_ID.yml
|
117
|
+
- spec/fixtures/vcr_cassettes/Snafu_Models_Hub/initialize_should_populate_values_if_given_the_raw_JSON_response_from_HTTParty.yml
|
118
|
+
- spec/fixtures/vcr_cassettes/Snafu_Models_Hub/initialize_should_populate_values_if_given_the_raw_response_from_Glitch.yml
|
119
|
+
- spec/fixtures/vcr_cassettes/Snafu_Models_Street/initialize_should_populate_values_if_given_the_raw_JSON_response_from_HTTParty.yml
|
120
|
+
- spec/fixtures/vcr_cassettes/calendar_getHoldays/valid_calendar.yml
|
121
|
+
- spec/snafu/client_spec.rb
|
122
|
+
- spec/snafu/locations_spec.rb
|
123
|
+
- spec/snafu/models/glitch_image_spec.rb
|
124
|
+
- spec/snafu/models/hub_spec.rb
|
125
|
+
- spec/snafu/models/street_spec.rb
|
126
|
+
- spec/snafu/models_spec.rb
|
127
|
+
- spec/snafu_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
homepage: https://github.com/jbrowning/snafu
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 1.9.2
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
144
|
+
requirements:
|
145
|
+
- - ! '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project: snafu
|
150
|
+
rubygems_version: 1.8.10
|
151
|
+
signing_key:
|
152
|
+
specification_version: 3
|
153
|
+
summary: A library for the Glitch API
|
154
|
+
test_files:
|
155
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_accept_a_hash_of_POST_arguments.yml
|
156
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if.yml
|
157
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_authenticate.yml
|
158
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_authenticate_called_with_true.yml
|
159
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_called_with_authenticate.yml
|
160
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_called_with_authenticate_true.yml
|
161
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_automatically_pass_in_the_oauth_token_if_called_with_true.yml
|
162
|
+
- spec/fixtures/vcr_cassettes/Snafu_Client/call_should_raise_a_GlitchAPIError_if_receiving_an_unsucessful_response_from_the_Glitch_API.yml
|
163
|
+
- spec/fixtures/vcr_cassettes/Snafu_Locations/get_hub_should_return_a_valid_hub_if_given_a_valid_Hub_ID.yml
|
164
|
+
- spec/fixtures/vcr_cassettes/Snafu_Locations/get_hubs_should_populated_the_returned_Hub_objects_with_an_id_and_name.yml
|
165
|
+
- spec/fixtures/vcr_cassettes/Snafu_Locations/get_hubs_should_return_an_array_of_Hub_objects.yml
|
166
|
+
- spec/fixtures/vcr_cassettes/Snafu_Locations/get_hubs_should_return_an_array_of_all_hubs.yml
|
167
|
+
- spec/fixtures/vcr_cassettes/Snafu_Locations/get_street_should_return_a_complete_street_if_given_a_valid_street_ID.yml
|
168
|
+
- spec/fixtures/vcr_cassettes/Snafu_Models_Hub/initialize_should_populate_values_if_given_the_raw_JSON_response_from_HTTParty.yml
|
169
|
+
- spec/fixtures/vcr_cassettes/Snafu_Models_Hub/initialize_should_populate_values_if_given_the_raw_response_from_Glitch.yml
|
170
|
+
- spec/fixtures/vcr_cassettes/Snafu_Models_Street/initialize_should_populate_values_if_given_the_raw_JSON_response_from_HTTParty.yml
|
171
|
+
- spec/fixtures/vcr_cassettes/calendar_getHoldays/valid_calendar.yml
|
172
|
+
- spec/snafu/client_spec.rb
|
173
|
+
- spec/snafu/locations_spec.rb
|
174
|
+
- spec/snafu/models/glitch_image_spec.rb
|
175
|
+
- spec/snafu/models/hub_spec.rb
|
176
|
+
- spec/snafu/models/street_spec.rb
|
177
|
+
- spec/snafu/models_spec.rb
|
178
|
+
- spec/snafu_spec.rb
|
179
|
+
- spec/spec_helper.rb
|