require 'spec_helper'
describe 'WrapperHelper' do
include RSpec::Rails::HelperExampleGroup
include Webrat::HaveTagMatcher
%w(wrapper column row buttons).each do |mode|
describe "##{mode}" do
css = mode.gsub(/input_/,'')
it "should add #{mode} wrapper" do
helper.jquery_form_for(:new_post, :url => '/hello') do |builder|
builder.send(mode) do
end.should have_tag("div.ui-form-#{css}")
end
end
it "should add #{mode} tag with options" do
helper.jquery_form_for(:new_post, :url => '/hello') do |builder|
builder.send(mode,:class => "kuku") do
end.should have_tag("div.ui-form-#{css}.kuku")
end
end
it "should add #{mode} tag with content" do
helper.jquery_form_for(:new_post, :url => '/hello') do |builder|
builder.send(mode) do
"
Yo
".html_safe
end.should have_tag("div.ui-form-#{css}>h1") do |text|
text.should contain("Yo")
end
end
end
end
end
describe '#fieldset' do
it 'should add fieldset tag ' do
helper.jquery_form_for(:new_post, :url => '/hello') do |builder|
builder.fieldset do
end.should have_tag("fieldset.ui-fieldset")
end
end
it 'should add fieldset tag with legend' do
helper.jquery_form_for(:new_post, :url => '/hello') do |builder|
builder.fieldset("Hi") do
end.should have_tag("legend") do |text|
text.should contain("Hi")
end
end
end
it 'should add fieldset tag with options and legend' do
helper.jquery_form_for(:new_post, :url => '/hello') do |builder|
builder.fieldset("Hi", "data-row" => "xml") do
end.should have_tag("fieldset[data-row='xml']>legend") do |text|
text.should contain("Hi")
end
end
end
it 'should add fieldset tag with content' do
helper.jquery_form_for(:new_post, :url => '/hello') do |builder|
builder.fieldset do
"Yo
aa".html_safe
end.should have_tag("fieldset>h1") do |text|
text.should contain("Yo")
end
end
end
end
end