Skip to content

Commit

Permalink
Merge pull request #54 from nashby/spec-for-issue-48
Browse files Browse the repository at this point in the history
add spec for case when we pass a block with argument to attribute
  • Loading branch information
carlosantoniodasilva committed Oct 16, 2012
2 parents 9b1ebb0 + 1e0e228 commit 6f3a16e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/attribute_test.rb
Expand Up @@ -133,6 +133,13 @@ class AttributeTest < ActionView::TestCase
assert_select "div.show_for p.wrapper", /This description/
end

test "show_for#content given a block should be wrapped in the result" do
with_attribute_for @user, :name do |name|
"<div class='block'>#{name}</div>".html_safe
end
assert_select "p.wrapper.user_name div.block", /ShowFor/
end

test "show_for escapes content by default" do
@user.name = "<b>hack you!</b>"
with_attribute_for @user, :name
Expand Down Expand Up @@ -171,13 +178,13 @@ class AttributeTest < ActionView::TestCase
assert_select "div.show_for p.user_email.wrapper", /Not specified/
assert_select "p.user_email strong.label", "Email"
end

test "show_for should wrap blank attributes with no_attribute" do
swap ShowFor, :blank_content_class => 'no_attribute' do
with_attributes_for @user, :name, :birthday
assert_select ".wrapper.user_birthday.no_attribute"
assert_select ".wrapper.user_name.no_attribute", false
end
end

end

0 comments on commit 6f3a16e

Please sign in to comment.