You are here: Browse Railsplugins Rjsassertions
RJS Assertions
RJS Assertions is a collection of assertions useful for testing your RJS templates. RJS Assertions function very similarly to the standard assertions built in to Rails, except that RJS Assertions are capable of parsing the JavaScript produced by an RJS template, and assert various conditions.
Usage: assert_rjs_tag & assert_rjs_no_tag – Same options as assert_tag/assert_no_tag. :rjs option can added to limit scope of assert. Example:
assert_rjs_visual_effect:
- Accepts two arguments, a string representing the id of the block the effect
should be performed on, and a symbol or string of the effect.
(Currently only supports "show" and "hide") Example:
assert_rjs_visual_effect 'greeting_div_id', :show
Example:
Say you have an action that triggers the following RJS template:
page.replace_html 'details_column_left', :partial => 'field', :collection => @left_column,
:locals => {:values => @field_hash}
page.replace_html 'details_column_right', :partial => 'field', :collection => @right_column,
:locals => {:values => @field_hash}
page.hide 'information_save_button'
page.show 'information_edit_button'
page.hide 'field_errors'
The action JavaScript response sent to the browser might end up looking something like: end
Element.update("details_column_left", "<label for="\"field[35]\""> @joe_schmoe.id, :field => {'1' => 'New Value'}}, logged_in_session
assert_rjs_tag :rjs => {:block => 'details_column_left' }, :tag => 'label', :content => 'Preferred:'
assert_rjs_tag :rjs => {:block => 'details_column_right' }, :tag => 'label', :content => 'Locations:'
assert_rjs_no_tag :rjs => {:block => 'details_column_left' }, :content => 'Left Value One!!!'
assert_rjs_visual_effect 'information_save_button', :hide
assert_rjs_visual_effect 'information_edit_button', :show
NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly