pattern_generator 0.0.1 → 0.0.2

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: 6eb526dea3c025252e19ed1b1cfb3897545c39d5
4
- data.tar.gz: 5e20f7227def6b873dc438b862e6d4b77e3ff515
3
+ metadata.gz: 590d40cb953dc48bf726b092c90affa70dae57d6
4
+ data.tar.gz: 5c0937a0e7fbb3b816d9bb3393b153d12b0c0f2d
5
5
  SHA512:
6
- metadata.gz: 8d9ccab6d5e9af609553379d17e051caa29056885861314eafb673af5c9177ff801e3227673f0dad4d5afd424c626772f32b3ba95e96840a6508440977b5d991
7
- data.tar.gz: 5d24e683b851881668222945d6678c2187e530b16cdb454fbd00faa9c525791fb0a7fd989eab53fbc46d4e7e25607915e367f3bd68b3acce5e0ff9886263f408
6
+ metadata.gz: f58698f7929877b1aca8a19523aeeeba8d5b6c5b174a8adaccf2b3359bcb3c3d9dda11119c921f37a3accd81e81e5dece240122d6cdcbd39c2b4cc693314c191
7
+ data.tar.gz: 795e6487260871a165d6d61093a28840edf91b3d3b465633088b478ea616a314374a3fbbadaa97a589337efc8c3c5b9f8de50d30d5745bb4d1a0360d21310375
data/Rakefile CHANGED
@@ -14,11 +14,6 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
17
-
18
-
19
-
20
-
21
-
22
17
  Bundler::GemHelper.install_tasks
23
18
 
24
19
  require 'rake/testtask'
@@ -0,0 +1,24 @@
1
+ require 'active_support/inflector'
2
+
3
+ class PolicyGenerator < Rails::Generators::NamedBase
4
+ source_root File.expand_path('../templates', __FILE__)
5
+ class_option :test_suite, type: :string, default: 'rspec', desc: 'Test framework to generate test. (rspec or minitest)'
6
+
7
+ def generate_template
8
+ template 'policy.rb', "app/policies/#{file_name}_policy.rb"
9
+ end
10
+
11
+ def generate_test
12
+ if options.test_suite == 'rspec'
13
+ template 'policy_spec.rb', "spec/policies/#{file_name}_policy_spec.rb"
14
+ elsif options.test_suite == 'minitest'
15
+ template 'policy_test.rb', "test/policies/#{file_name}_policy_test.rb"
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def class_name
22
+ file_name.classify
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ class <%= class_name %>Policy
2
+ def initialize
3
+
4
+ end
5
+
6
+ def policy_method
7
+ # Customize to fit your need
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe <%= class_name %>Policy, type: :policy do
4
+ describe '#policy_method' do
5
+ it 'does something' do
6
+
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>PolicyTest < Minitest::Test
4
+ def test_something
5
+
6
+ end
7
+ end
@@ -2,13 +2,18 @@ require "active_support/inflector"
2
2
 
3
3
  class ServiceGenerator < Rails::Generators::NamedBase
4
4
  source_root File.expand_path('../templates', __FILE__)
5
+ class_option :test_suite, type: :string, default: 'rspec', desc: 'Test framework to generate test. (rspec or minitest)'
5
6
 
6
7
  def copy_service_file
7
8
  template 'service.rb', "app/services/#{file_name}_service.rb"
8
9
  end
9
10
 
10
- def copy_service_spec_file
11
- template 'service_spec.rb', "spec/services/#{file_name}_service_spec.rb"
11
+ def copy_service_test_file
12
+ if options.test_suite == 'rspec'
13
+ template 'service_spec.rb', "spec/services/#{file_name}_service_spec.rb"
14
+ elsif options.test_suite == 'minitest'
15
+ template 'service_test.rb', "test/services/#{file_name}_service_test.rb"
16
+ end
12
17
  end
13
18
 
14
19
  private
@@ -1,5 +1,4 @@
1
1
  class <%= class_name %>Service
2
-
3
2
  def initialize
4
3
 
5
4
  end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>ServiceTest < Minitest::Test
4
+ def test_call
5
+
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module PatternGenerator
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,2 +1,4 @@
1
+ require "rails/generators"
2
+
1
3
  module PatternGenerator
2
4
  end
File without changes