Module: ForeignOffice::Test::ClientExec
- Defined in:
- lib/foreign_office/test/client_exec.rb
Instance Method Summary collapse
Instance Method Details
#exec_listeners(listeners, push_data) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/foreign_office/test/client_exec.rb', line 15 def exec_listeners(listeners, push_data) listeners.each do |el| = push_data.select{|msg| msg['channel'] == el[:'data-channel']} = .last if page.execute_script("foreign_office.channels_by_name['#{el[:'data-channel']}'].handleMessage(#{.to_json});") end end end |
#fetch_foreign_office_messages ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/foreign_office/test/client_exec.rb', line 5 def push_data = File.read(Rails.root + 'tmp/foreign_office_rspec_cache.json') push_data = push_data.split('IH_FO_MESSAGE_SEPARATOR') push_data.map!{|msg| JSON.parse msg} File.delete(Rails.root + 'tmp/foreign_office_rspec_cache.json') exec_listeners(page.all(:css, '[data-listener]', visible: false), push_data) exec_listeners(page.all(:css, '[data-listener]'), push_data) end |