Guest User

Untitled

a guest
Apr 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. require 'test/unit'
  2. require 'rubygems'
  3. require 'active_support'
  4. require 'title_helper'
  5.  
  6.  
  7. class TitleHelperTest < Test::Unit::TestCase
  8. include TitleHelper
  9.  
  10. def setup
  11. reset!
  12. end
  13.  
  14. def test_title_should_accepts_zero_or_more_params
  15. assert_nothing_raised { title }
  16. assert_nothing_raised { title('One') }
  17. assert_nothing_raised { title('One', 'Two', 'Three') }
  18. end
  19.  
  20. def test_title_should_return_content
  21. assert_equal('', title)
  22. assert_equal('One', title('One'))
  23. end
  24.  
  25. def test_title_should_return_empty_string_if_empty
  26. assert_equal('', title)
  27. end
  28.  
  29. def test_title_should_store_content
  30. assert_equal('', title)
  31. assert_equal('One', title('One'))
  32. assert_equal('One', title)
  33. end
  34.  
  35. def test_title_should_join_content
  36. assert_equal('', title)
  37. assert_equal('One', title('One'))
  38. assert_equal('One - Two', title('Two'))
  39. assert_equal('One - Two - Three - Four', title('Three', 'Four'))
  40. end
  41.  
  42. def test_title_should_join_content_with_separator
  43. assert_equal('One - Two', title('One', 'Two'))
  44. assert_equal('One | Two', title(:separator => ' | '))
  45. assert_equal('One x Two x Three', title('Three', :separator => ' x '))
  46. end
  47.  
  48. def test_title_should_append_headline_to_content
  49. assert_equal('One - Two', title('One', 'Two'))
  50. assert_equal('One - Two - Cool!', title(:headline => 'Cool!'))
  51. assert_equal('One - Two - Three - Yeah!', title('Three', :headline => 'Yeah!'))
  52. end
  53.  
  54. def test_title_should_append_site_to_content
  55. assert_equal('One - Two', title('One', 'Two'))
  56. assert_equal('One - Two - Cool!', title(:site => 'Cool!'))
  57. assert_equal('One - Two - Three - Yeah!', title('Three', :site => 'Yeah!'))
  58. end
  59.  
  60. def test_title_should_append_site_then_headline
  61. assert_equal('One - Two', title('One', 'Two'))
  62. assert_equal('One - Two - Cool!', title(:site => 'Cool!'))
  63. assert_equal('One - Two - Cool! - Yeah!', title(:headline => 'Yeah!'))
  64. end
  65.  
  66.  
  67. protected
  68.  
  69. def reset!
  70. title(nil)
  71. end
  72.  
  73. end
Add Comment
Please, Sign In to add comment