-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
3 changed files
with
36 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'generators/rspec' | ||
|
||
module Rspec | ||
module Generators | ||
# @private | ||
class ChannelGenerator < Base | ||
def create_channel_spec | ||
template 'channel_spec.rb.erb', File.join('spec/channels', class_path, "#{file_name}_channel_spec.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,7 @@ | ||
require 'rails_helper' | ||
|
||
<% module_namespacing do -%> | ||
RSpec.describe <%= class_name %>Channel, <%= type_metatag(:channel) %> do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
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,17 @@ | ||
# Generators are not automatically loaded by Rails | ||
require "generators/rspec/channel/channel_generator" | ||
require 'support/generators' | ||
|
||
RSpec.describe Rspec::Generators::ChannelGenerator, :type => :generator, :skip => !RSpec::Rails::FeatureCheck.has_action_cable_testing? do | ||
setup_default_destination | ||
|
||
describe 'the generated files' do | ||
before { run_generator %w(chat) } | ||
|
||
subject { file("spec/channels/chat_channel_spec.rb") } | ||
|
||
it { is_expected.to exist } | ||
it { is_expected.to contain(/require 'rails_helper'/) } | ||
it { is_expected.to contain(/describe ChatChannel, #{type_metatag(:channel)}/) } | ||
end | ||
end |