Simple test framework to check that public facing pages without an id respond successfully
This is only a basic check, it does not check that all form submittals work, as that requires that you choose an object to test. If you want to be sure that all parts of Scaffolding Extensions work with your applications, you should extend the tests here to do so.
Methods
public class
public instance
Public class methods
Test the scaffold method using the same arguments as the method
# File lib/scaffolding_extensions/rails_test_help.rb, line 15 15: def self.test_scaffold(model, options = {}) 16: define_method("test_scaffold_#{model.scaffold_name}"){scaffold_test(model, options)} 17: end
Test the scaffold_all_models method using the same arguments as the method
# File lib/scaffolding_extensions/rails_test_help.rb, line 10 10: def self.test_scaffold_all_models(options = {}) 11: ActionController::Base.send(:scaffold_all_models_parse_options, options).each{|model, options| test_scaffold(model, options)} 12: end
Public instance methods
Test the habtm scaffold for singular class, many class, and the specific id
# File lib/scaffolding_extensions/rails_test_help.rb, line 38 38: def scaffold_habtm_test(model, association, id) 39: action = "edit_#{model.scaffold_name}_#{association}", {:id=>id} 40: assert_nothing_raised("Error requesting habtm scaffold #{action}"){get action} 41: assert_response :success, "Response for habtm scaffold #{action} not :success" 42: end
Default scaffold session hash to use.
# File lib/scaffolding_extensions/rails_test_help.rb, line 20 20: def scaffold_session 21: {} 22: end
Test that getting all display actions for the scaffold returns success
# File lib/scaffolding_extensions/rails_test_help.rb, line 25 25: def scaffold_test(model, options = {}) 26: klass = @controller.class 27: methods = options[:only] ? Array(options[:only]) : ScaffoldingExtensions::DEFAULT_METHODS 28: methods -= Array(options[:except]) if options[:except] 29: methods.each do |action| 30: assert_nothing_raised("Error requesting scaffolded action #{action} for model #{model.name}") do 31: get "#{action}_#{model.scaffold_name}", nil, scaffold_session 32: end 33: assert_response :success, "Response for scaffolded action #{action} for model #{model.name} not :success" 34: end 35: end