forked from palkan/action-cable-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
102 additions
and
25 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--exclude /templates/ | ||
--quiet | ||
act*/lib/**/*.rb | ||
railties/lib/**/*.rb |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem "actioncable", "~> 5.0.0" | ||
gem "rails", "~> 5.0.0" | ||
|
||
gemspec path: '..' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails/generators/test_unit" | ||
|
||
module TestUnit # :nodoc: | ||
module Generators # :nodoc: | ||
class ChannelGenerator < Base # :nodoc: | ||
source_root File.expand_path("../templates", __FILE__) | ||
|
||
check_class_collision suffix: "ChannelTest" | ||
|
||
def create_test_file | ||
template "unit_test.rb.erb", File.join("test/channels", class_path, "#{file_name}_channel_test.rb") | ||
end | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'test_helper' | ||
|
||
<% module_namespacing do -%> | ||
class <%= class_name %>ChannelTest < ActionCable::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end | ||
<% end -%> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
require "generators/test_unit/channel/channel_generator" | ||
|
||
describe TestUnit::Generators::ChannelGenerator, type: :generator do | ||
destination File.expand_path("../../../tmp", __FILE__) | ||
|
||
let(:args) { ["chat"] } | ||
|
||
before do | ||
prepare_destination | ||
run_generator(args) | ||
end | ||
|
||
subject { file("test/channels/chat_channel_test.rb") } | ||
|
||
it "creates script", :aggregate_failures do | ||
is_expected.to exist | ||
is_expected.to contain("class ChatChannelTest < ActionCable::TestCase") | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) | ||
|
||
require "pry-byebug" | ||
|
||
require "action_controller/railtie" | ||
require "action_view/railtie" | ||
require "action_cable" | ||
require "action-cable-testing" | ||
|
||
require "ammeter/init" | ||
|
||
# Require all the stubs and models | ||
Dir[File.expand_path("../test/stubs/*.rb", __dir__)].each { |file| require file } | ||
|
||
# # Set test adapter and logger | ||
ActionCable.server.config.cable = { "adapter" => "test" } | ||
ActionCable.server.config.logger = | ||
ActiveSupport::TaggedLogging.new ActiveSupport::Logger.new(StringIO.new) | ||
|
||
Dir[File.expand_path("support/**/*.rb", __dir__)].each { |f| require f } | ||
|
||
RSpec.configure do |config| | ||
config.mock_with :rspec do |mocks| | ||
mocks.verify_partial_doubles = true | ||
end | ||
|
||
config.example_status_persistence_file_path = "tmp/rspec_examples.txt" | ||
config.filter_run :focus | ||
config.run_all_when_everything_filtered = true | ||
|
||
config.order = :random | ||
Kernel.srand config.seed | ||
end |
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