Sha256: 88eee945cc66256406a2717fa86550103b9ed9c2d1d6b647ebc02645271cfc6d

Contents?: true

Size: 1.48 KB

Versions: 12

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'
require 'cream/view/host_area'

describe Cream::View::Host do
  extend_view_with Cream::View::Host

  before do
    @post = stub(:title => 'my post', :id => 1, :author => 'kristian' )
  end
  
  describe '#for_localhost' do
    it "should display localhost guarded content for localhost browser agent" do
      with_engine do |e, view|
        view.stubs(:localhost?).returns true

        res = e.run_template do 
          %{<%= for_localhost do %>
              hello
            <% end %>
          }
        end
        res.should match /hello/  
      end
    end

    it "should NOT display localhost guarded content for NON-localhost browser agent" do
      with_engine do |e, view|
        view.stubs(:localhost?).returns false
    
        res = e.run_template do 
          %{<%= for_localhost { 'hello' } %>}
        end
        res.should be_empty
      end
    end
  end

  describe '#for_public' do
    it "should display public content for public browser agent" do
      with_engine do |e, view|
        view.stubs(:publichost?).returns true
  
        res = e.run_template do 
          %{<%= for_public { 'hello' } %>}
        end
        res.should match /hello/
      end
    end
  
    it "should display public content for public browser agent" do
      with_engine do |e, view|
        view.stubs(:publichost?).returns false
    
        res = e.run_template do 
          %{<%= for_public { 'hello' } %>}
        end
        res.should be_empty
      end
    end
  end  
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
cream-0.7.3 spec/cream/view/host_area_spec.rb
cream-0.7.2 spec/cream/view/host_area_spec.rb
cream-0.7.0 spec/cream/view/host_area_spec.rb
cream-0.6.4 spec/cream/view/host_area_spec.rb
cream-0.6.3 spec/cream/view/host_area_spec.rb
cream-0.6.1 spec/cream/view/host_area_spec.rb
cream-0.6.0 spec/cream/view/host_area_spec.rb
cream-0.5.10 spec/cream/view/host_area_spec.rb
cream-0.5.9 spec/cream/view/host_area_spec.rb
cream-0.5.8 spec/cream/view/host_area_spec.rb
cream-0.5.7 spec/cream/view/host_area_spec.rb
cream-0.5.6 spec/cream/view/host_area_spec.rb