diff --git a/.gitignore b/.gitignore index c111b33..0c14ba2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.gem +Gemfile.lock +.bundle diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..4e1e0d2 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--color diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..1aa98e4 --- /dev/null +++ b/Gemfile @@ -0,0 +1,2 @@ +source "http://rubygems.org" +gemspec diff --git a/README.rdoc b/README.rdoc index bad76c7..fef7215 100644 --- a/README.rdoc +++ b/README.rdoc @@ -147,6 +147,14 @@ This will only work when abilities are defined using hash conditions, not blocks * {Admin Namespace}[http://wiki.github.com/ryanb/cancan/admin-namespace] * {See more}[http://wiki.github.com/ryanb/cancan/] + +== Questions or Problems? + +If you have any issues with CanCan which you cannot find the solution to in the documentation, please add an {issue on GitHub}. Or better yet, fork the project and make a pull request. + +To get the specs running you should call +bundle+ and then +rake+. Specs currently do not work in Ruby 1.9 due to the RR mocking framework. + + == Special Thanks CanCan was inspired by declarative_authorization[http://github.com/stffn/declarative_authorization/] and aegis[http://github.com/makandra/aegis]. Also many thanks to the CanCan contributors[http://github.com/ryanb/cancan/contributors]. See the CHANGELOG[http://github.com/ryanb/cancan/blob/master/CHANGELOG.rdoc] for the full list. diff --git a/Rakefile b/Rakefile index 863ae7a..c629b0d 100644 --- a/Rakefile +++ b/Rakefile @@ -1,13 +1,10 @@ require 'rubygems' require 'rake' -require 'spec/rake/spectask' +require 'rspec/core/rake_task' -spec_files = Rake::FileList["spec/**/*_spec.rb"] - -desc "Run specs" -Spec::Rake::SpecTask.new do |t| - t.spec_files = spec_files - t.spec_opts = ["-c"] +desc "Run RSpec" +RSpec::Core::RakeTask.new do |t| + t.verbose = false end task :default => :spec diff --git a/cancan.gemspec b/cancan.gemspec index 2fdff9c..37f73e9 100644 --- a/cancan.gemspec +++ b/cancan.gemspec @@ -10,6 +10,10 @@ Gem::Specification.new do |s| s.files = Dir["{lib,spec}/**/*", "[A-Z]*", "init.rb"] s.require_path = "lib" + s.add_development_dependency 'rspec', '~> 2.0.0.beta.22' + s.add_development_dependency 'rails', '~> 3.0.0' + s.add_development_dependency 'rr', '~> 0.10.11' # 1.0.0 has respond_to? issues: http://github.com/btakita/rr/issues/issue/43 + s.rubyforge_project = s.name s.required_rubygems_version = ">= 1.3.4" end diff --git a/spec/cancan/ability_spec.rb b/spec/cancan/ability_spec.rb index 1f7fce9..4888dc5 100644 --- a/spec/cancan/ability_spec.rb +++ b/spec/cancan/ability_spec.rb @@ -379,7 +379,7 @@ describe CanCan::Ability do end it "should have variables for action and subject" do - I18n.backend.store_translations :en, :unauthorized => {:manage => {:all => "{{action}} {{subject}}"}} # old syntax for now in case testing with old I18n + I18n.backend.store_translations :en, :unauthorized => {:manage => {:all => "%{action} %{subject}"}} # old syntax for now in case testing with old I18n @ability.unauthorized_message(:update, Array).should == "update array" @ability.unauthorized_message(:edit, 1..3).should == "edit range" end diff --git a/spec/matchers.rb b/spec/matchers.rb index f83bc45..b98bd24 100644 --- a/spec/matchers.rb +++ b/spec/matchers.rb @@ -1,4 +1,4 @@ -Spec::Matchers.define :orderlessly_match do |original_string| +RSpec::Matchers.define :orderlessly_match do |original_string| match do |given_string| original_string.split('').sort == given_string.split('').sort end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 19f5eaa..93bce52 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,14 +1,12 @@ require 'rubygems' -require 'spec' -require 'active_support' -require 'active_record' -require 'action_controller' -require 'action_view' +require 'bundler' +Bundler.require(:default, :test) +require 'active_support/all' require 'matchers' require 'cancan' require 'cancan/matchers' -Spec::Runner.configure do |config| +RSpec.configure do |config| config.mock_with :rr end