From e1da6814b44110bc640a297bbca98bd87950b192 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Mon, 13 Jul 2015 10:43:52 -0500 Subject: Always load all the stub files --- test/channel/base_test.rb | 3 +-- test/channel/periodic_timers_test.rb | 3 +-- test/channel/stream_test.rb | 3 +-- test/stubs/room.rb | 12 ++++++++++++ test/test_helper.rb | 3 +++ 5 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 test/stubs/room.rb diff --git a/test/channel/base_test.rb b/test/channel/base_test.rb index e525631642..aa31d23297 100644 --- a/test/channel/base_test.rb +++ b/test/channel/base_test.rb @@ -1,9 +1,8 @@ require 'test_helper' require 'stubs/test_connection' +require 'stubs/room' class ActionCable::Channel::BaseTest < ActiveSupport::TestCase - Room = Struct.new(:id) - class ChatChannel < ActionCable::Channel::Base attr_reader :room, :last_action on_subscribe :toggle_subscribed diff --git a/test/channel/periodic_timers_test.rb b/test/channel/periodic_timers_test.rb index 96d3e01783..1590a12f09 100644 --- a/test/channel/periodic_timers_test.rb +++ b/test/channel/periodic_timers_test.rb @@ -1,9 +1,8 @@ require 'test_helper' require 'stubs/test_connection' +require 'stubs/room' class ActionCable::Channel::PeriodicTimersTest < ActiveSupport::TestCase - Room = Struct.new(:id) - class ChatChannel < ActionCable::Channel::Base periodically -> { ping }, every: 5 periodically :send_updates, every: 1 diff --git a/test/channel/stream_test.rb b/test/channel/stream_test.rb index 2f4c988adf..1a8c259d11 100644 --- a/test/channel/stream_test.rb +++ b/test/channel/stream_test.rb @@ -1,9 +1,8 @@ require 'test_helper' require 'stubs/test_connection' +require 'stubs/room' class ActionCable::Channel::StreamTest < ActiveSupport::TestCase - Room = Struct.new(:id) - class ChatChannel < ActionCable::Channel::Base def subscribed @room = Room.new params[:id] diff --git a/test/stubs/room.rb b/test/stubs/room.rb new file mode 100644 index 0000000000..388b5ae33f --- /dev/null +++ b/test/stubs/room.rb @@ -0,0 +1,12 @@ +class Room + attr_reader :id, :name + + def initialize(id, name='Campfire') + @id = id + @name = name + end + + def to_global_id + "Room##{id}-#{name}" + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 5b8ba110db..0e0191e804 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -13,6 +13,9 @@ require 'mocha/mini_test' require 'action_cable' ActiveSupport.test_order = :sorted +# Require all the stubs and models +Dir[File.dirname(__FILE__) + '/stubs/*.rb'].each {|file| require file } + class ActionCableTest < ActiveSupport::TestCase PORT = 420420 -- cgit v1.2.3