-
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.
Generators / tests: added support for RSpec
Presenter generator invokes test framework to generate presenter tests.
- Loading branch information
1 parent
b5f649f
commit 100ce27
Showing
6 changed files
with
60 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
- `magic:presenter:install` | ||
- `presenter` | ||
- Test::Unit | ||
- RSpec | ||
|
||
### Fixed | ||
|
||
|
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 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.configure do |config| | ||
config.include concern(:PresenterExampleGroup) { | ||
included { metadata[:type] = :presenter } | ||
}, file_path: %r'spec/presenters', type: :presenter | ||
end if defined? RSpec |
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,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'generators/rspec' | ||
require 'generators/magic/presenter/generator' | ||
|
||
module Rspec # :nodoc: | ||
module Generators # :nodoc: | ||
class PresenterGenerator < Base # :nodoc: | ||
include Magic::Presenter::Generator | ||
|
||
source_root File.expand_path('templates', __dir__) | ||
|
||
cattr_reader :target_root, default: Pathname('spec') | ||
|
||
def create_test_file | ||
template 'presenter_spec.rb', "#{file_path}_spec.rb" | ||
end | ||
end | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
lib/generators/rspec/presenter/templates/presenter_spec.rb.tt
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 %> 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