require File.dirname(__FILE__) + '/spec_helper' describe MetaTags::ViewHelper do before :each do @view = ActionView::Base.new end context 'module' do it 'should be mixed into ActionView::Base' do ActionView::Base.included_modules.should include(MetaTags::ViewHelper) end it 'should respond to "title" helper' do @view.should respond_to(:title) end it 'should respond to "description" helper' do @view.should respond_to(:description) end it 'should respond to "keywords" helper' do @view.should respond_to(:keywords) end it 'should respond to "noindex" helper' do @view.should respond_to(:noindex) end it 'should respond to "nofollow" helper' do @view.should respond_to(:nofollow) end it 'should respond to "set_meta_tags" helper' do @view.should respond_to(:set_meta_tags) end it 'should respond to "display_meta_tags" helper' do @view.should respond_to(:display_meta_tags) end end context 'returning values' do it 'should return title' do @view.title('some-title').should == 'some-title' end it 'should return headline if specified' do @view.title('some-title', 'some-headline').should == 'some-headline' end it 'should return description' do @view.description('some-description').should == 'some-description' end it 'should return keywords' do @view.keywords('some-keywords').should == 'some-keywords' end it 'should return noindex' do @view.noindex('some-noindex').should == 'some-noindex' end it 'should return nofollow' do @view.noindex('some-nofollow').should == 'some-nofollow' end end context 'title' do it 'should use website name if title is empty' do @view.display_meta_tags(:site => 'someSite').should == '
some description
").should include('') end end context 'displaying keywords' do it 'should display keywords when "keywords" used' do @view.keywords('some-keywords') @view.display_meta_tags(:site => 'someSite').should include('') end it 'should display keywords when "set_meta_tags" used' do @view.set_meta_tags(:keywords => 'some-keywords') @view.display_meta_tags(:site => 'someSite').should include('') end it 'should display default keywords' do @view.display_meta_tags(:site => 'someSite', :keywords => 'some-keywords').should include('') end it 'should use custom keywords if given' do @view.keywords('some-keywords') @view.display_meta_tags(:site => 'someSite', :keywords => 'default_keywords').should include('') end it 'should lowercase keywords' do @view.display_meta_tags(:site => 'someSite', :keywords => 'someKeywords').should include('') end it 'should join keywords from Array' do @view.display_meta_tags(:site => 'someSite', :keywords => %w(keyword1 keyword2)).should include('') end it 'should join keywords from nested Arrays' do @view.display_meta_tags(:site => 'someSite', :keywords => [%w(keyword1 keyword2), 'keyword3']).should include('') end end context 'displaying noindex' do it 'should display noindex when "noindex" used' do @view.noindex(true) @view.display_meta_tags(:site => 'someSite').should include('') end it 'should display noindex when "set_meta_tags" used' do @view.set_meta_tags(:noindex => true) @view.display_meta_tags(:site => 'someSite').should include('') end it 'should use custom noindex if given' do @view.noindex('some-noindex') @view.display_meta_tags(:site => 'someSite').should include('') end it 'should display nothing by default' do @view.display_meta_tags(:site => 'someSite').should_not include(' 'someSite').should include('') end it 'should display nofollow when "set_meta_tags" used' do @view.set_meta_tags(:nofollow => true) @view.display_meta_tags(:site => 'someSite').should include('') end it 'should use custom nofollow if given' do @view.nofollow('some-nofollow') @view.display_meta_tags(:site => 'someSite').should include('') end it 'should display nothing by default' do @view.display_meta_tags(:site => 'someSite').should_not include(' 'someSite').should include('') end it 'should be displayed when "set_meta_tags" used' do @view.set_meta_tags(:nofollow => true, :noindex => true) @view.display_meta_tags(:site => 'someSite').should include('') end it 'should use custom name if string is used' do @view.noindex('some-name') @view.nofollow('some-name') @view.display_meta_tags(:site => 'someSite').should include('') end it 'should display two meta tags when different names used' do @view.noindex('some-noindex') @view.nofollow('some-nofollow') content = @view.display_meta_tags(:site => 'someSite') content.should include('') content.should include('') end end end