mirror of
https://github.com/varvet/pundit.git
synced 2022-11-09 12:30:11 -05:00
Add spec generator for policies.
Add test hook. Remove old spec template.
This commit is contained in:
parent
c028f722e6
commit
933d9295ba
3 changed files with 41 additions and 0 deletions
|
@ -6,6 +6,8 @@ module Pundit
|
|||
def create_policy
|
||||
template 'policy.rb', File.join('app/policies', class_path, "#{file_name}_policy.rb")
|
||||
end
|
||||
|
||||
hook_for :test_framework
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
11
lib/generators/rspec/policy_generator.rb
Normal file
11
lib/generators/rspec/policy_generator.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
module Rspec
|
||||
module Generators
|
||||
class PolicyGenerator < ::Rails::Generators::NamedBase
|
||||
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
||||
|
||||
def create_policy_spec
|
||||
template 'policy_spec.rb', File.join('spec/policies', class_path, "#{file_name}_policy_spec.rb")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
28
lib/generators/rspec/templates/policy_spec.rb
Normal file
28
lib/generators/rspec/templates/policy_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe <%= class_name %>Policy do
|
||||
|
||||
let(:user) { User.new }
|
||||
|
||||
subject { <%= class_name %>Policy }
|
||||
|
||||
permissions ".scope" do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
|
||||
permissions :create? do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
|
||||
permissions :show? do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
|
||||
permissions :update? do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
|
||||
permissions :destroy? do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue