spec/message_spec.rb in socialcastr-0.1.3 vs spec/message_spec.rb in socialcastr-0.2.0

- old
+ new

@@ -31,14 +31,10 @@ it "should have a collection of groups" do @message.groups.class.should == Array end - it "should belong to a well formed group" do - @message.groups.first.class.should == Socialcastr::Group - end - it "should have a source" do @message.source.should_not be_nil @message.source.class.should == Socialcastr::Source end @@ -49,12 +45,12 @@ fake_socialcast_api_for(:messages) do @messages = Socialcastr::Message.all end end - it "should be an instance of MessageList" do - @messages.class.should == MessageList + it "should be an instance of Array" do + @messages.class.should == Array end it "should be a collection of 20 Socialcastr::Message objects" do @messages.size.should == 20 end @@ -73,11 +69,11 @@ before :each do fake_socialcast_api_for(:message) do @message = Socialcastr::Message.find(425) end @api = mock(:api) - response = "<flag><id>3333</id></flag>" + response = "<flag><id type='integer'>3333</id></flag>" Socialcastr::Message.stub!(:api).and_return(@api) @api.stub!(:post).and_return(response) end it "should assign an id to the Flag" do @@ -89,13 +85,18 @@ before :each do @message.flag! @api.should_receive(:delete).with("/messages/425/flags/3333").and_return("") end + it "should not be flagged afterwards" do + @message.unflag! + @message.flagged?.should be_false + end + it "should not have a flag afterwards" do @message.unflag! - @message.flag.id.should be_nil + @message.flag.should be_nil end end end context 'liking a message' do @@ -103,11 +104,11 @@ fake_socialcast_api_for :message do @message = Socialcastr::Message.find(425) end @api = mock(:api) - response = "<like><id>2222</id><unlikable>true</unlikable></like>" + response = "<like><id type='integer'>2222</id><unlikable>true</unlikable></like>" Socialcastr::Message.stub!(:api).and_return(@api) @api.stub!(:post).and_return(response) end it 'should create a new like' do @@ -122,20 +123,21 @@ end end context "unliking a message" do before :each do - fake_socialcast_api_for :message do + fake_socialcast_api_for :message do @message = Socialcastr::Message.find(425) end @api = mock(:api) response = "<like><id>2222</id><unlikable>true</unlikable></like>" Socialcastr::Message.stub!(:api).and_return(@api) @api.stub!(:post).and_return(response) @api.stub!(:delete).and_return("") @message.like! + @message.likes.count.should == 1 end it "should remove a like" do old_count = @message.likes.count @message.unlike! @@ -143,15 +145,16 @@ end end context "searching for messages matching 'trying'" do before :each do - fake_socialcast_api_for :message + fake_socialcast_api_for :messages end it "should return a message" do - @messages = Socialcastr::Message.search(:q=>"trying") - @messages.size.should == 1 + @messages = Socialcastr::Message.search("trying") + puts "@messages is a #{@message.class}" + @messages.size.should == 20 end end context "commenting a message" do before :each do