1
0
Fork 0
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:
John Otander 2014-04-22 16:11:17 -06:00
parent c028f722e6
commit 933d9295ba
3 changed files with 41 additions and 0 deletions

View file

@ -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

View 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

View 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