Created
August 9, 2012 21:13
-
-
Save shwoodard/3308129 to your computer and use it in GitHub Desktop.
RSpec + Capybara support file to work with ckeditor instances
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ckeditor | |
class Instance | |
attr_reader :capybara | |
private :capybara | |
def initialize(instance_id, capybara) | |
@instance_id, @capybara = instance_id, capybara | |
end | |
def val(value) | |
capybara.execute_script "jQuery('textarea##{@instance_id}').val('#{value}')" | |
end | |
def reload_all | |
capybara.execute_script "for(var instance in CKEDITOR.instances) { if(CKEDITOR.instances.hasOwnProperty(instance)) {CKEDITOR.instances[instance].destroy(true);} }" | |
capybara.execute_script "CKEDITOR.replaceAll();" | |
end | |
end | |
end | |
# usage | |
# rte = Ckeditor::Instance.new(:my_instance_id, page) | |
# rte.val 'foo' | |
# rte.reload_all | |
# NOTE: page is provided by Capybara |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment