Sha256: 05a7eef1b23af511fc9cb65e4865a864142a33c7bff7fcf21985c37d4e3937b4

Contents?: true

Size: 1021 Bytes

Versions: 59

Compression:

Stored size: 1021 Bytes

Contents

module ForeignOffice
  module Test
    module ClientExec

      def fetch_foreign_office_messages
        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

      def exec_listeners(listeners, push_data)
        listeners.each do |el|
          messages = push_data.select{|msg| msg['channel'] == el[:'data-channel']}
          message = messages.last
          if message
            page.execute_script("foreign_office.channels_by_name['#{el[:'data-channel']}'].handleMessage(#{message.to_json});")
          end
        end
      end
    end
  end
end

RSpec.configure do |config|
  config.include ForeignOffice::Test::ClientExec, type: :feature
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
foreign_office-0.17.6 lib/foreign_office/test/client_exec.rb
foreign_office-0.17.5 lib/foreign_office/test/client_exec.rb
foreign_office-0.17.4 lib/foreign_office/test/client_exec.rb
foreign_office-0.17.3 lib/foreign_office/test/client_exec.rb
foreign_office-0.17.2 lib/foreign_office/test/client_exec.rb
foreign_office-0.17.1 lib/foreign_office/test/client_exec.rb
foreign_office-0.17.0 lib/foreign_office/test/client_exec.rb
foreign_office-0.16.6 lib/foreign_office/test/client_exec.rb
foreign_office-0.16.5 lib/foreign_office/test/client_exec.rb
foreign_office-0.16.4 lib/foreign_office/test/client_exec.rb
foreign_office-0.16.3 lib/foreign_office/test/client_exec.rb
foreign_office-0.16.2 lib/foreign_office/test/client_exec.rb
foreign_office-0.16.1 lib/foreign_office/test/client_exec.rb
foreign_office-0.16.0 lib/foreign_office/test/client_exec.rb
foreign_office-0.15.12 lib/foreign_office/test/client_exec.rb
foreign_office-0.15.11 lib/foreign_office/test/client_exec.rb
foreign_office-0.15.10 lib/foreign_office/test/client_exec.rb
foreign_office-0.15.9 lib/foreign_office/test/client_exec.rb
foreign_office-0.15.8 lib/foreign_office/test/client_exec.rb
foreign_office-0.15.7 lib/foreign_office/test/client_exec.rb