elabs/pundit — pull request #138 by johnotander (2014-04-23 00:35:57+00:00)
Title: Add Rspec generator for policies.

I've added an Rspec generator that stubs out the `permissions` blocks for CRUD actions. I thought I'd submit a pull request to see if the project maintainers had any desire for test generators before I undertook adding other testing frameworks.

#### When generating a Pundit Policy, the stubbed out spec is also generated.

```
fake_rspec_app|||master* $ rails g pundit:policy fake
create app/policies/fake_policy.rb
invoke rspec
create spec/policies/fake_policy_spec.rb
```

#### Which will generate:

```ruby
require 'spec_helper'

describe FakePolicy do

let(:user) { User.new }

subject { FakePolicy }

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

```

However, the current implementation is problematic because it prints an error when generating with other testing frameworks.

```
fake_test_unit_app|||master* $ rails g pundit:policy fake
create app/policies/fake_policy.rb
error test_unit [not found]
```

I'm happy to also incorporate MiniTest and Test::Unit generators if you'd like, or I can only hook the `test_framework` if Rspec is being used.