use a stub instead of creating a post to simpy supply text

This commit is contained in:
Steven Fuchs 2012-02-25 23:59:02 -05:00
parent 487c404d0d
commit 66afb7baff

View file

@ -35,17 +35,17 @@ describe Services::Twitter do
it "should not truncate a short message" do it "should not truncate a short message" do
short_message = ActiveSupport::SecureRandom.hex(20) short_message = ActiveSupport::SecureRandom.hex(20)
short_post = @user.post(:status_message, :text => short_message, :to =>@user.aspects.first.id) short_post = stub(:text => short_message )
@service.public_message(short_post, '').should == short_message @service.public_message(short_post, '').should == short_message
end end
it "should truncate a long message" do it "should truncate a long message" do
long_message = ActiveSupport::SecureRandom.hex(220) long_message = ActiveSupport::SecureRandom.hex(220)
long_post = @user.post(:status_message, :text => long_message, :to =>@user.aspects.first.id) long_post = stub(:text => long_message )
@service.public_message(long_post, '').should == long_message.first(137) + "..." @service.public_message(long_post, '').should == long_message.first(137) + "..."
end end
it "should not truncate a long message with an http url" do it "should not truncate a long message with an http url" do
long_message = @long_message_start + " http://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " + @long_message_end long_message = @long_message_start + " http://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " + @long_message_end
long_post = @user.post(:status_message, :text => long_message, :to =>@user.aspects.first.id) long_post = stub(:text => long_message )
answer = @service.public_message(long_post, '') answer = @service.public_message(long_post, '')
answer.starts_with?( @long_message_start ).should be_true answer.starts_with?( @long_message_start ).should be_true
@ -53,7 +53,7 @@ describe Services::Twitter do
end end
it "should not truncate a long message with an https url" do it "should not truncate a long message with an https url" do
long_message = @long_message_start + " https://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " + @long_message_end long_message = @long_message_start + " https://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " + @long_message_end
long_post = @user.post(:status_message, :text => long_message, :to =>@user.aspects.first.id) long_post = stub(:text => long_message )
answer = @service.public_message(long_post, '') answer = @service.public_message(long_post, '')
answer.starts_with?( @long_message_start ).should be_true answer.starts_with?( @long_message_start ).should be_true
@ -61,7 +61,7 @@ describe Services::Twitter do
end end
it "should truncate a long message with an ftp url" do it "should truncate a long message with an ftp url" do
long_message = @long_message_start + " ftp://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " + @long_message_end long_message = @long_message_start + " ftp://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " + @long_message_end
long_post = @user.post(:status_message, :text => long_message, :to =>@user.aspects.first.id) long_post = stub(:text => long_message )
answer = @service.public_message(long_post, '') answer = @service.public_message(long_post, '')
answer.starts_with?( @long_message_start ).should be_true answer.starts_with?( @long_message_start ).should be_true