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