Class: Test::Unit::TestCase
- Inherits:
-
Object
- Object
- Test::Unit::TestCase
- Defined in:
- lib/scaffolding_extensions/rails_test_help.rb
Overview
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.
Class Method Summary collapse
-
.test_scaffold(model, options = {}) ⇒ Object
Test the scaffold method using the same arguments as the method.
-
.test_scaffold_all_models(options = {}) ⇒ Object
Test the scaffold_all_models method using the same arguments as the method.
Instance Method Summary collapse
-
#scaffold_habtm_test(model, association, id) ⇒ Object
Test the habtm scaffold for singular class, many class, and the specific id.
-
#scaffold_session ⇒ Object
Default scaffold session hash to use.
-
#scaffold_test(model, options = {}) ⇒ Object
Test that getting all display actions for the scaffold returns success.
Class Method Details
.test_scaffold(model, options = {}) ⇒ Object
Test the scaffold method using the same arguments as the method
15 16 17 |
# File 'lib/scaffolding_extensions/rails_test_help.rb', line 15 def self.test_scaffold(model, = {}) define_method("test_scaffold_#{model.scaffold_name}"){scaffold_test(model, )} end |
.test_scaffold_all_models(options = {}) ⇒ Object
Test the scaffold_all_models method using the same arguments as the method
10 11 12 |
# File 'lib/scaffolding_extensions/rails_test_help.rb', line 10 def self.test_scaffold_all_models( = {}) ActionController::Base.send(:scaffold_all_models_parse_options, ).each{|model, | test_scaffold(model, )} end |
Instance Method Details
#scaffold_habtm_test(model, association, id) ⇒ Object
Test the habtm scaffold for singular class, many class, and the specific id
38 39 40 41 42 |
# File 'lib/scaffolding_extensions/rails_test_help.rb', line 38 def scaffold_habtm_test(model, association, id) action = "edit_#{model.scaffold_name}_#{association}", {:id=>id} assert_nothing_raised("Error requesting habtm scaffold #{action}"){get action} assert_response :success, "Response for habtm scaffold #{action} not :success" end |
#scaffold_session ⇒ Object
Default scaffold session hash to use.
20 21 22 |
# File 'lib/scaffolding_extensions/rails_test_help.rb', line 20 def scaffold_session {} end |
#scaffold_test(model, options = {}) ⇒ Object
Test that getting all display actions for the scaffold returns success
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/scaffolding_extensions/rails_test_help.rb', line 25 def scaffold_test(model, = {}) klass = @controller.class methods = [:only] ? Array([:only]) : ScaffoldingExtensions::DEFAULT_METHODS methods -= Array([:except]) if [:except] methods.each do |action| assert_nothing_raised("Error requesting scaffolded action #{action} for model #{model.name}") do get "#{action}_#{model.scaffold_name}", nil, scaffold_session end assert_response :success, "Response for scaffolded action #{action} for model #{model.name} not :success" end end |