monty-rspec-rails
Rspec Rails helpers for Monty
In your spec/spec_helper.rb
require 'monty-rspec-rails'
include Monty::RspecRails
Some test examples:
describe UsersController do
describe "public" do
before do
public_user
end
it '#new is allowed' do
request_allowed?(:new).should be_true
end
# Need to pass in the :post method to mimic the Rails request
it '#create is allowed' do
request_allowed?(:create, :post).should be_true
end
# Need to pass in the :post method and the put param
# to mimic the Rails request
it '#update is not allowed' do
request_allowed?(:update, :post, :_method => 'put').should be_false
end
it '#show is not allowed' do
request_allowed?(:show).should be_false
end
end
describe "protected" do
before do
authenticated_user
end
it '#show is not allowed' do
request_allowed?(:show).should be_true
end
# And so on..
end
end
Note on Patches/Pull Requests
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a future version unintentionally.
- Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
- Send me a pull request. Bonus points for topic branches.
Copyright
Copyright (c) 2010 stonean. See LICENSE for details.