Permalink
Browse files

add spec for case when we pass a block with argument to attribute

closes #48
  • Loading branch information...
nashby committed Oct 16, 2012
1 parent 9b1ebb0 commit 1e0e228f744addc93541314bf9bb3a32ae7b72fa
Showing with 9 additions and 2 deletions.
  1. +9 −2 test/attribute_test.rb
View
@@ -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
@@ -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 1e0e228

Please sign in to comment.