foreign_office 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75d5e2b584022e4551cb14be7327e8d1c090be32
4
- data.tar.gz: d83f9f28906d4c4cd7ed2cf34b605fe02ab1a7c5
3
+ metadata.gz: 0e7431926c0bca4b256992c1c2192d0959ef9e84
4
+ data.tar.gz: 77ae60663135f85a843366a9e9b4717cc5d5c86e
5
5
  SHA512:
6
- metadata.gz: e80fbbbe9a332b6585f07e6c18c21b8670404286f6f31d88c48018258955534b4ecafda215f7839142f2c68df16ae08813b431959b38ff966e9e6328275eb9a5
7
- data.tar.gz: 63b435d0ceb68a101d581980c16076b82ae27b31318eac89f10ec8ec24176844bdb8f8d1b88d2dad82a367930df4da9a23dc3159d9f35c4c3aee1e562be8f138
6
+ metadata.gz: 888f30502186eb8bbeeb8b01a9033ab4906020de0e70265ab1718810468c869c8e299d6314229cbaf9f28272ee790a78850fe0584ab574d81bf661a26e1e6447
7
+ data.tar.gz: ec6ad1b40e1a65ff37c06aba46a5be6bc2c3a04fe0ce56a097cc648d1cd6a17965785cba52d9c63aafd1dd9d15850ac4e8fcea2cc3ca127a7c9608dafa970045
@@ -38,19 +38,21 @@ var ForeignOfficeChannel = Class.extend({
38
38
  foreign_office.connection().subscribe({
39
39
  channel : channel_name,
40
40
  backfill: true,
41
- message : function(m){
42
- debug_logger.log("Got a message: ");
43
- debug_logger.log(m);
44
- $.each(foreign_office_channel.listeners,function(i,listener){
45
- debug_logger.log("sending message to listener: ");
46
- debug_logger.log(listener);
47
- listener.handleMessage(m);
48
- });
49
- }
41
+ message : function(m){foreign_office_channel.handleMessage(m)}
50
42
  });
51
43
  this.channel_name = channel_name;
52
44
  this.listeners = [];
53
45
  },
46
+ handleMessage: function(m){
47
+ debug_logger.log("Got a message: ");
48
+ debug_logger.log(m);
49
+ console.log(this);
50
+ $.each(this.listeners,function(i,listener){
51
+ debug_logger.log("sending message to listener: ");
52
+ debug_logger.log(listener);
53
+ listener.handleMessage(m);
54
+ })
55
+ },
54
56
  addListener: function(listener){
55
57
  this.listeners.push(listener);
56
58
  }
@@ -5,6 +5,11 @@ module ForeignOffice
5
5
  isolate_namespace ForeignOffice
6
6
  end
7
7
 
8
+ module Test
9
+ autoload :ClientExec, 'foreign_office/test/client_exec'
10
+ autoload :FakeForeignOffice, 'foreign_office/test/fake_foreign_office'
11
+ end
12
+
8
13
  def self.bus=(bus)
9
14
  @bus = bus
10
15
  end
@@ -61,8 +66,6 @@ module ForeignOffice
61
66
  self.bus.publish(message)
62
67
  end
63
68
 
64
- module Busses
65
- end
66
69
  end
67
70
  require 'foreign_office/busses/generic_bus'
68
71
  require 'foreign_office/busses/pubnub_bus'
@@ -1,4 +1,8 @@
1
- class ForeignOffice::Busses::GenericBus
2
- def publish(message)
1
+ module ForeignOffice
2
+ module Busses
3
+ class GenericBus
4
+ def publish(message)
5
+ end
6
+ end
3
7
  end
4
8
  end
@@ -0,0 +1,25 @@
1
+ module ForeignOffice
2
+ module Test
3
+ module ClientExec
4
+ def fetch_foreign_office_messages
5
+ push_data = File.read(Rails.root + 'tmp/foreign_office_rspec_cache.json')
6
+ push_data = push_data.split('IH_FO_MESSAGE_SEPARATOR')
7
+ push_data.map!{|msg| JSON.parse msg}
8
+ File.delete(Rails.root + 'tmp/foreign_office_rspec_cache.json')
9
+ if page.has_css?('[data-listener]')
10
+ page.all(:css, '[data-listener]').each do |el|
11
+ messages = push_data.select{|msg| msg['channel'] == el[:'data-channel']}
12
+ message = messages.last
13
+ if message
14
+ page.execute_script("foreign_office.channels_by_name['#{el[:'data-channel']}'].handleMessage(#{message.to_json});")
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ RSpec.configure do |config|
24
+ config.include ForeignOffice::Test::ClientExec, type: :feature
25
+ end
@@ -0,0 +1,19 @@
1
+ module ForeignOffice::Test::FakeForeignOffice
2
+ def self.included base
3
+ base.instance_eval do
4
+ def publish(stuff)
5
+ publish!(stuff)
6
+ end
7
+ def publish!(message)
8
+ File.open(Rails.root + 'tmp/foreign_office_rspec_cache.json','a+') do |file|
9
+ file.write(message.to_json)
10
+ file.write('IH_FO_MESSAGE_SEPARATOR')
11
+ end
12
+ end
13
+ def cache_messages
14
+ end
15
+ def flush_messages
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module ForeignOffice
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreign_office
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut
@@ -83,6 +83,8 @@ files:
83
83
  - lib/foreign_office/busses/generic_bus.rb
84
84
  - lib/foreign_office/busses/pubnub_bus.rb
85
85
  - lib/foreign_office/busses/pusher_bus.rb
86
+ - lib/foreign_office/test/client_exec.rb
87
+ - lib/foreign_office/test/fake_foreign_office.rb
86
88
  - lib/foreign_office/version.rb
87
89
  - lib/tasks/foreign_office_tasks.rake
88
90
  - test/dummy/README.rdoc