Sha256: 100e8e6efaba46654962cc45c40d42afd165a9c5d09780f9678720592ded0fe0
Contents?: true
Size: 1.97 KB
Versions: 14
Compression:
Stored size: 1.97 KB
Contents
require_relative '../spec_helper' require "cancan/matchers" describe Canard::Abilities, "for <%= plural_name %>" do before do <% if Rails.configuration.generators.options[:rails][:fixture_replacement] == :factory_girl -%> @user = Factory.create(:<%= name %>_user) <% elsif Rails.configuration.generators.options[:rails][:fixture_replacement] == :machinist -%> @user = User.make!(:<%= name %>) <% else -%> @user = User.create(:roles => %w(<%= name -%>)) <% end -%> end subject { Ability.new(@user) } <% if ability_definitions.empty? -%> # Define your ability tests thus; # # describe 'on Activity' do # # before do # @activity = Factory.create(:activity) # end # # it { should be_able_to( :index, Activity ) } # it { should be_able_to( :show, @activity ) } # it { should be_able_to( :read, @activity ) } # it { should be_able_to( :new, @activity ) } # it { should be_able_to( :create, @activity ) } # it { should be_able_to( :edit, @activity ) } # it { should be_able_to( :update, @activity ) } # it { should be_able_to( :destroy, @activity ) } # # end # # on Activity <% else -%> <% definitions do |model, definition| -%> <% model_name = model.camelize -%> describe 'on <%= model_name -%>' do before do <% if Rails.configuration.generators.options[:rails][:fixture_replacement] == :factory_girl -%> @<%= model -%> = Factory.create(:<%= model -%>) <% elsif Rails.configuration.generators.options[:rails][:fixture_replacement] == :machinist -%> @<%= model -%> = <%= model_name -%>.make! <% else -%> @<%= model -%> = <%= model_name -%>.create <% end -%> end <% definition.cans.each do |can| -%> it { should be_able_to( <%= ":#{can},".ljust(12, ' ') + "@#{model}" -%> ) } <% end -%> <%- definition.cannots.each do |cannot| -%> it { should_not be_able_to( <%= ":#{cannot},".ljust(12, ' ') + "@#{model}" -%> ) } <% end -%> end # on <%= model_name %> <% end -%> <% end -%> end
Version data entries
14 entries across 14 versions & 1 rubygems