From 7c78a102bc83a5d52c3bb477676035e3b4db7dfc Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Wed, 20 May 2015 15:48:24 +0200 Subject: Add Comment#first_three_words This was a demo method for AlaveteliCon 2015 --- spec/models/comment_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 spec/models/comment_spec.rb (limited to 'spec/models/comment_spec.rb') diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb new file mode 100644 index 000000000..804ce608f --- /dev/null +++ b/spec/models/comment_spec.rb @@ -0,0 +1,14 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe Comment do + + describe :first_three_words do + + it 'returns the first three words of the comment body' do + comment = Comment.new(:body => 'Hello there Alaveteli technical people') + comment.first_three_words.should == 'Hello there Alaveteli' + end + + end + +end -- cgit v1.2.3