forked from mmangino/mogli
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added tests and implement Client#event
- Loading branch information
Showing
4 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Mogli | ||
class Client | ||
module Event | ||
|
||
|
||
def event(id) | ||
get_and_map(id,Mogli::Event) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |