Topic: Test::Rails View
I have some code that is mysteriously breaking and wondered if anyone could see why. In the first case, there are some checkboxes named 'projects[]' and the word "properties" appears in a <p></p> content tag. In the second case, these checkboxes should be absent, replaced by a hidden tag named 'projects[]'. Additionally, the word properties is replaced with property. I think that's what my test expresses, but clearly Test::Rails feels otherwise.
The error I'm receiving is:
test_index_with_key(MemberViewTest):
RuntimeError: expected > (got "" for <input type="hidden" id="projects[]" name="projects[]" value="" , {"name"=>"projects[]", "type"=>"hidden", "id"=>"projects[]", "value"=>""})
I'm not sure what got "" refers to.
class MemberViewTest < Test::Rails::ViewTestCase
def test_index
# first visit case
assigns[:member] = Member.new
render
assert_post_form '/member/signup'
assert_input '/member/signup', :checkbox, 'projects[]' # checkboxes only present if we go there directly
assert_tag :tag => 'p', :content => 'properties' # pluralized only if we go there directly
end
def test_index_with_key
# key visit case
assigns[:member] = Member.new
assigns[:key] = true
assigns[:project_array] = ['Three19']
render :action => 'index', :key => 'BAhbBiIKTWV6em8='
assert_tag :tag => 'p', :content => 'property' # pluralized only if we go there directly
assert_post_form '/member/signup'
assert_input('/member/signup', :hidden, 'projects[]', 'Three19') # checkboxes only present if we go there directly
end
end