Hi all,
in a test I’m doing I’m looking for a div of class errorExplanation to
know if an update passed validation, but even if the rendered html has
it, as you can see below, the assert_tag fails. What am I doing wrong?
expected tag, but no tag found matching
{:attributes=>{:class=>“errorExplanation”}, :tag=>“div”} in:
"HWait(‘0’);HWait(‘00’);\nif($(‘flashesint’) !=
undefined){Effect.Fade(‘flashesint’,{duration:
0.7});Effect.BlindUp(‘flashesint’, {duration:
0.7});}\nsetTimeout(function() {\n;\n},
800);\nElement.update(“mac_address_number_1”, "\n\074div
class=\“errorExplanation\”
id=\“errorExplanation\”\076\074h2\0761 error prohibited this mac
address from being saved\074/h2\076\074p\076There were problems with
the following fields:\074/p\076\074ul\076\074li\076Mac address is
not a valid MAC Address\074/li\076\074/ul\076\074/div\076
\n\074form…
Hi all,
in a test I’m doing I’m looking for a div of class errorExplanation to
know if an update passed validation, but even if the rendered html has
it, as you can see below, the assert_tag fails. What am I doing wrong?
assert_tag is quite literally looking for a div tag of that class,
which your output does not contain. It does contain javascript for
inserting such a tag, but assert_tag doesn’t understand that.
You probably want to use assert_select_rjs (I also find the arts
plugin useful for this sort of stuff)
Hi all,
in a test I’m doing I’m looking for a div of class errorExplanation to
know if an update passed validation, but even if the rendered html has
it, as you can see below, the assert_tag fails. What am I doing wrong?
assert_tag is quite literally looking for a div tag of that class,
which your output does not contain. It does contain javascript for
inserting such a tag, but assert_tag doesn’t understand that.
You probably want to use assert_select_rjs (I also find the arts
plugin useful for this sort of stuff)
Fred
Thank you very much for your answer, I’ ll look into assert_select_rjs
and arts, till now I patched it with a custom assertion that works for
me:
def assert_validation_success
assert got_validation_error.nil?, "Not valid!"
end
def got_validation_error
@response.body.inspect.match(/.*errorExplanation.*/)
end
I had a problem similar to this and just could not get assert_tag to
work,
but I did not want to use a regex as the order of different attributes
makes complex testing difficult to maintain.
so after some testing I found that if I replaced the strict
declaration in the application layout with the transitional one
replace this
with
then it worked just fine.
On Nov 30 2007, 1:27 pm, Emanuele R. <rails-mailing-l…@andreas-
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.