##// END OF EJS Templates
Added some shoulda macros for testing....
Eric Davis -
r3155:9ffee0a5a495
parent child
Show More
@@ -75,4 +75,32 class ActiveSupport::TestCase
75 yield
75 yield
76 saved_settings.each {|k, v| Setting[k] = v}
76 saved_settings.each {|k, v| Setting[k] = v}
77 end
77 end
78
79 # Shoulda macros
80 def self.should_render_404
81 should_respond_with :not_found
82 should_render_template 'common/404'
83 end
84
85 def self.should_have_before_filter(expected_method, options = {})
86 should_have_filter('before', expected_method, options)
87 end
88
89 def self.should_have_after_filter(expected_method, options = {})
90 should_have_filter('after', expected_method, options)
91 end
92
93 def self.should_have_filter(filter_type, expected_method, options)
94 description = "have #{filter_type}_filter :#{expected_method}"
95 description << " with #{options.inspect}" unless options.empty?
96
97 should description do
98 klass = "action_controller/filters/#{filter_type}_filter".classify.constantize
99 expected = klass.new(:filter, expected_method.to_sym, options)
100 assert_equal 1, @controller.class.filter_chain.select { |filter|
101 filter.method == expected.method && filter.kind == expected.kind &&
102 filter.options == expected.options && filter.class == expected.class
103 }.size
104 end
105 end
78 end
106 end
General Comments 0
You need to be logged in to leave comments. Login now