Module: BestInPlace::TestHelpers
- Includes:
- ActionView::Helpers::JavaScriptHelper
- Defined in:
- lib/best_in_place/test_helpers.rb
Instance Method Summary collapse
- #bip_area(model, attr, new_value) ⇒ Object
- #bip_bool(model, attr) ⇒ Object
- #bip_select(model, attr, name) ⇒ Object
- #bip_text(model, attr, new_value) ⇒ Object
Instance Method Details
#bip_area(model, attr, new_value) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/best_in_place/test_helpers.rb', line 6 def bip_area(model, attr, new_value) id = BestInPlace::Utils.build_best_in_place_id model, attr page.execute_script <<-JS jQuery("##{id}").click(); jQuery("##{id} form textarea").val('#{escape_javascript new_value.to_s}'); jQuery("##{id} form textarea").blur(); JS end |
#bip_bool(model, attr) ⇒ Object
24 25 26 27 |
# File 'lib/best_in_place/test_helpers.rb', line 24 def bip_bool(model, attr) id = BestInPlace::Utils.build_best_in_place_id model, attr page.execute_script("jQuery('##{id}').click();") end |
#bip_select(model, attr, name) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/best_in_place/test_helpers.rb', line 29 def bip_select(model, attr, name) id = BestInPlace::Utils.build_best_in_place_id model, attr page.execute_script <<-JS (function() { jQuery("##{id}").click(); var opt_value = jQuery("##{id} select option:contains('#{name}')").attr('value'); jQuery("##{id} select option[value='" + opt_value + "']").attr('selected', true); jQuery("##{id} select").change(); })(); JS end |
#bip_text(model, attr, new_value) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/best_in_place/test_helpers.rb', line 15 def bip_text(model, attr, new_value) id = BestInPlace::Utils.build_best_in_place_id model, attr page.execute_script <<-JS jQuery("##{id}").click(); jQuery("##{id} input[name='#{attr}']").val('#{escape_javascript new_value.to_s}'); jQuery("##{id} form").submit(); JS end |