cancan/spec/spec_helper.rb

61 lines
1.3 KiB
Ruby
Raw Normal View History

2009-11-16 22:28:52 +00:00
require 'rubygems'
require 'bundler/setup'
Bundler.require(:default)
require 'supermodel' # shouldn't Bundler do this already?
require 'active_support/all'
2010-07-20 23:00:22 +00:00
require 'matchers'
2010-04-13 13:02:39 +00:00
require 'cancan/matchers'
2009-11-16 22:28:52 +00:00
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
2009-11-16 22:28:52 +00:00
config.mock_with :rr
config.before(:each) do
Project.delete_all
Category.delete_all
end
config.extend WithModel if ENV["MODEL_ADAPTER"].nil? || ENV["MODEL_ADAPTER"] == "active_record"
2009-11-16 22:28:52 +00:00
end
class Ability
include CanCan::Ability
2010-05-21 20:41:24 +00:00
def initialize(user)
end
end
class Category < SuperModel::Base
has_many :projects
end
module Sub
class Project < SuperModel::Base
belongs_to :category
attr_accessor :category # why doesn't SuperModel do this automatically?
def self.respond_to?(method, include_private = false)
if method.to_s == "find_by_name!" # hack to simulate ActiveRecord
true
else
super
end
end
end
end
class Project < SuperModel::Base
belongs_to :category
attr_accessor :category # why doesn't SuperModel do this automatically?
def self.respond_to?(method, include_private = false)
if method.to_s == "find_by_name!" # hack to simulate ActiveRecord
true
else
super
end
end
2010-05-25 08:14:01 +00:00
end