Skip to content

Commit

Permalink
add scores specs and remove "type" attributes nov#124
Browse files Browse the repository at this point in the history
  • Loading branch information
nov committed Dec 15, 2011
1 parent 1829284 commit 36cba01
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
fb_graph (2.2.2)
fb_graph (2.2.3)
httpclient (>= 2.2.0.2)
rack-oauth2 (>= 0.9.4)

Expand Down
3 changes: 1 addition & 2 deletions lib/fb_graph/score.rb
@@ -1,6 +1,6 @@
module FbGraph
class Score < Node
attr_accessor :user, :score, :application, :type
attr_accessor :user, :score, :application

def initialize(identifier, attributes = {})
super
Expand All @@ -11,7 +11,6 @@ def initialize(identifier, attributes = {})
@application = Application.new(app[:id], app)
end
@score = attributes[:score]
@type = attributes[:type]
end
end
end
40 changes: 40 additions & 0 deletions spec/fb_graph/connections/scores_spec.rb
@@ -0,0 +1,40 @@
require 'spec_helper'

describe FbGraph::Connections::Scores do
let(:user) { FbGraph::User.new('matake', :access_token => 'user_access_token') }
let(:app) { FbGraph::Application.new('FbGraph', :access_token => 'app_access_token') }

describe '#scores' do
it 'should return an Array of Score' do
mock_graph :get, 'matake/scores', 'users/scores/sample', :access_token => 'user_access_token' do
scores = user.scores
scores.should be_a Array
scores.should_not be_blank
scores.each do |score|
score.should be_instance_of FbGraph::Score
score.user.should be_instance_of FbGraph::User
score.application.should be_instance_of FbGraph::Application
score.score.should be_a Integer
end
end
end
end

describe '#score!' do
it 'should return true' do
mock_graph :post, 'matake/scores', 'true', :access_token => 'app_access_token', :params => {
:score => '10'
} do
user.score!(10, :access_token => app.access_token).should be_true
end
end
end

describe '#unscore!' do
it 'should return true' do
mock_graph :delete, 'matake/scores', 'true', :access_token => 'app_access_token' do
user.unscore!(:access_token => app.access_token).should be_true
end
end
end
end
15 changes: 15 additions & 0 deletions spec/mock_json/users/scores/sample.json
@@ -0,0 +1,15 @@
{
"data": [{
"user": {
"name": "Nov Matake",
"id": "579612276"
},
"score": 10,
"application": {
"name": "gem sample",
"canvas_name": "fbgraphsample",
"namespace": "fbgraphsample",
"id": "134145643294322"
}
}]
}

0 comments on commit 36cba01

Please sign in to comment.