thoughtbot--shoulda-matchers/spec/shoulda/matchers/action_controller/filter_param_matcher_spec.rb

23 lines
528 B
Ruby
Raw Normal View History

require 'spec_helper'
2010-12-15 22:34:19 +00:00
describe Shoulda::Matchers::ActionController::FilterParamMatcher do
2012-12-20 05:04:27 +00:00
it 'accepts filtering a filtered parameter' do
filter(:secret)
2012-12-20 05:04:27 +00:00
nil.should filter_param(:secret)
end
it 'rejects filtering an unfiltered parameter' do
filter(:secret)
matcher = filter_param(:other)
matcher.matches?(nil).should be_false
matcher.failure_message.should =~ /Expected other to be filtered.*secret/
2012-12-20 05:04:27 +00:00
end
2012-12-20 05:04:27 +00:00
def filter(param)
Rails.application.config.filter_parameters = [param]
end
end