Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added tests and implement Client#event
  • Loading branch information
John Ford authored and mmangino committed May 3, 2010
1 parent 118894e commit 6f29574
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/mogli/client.rb
@@ -1,3 +1,4 @@
require "mogli/client/event"
require "mogli/client/user"
require "ruby-debug"

Expand All @@ -8,6 +9,7 @@ class Client
attr_reader :expiration

include HTTParty
include Mogli::Client::Event
include Mogli::Client::User
class UnrecognizeableClassError < Exception; end

Expand Down Expand Up @@ -133,4 +135,4 @@ def to_yaml( opts = {} )#nodoc
end

end
end
end
11 changes: 11 additions & 0 deletions lib/mogli/client/event.rb
@@ -0,0 +1,11 @@
module Mogli
class Client
module Event


def event(id)
get_and_map(id,Mogli::Event)
end
end
end
end
12 changes: 12 additions & 0 deletions spec/client/client_event_spec.rb
@@ -0,0 +1,12 @@
require "spec_helper"
describe Mogli::Client do
let :client do
Mogli::Client.new
end

it "fetches an event by id" do
client.should_receive(:get_and_map).with(118515001510745,Mogli::Event).and_return("event")
client.event(118515001510745).should == "event"
end

end
34 changes: 34 additions & 0 deletions spec/event_spec.rb
@@ -0,0 +1,34 @@
require "spec_helper"
describe Mogli::Event do

let :event_1 do
event_1 = Mogli::Event.new(:id=>1)
event_1.client = mock_client
event_1
end

let :mock_client do
mock("client")
end

it "allow setting the client" do
event = Mogli::Event.new
event.client = "client"
event.client.should == "client"
end

it "have a noreply attribute which fetches when called" do
mock_client.should_receive(:get_and_map).with("/1/noreply","User").and_return("noreply")
event_1.noreply.should == "noreply"
end

it "only fetch noreply once" do
mock_client.should_receive(:get_and_map).once.with("/1/noreply","User").and_return([])
event_1.noreply
event_1.noreply
end

it "will recognize itself" do
Mogli::Event.recognize?("id"=>1,"name"=>"Ruby Hackfest")
end
end

0 comments on commit 6f29574

Please sign in to comment.