/spec/helpers/application_helper_spec.rb

https://bitbucket.org/tbueno/planetafutebol · Ruby · 71 lines · 53 code · 17 blank · 1 comment · 12 complexity · b30191eede53dccbe5210ac9d73bd0e9 MD5 · raw file

  1. # encoding: UTF-8
  2. require 'spec_helper'
  3. describe ApplicationHelper do
  4. describe 'Site Title' do
  5. let(:suffix) { 'Vole.io' }
  6. let(:club) do
  7. Club.new(name: "Inter")
  8. end
  9. let(:article) do
  10. Article.new(title: "Title")
  11. end
  12. context "in the home page" do
  13. it "Uses the site slogan" do
  14. helper.site_title.should == "Notícias atualizadas sobre futebol | #{suffix}"
  15. end
  16. end
  17. context "in a club page" do
  18. it "uses prefix + club name with news callout" do
  19. helper.stub(main_resource: club)
  20. helper.site_title.should == "Notícias sobre o clube #{club.name} | #{suffix}"
  21. end
  22. end
  23. context "in an article page" do
  24. it " uses prefix + article title" do
  25. helper.stub(main_resource: article)
  26. helper.site_title.should == "#{article.title} | #{suffix}"
  27. end
  28. end
  29. end
  30. describe "image for club" do
  31. it "generates image file name base on club" do
  32. helper.image_for(Club.new(name: 'Inter')).should == "inter.png"
  33. end
  34. it 'return empty string when club name is nil' do
  35. helper.image_for(Club.new()).should == ""
  36. end
  37. it 'removes accents' do
  38. helper.image_for(Club.new(name: "Grêmio")).should == "gremio.png"
  39. end
  40. it 'replaces spaces for dashes' do
  41. helper.image_for(Club.new(name: 'São Paulo')).should == "sao-paulo.png"
  42. end
  43. end
  44. describe "breadcrumbs" do
  45. let(:club){Club.new(name: 'inter')}
  46. let(:article) {Article.new(club: club)}
  47. it "generates breacrumbs for club" do
  48. helper.breadcrumbs_for(club).should == "<li><a href=\"/\">Home</a><span class=\"divider\">/</span></li><li class=\"active\">inter</li>"
  49. end
  50. it "generates breacrumbs for club" do
  51. helper.breadcrumbs_for(article).should == "<li><a href=\"/\">Home</a><span class=\"divider\">/</span></li><li>inter</li>"
  52. end
  53. end
  54. end