diff --git a/Gemfile.lock b/Gemfile.lock index 4be1dda4..b8022af7 100644 --- a/Gemfile.lock +++ b/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) diff --git a/lib/fb_graph/score.rb b/lib/fb_graph/score.rb index a59befae..cba3b560 100644 --- a/lib/fb_graph/score.rb +++ b/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 @@ -11,7 +11,6 @@ def initialize(identifier, attributes = {}) @application = Application.new(app[:id], app) end @score = attributes[:score] - @type = attributes[:type] end end end \ No newline at end of file diff --git a/spec/fb_graph/connections/scores_spec.rb b/spec/fb_graph/connections/scores_spec.rb new file mode 100644 index 00000000..7579f28f --- /dev/null +++ b/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 diff --git a/spec/mock_json/users/scores/sample.json b/spec/mock_json/users/scores/sample.json new file mode 100644 index 00000000..8a9248c2 --- /dev/null +++ b/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" + } + }] +} \ No newline at end of file