Sha256: 54852270785692e1702c32e9852ba4e74bca1c1b56a5f3168a5059aeff783c8a

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'
require 'action_view'
require 'active_support'
require_relative '../../../app/helpers/navbar_helper'

include ActionView::Helpers
include ActionView::Context
include NavbarHelper

describe NavbarHelper, 'uri_state', type: :helper do
  before do
    subject.stub_chain("request.host_with_port").and_return("#{HOST}")
    subject.stub_chain("request.protocol").and_return("http://")
    subject.stub_chain("request.url").and_return("#{HOST}/a/b")
    subject.stub_chain("request.path").and_return('/a/b')    
  end

  it 'must return active state' do
    subject.uri_state('/a/b').should == :active
    subject.uri_state("#{HOST}/a/b").should == :active
  end

  it 'must return chosen state' do
    subject.uri_state('/a').should == :chosen
    subject.uri_state("#{HOST}/a").should == :chosen
  end

  it 'must return inactive state' do
    subject.uri_state('/test').should == :inactive
    subject.uri_state("#{HOST}/test").should == :inactive
  end

  it 'must not return chosen for root url' do
    subject.uri_state('/').should == :inactive
    subject.uri_state("#{HOST}/").should == :inactive
  end

end

HOST = "http://example.com:80"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twitter-bootstrap-rails-2.2.7 spec/lib/twitter_bootstrap_rails/uri_state_spec.rb