Commit 93760caf6d8b10b166c4f728c689779f588d2644

Authored by Antonio Terceiro
1 parent c8f04c6b

Less strict tests

Showing 1 changed file with 9 additions and 3 deletions   Show diff stats
test/unit/forum_helper_test.rb
@@ -41,7 +41,9 @@ class ForumHelperTest < ActiveSupport::TestCase @@ -41,7 +41,9 @@ class ForumHelperTest < ActiveSupport::TestCase
41 some_post = TextileArticle.create!(:name => 'First post', :profile => profile, :parent => forum, :published => true) 41 some_post = TextileArticle.create!(:name => 'First post', :profile => profile, :parent => forum, :published => true)
42 some_post.expects(:author).returns(author).times(2) 42 some_post.expects(:author).returns(author).times(2)
43 assert some_post.comments.empty? 43 assert some_post.comments.empty?
44 - assert_match /#{some_post.updated_at.to_s} ago by <a href='[^']+'>forum test author<\/a>/, last_topic_update(some_post) 44 + out = last_topic_update(some_post)
  45 + assert_match some_post.updated_at.to_s, out
  46 + assert_match /forum test author/, out
45 end 47 end
46 48
47 should 'return last comment date if it has comments' do 49 should 'return last comment date if it has comments' do
@@ -51,14 +53,18 @@ class ForumHelperTest &lt; ActiveSupport::TestCase @@ -51,14 +53,18 @@ class ForumHelperTest &lt; ActiveSupport::TestCase
51 some_post.comments << Comment.new(:title => 'test', :body => 'test', :author => a2) 53 some_post.comments << Comment.new(:title => 'test', :body => 'test', :author => a2)
52 c = Comment.last 54 c = Comment.last
53 assert_equal 2, some_post.comments.count 55 assert_equal 2, some_post.comments.count
54 - assert_match /#{c.created_at.to_s} ago by <a href='[^']+'>a2<\/a>/, last_topic_update(some_post) 56 + out = last_topic_update(some_post)
  57 + assert_match c.created_at.to_s, out
  58 + assert_match 'a2', out
55 end 59 end
56 60
57 should "return last comment author's name from unauthenticated user" do 61 should "return last comment author's name from unauthenticated user" do
58 some_post = TextileArticle.create!(:name => 'First post', :profile => profile, :parent => forum, :published => true) 62 some_post = TextileArticle.create!(:name => 'First post', :profile => profile, :parent => forum, :published => true)
59 some_post.comments << Comment.new(:name => 'John', :email => 'lenon@example.com', :title => 'test', :body => 'test') 63 some_post.comments << Comment.new(:name => 'John', :email => 'lenon@example.com', :title => 'test', :body => 'test')
60 c = Comment.last 64 c = Comment.last
61 - assert_match /#{c.created_at.to_s} ago by John/m, last_topic_update(some_post) 65 + out = last_topic_update(some_post)
  66 + assert_match "#{c.created_at.to_s} ago by John", out
  67 + assert_match 'John', out
62 end 68 end
63 69
64 protected 70 protected