Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

44 lines (41 sloc) 1.573 kb
require 'spec_helper'
describe BodyClassHelper, 'without any extra body classes' do
describe "body_class with a normal controller" do
before do
controller = mock
controller.stubs(:controller_path).returns('widgets')
controller.stubs(:action_name).returns('show')
helper.stubs(:controller).returns controller
end
it "should return the correct names" do
helper.body_class.should == "widgets widgets-show"
end
end
describe "body_class with a nested controller" do
before do
controller = mock
controller.stubs(:controller_path).returns('module/widgets')
controller.stubs(:action_name).returns('show')
helper.stubs(:controller).returns controller
end
it "should return the correct names" do
helper.body_class.should == "module-widgets module-widgets-show"
end
end
end
describe BodyClassHelper, 'with extra body classes' do
before do
controller = mock
controller.stubs(:controller_path).returns('widgets')
controller.stubs(:action_name).returns('show')
helper.stubs(:controller).returns controller
helper.content_for(:extra_body_classes, 'extra_class')
end
it "adds extra body classes to the controller classes" do
helper.body_class.should == 'widgets widgets-show extra_class'
end
it "adds extra body classes to the controller classes when #content_for= is called many times" do
helper.content_for(:extra_body_classes, ' many extra classes')
helper.body_class.should == 'widgets widgets-show extra_class many extra classes'
end
end
Jump to Line
Something went wrong with that request. Please try again.