public
Rubygem
Description: Makes tests easy on the fingers and the eyes
Homepage: http://www.thoughtbot.com/projects/shoulda
Clone URL: git://github.com/thoughtbot/shoulda.git
adding should_filter macro
dancroak (author)
Tue Sep 23 16:31:01 -0700 2008
commit  669a761959d2c8c0de81706a4bcb7aa8ffc0d842
tree    f407223b191ae270c2f89020ea2041100ef9643f
parent  3b5f2642733d93e9d3219bfdffdb213f601a1be2
...
100
101
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
104
105
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
0
@@ -100,6 +100,24 @@ module ThoughtBot # :nodoc:
0
         def should_not_set_the_flash
0
           should_set_the_flash_to nil
0
         end
0
+
0
+ # Macro that creates a test asserting that b
0
+ # is set for the specified keys
0
+ #
0
+ # Example:
0
+ #
0
+ # should_filter :password, :ssn
0
+ def should_filter(*keys)
0
+ keys.each do |key|
0
+ should "filter #{key}" do
0
+ assert @controller.respond_to?(:filter_parameters),
0
+ "The key #{key} is not filtered"
0
+ filtered = @controller.send(:filter_parameters, {key.to_s => key.to_s})
0
+ assert_equal '[FILTERED]', filtered[key.to_s],
0
+ "The key #{key} is not filtered"
0
+ end
0
+ end
0
+ end
0
 
0
         # Macro that creates a test asserting that the controller assigned to
0
         # each of the named instance variable(s).
...
13
14
15
 
 
16
17
18
...
13
14
15
16
17
18
19
20
0
@@ -13,6 +13,8 @@ class UsersControllerTest < Test::Unit::TestCase
0
     @response = ActionController::TestResponse.new
0
     @user = User.find(:first)
0
   end
0
+
0
+ should_filter :ssn
0
 
0
   should_be_restful do |resource|
0
     resource.identifier = :id
...
1
 
 
 
2
3
4
...
1
2
3
4
5
6
7
0
@@ -1,4 +1,7 @@
0
 class UsersController < ApplicationController
0
+
0
+ filter_parameter_logging :ssn
0
+
0
   # GET /users
0
   # GET /users.xml
0
   def index

Comments

    No one has commented yet.