Class: ValidationReflectionTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- ValidationReflectionTest
- Defined in:
- lib/vendor/plugins/validation_reflection/test/validation_reflection_test.rb
Defined Under Namespace
Classes: Dummy
Instance Attribute Summary
Attributes included from Spec::Example::ExampleGroupMethods
Attributes included from Spec::Example::Subject::ExampleGroupMethods
Instance Method Summary collapse
- #test_custom_validations_are_reflected ⇒ Object
- #test_custom_validations_with_options_are_reflected ⇒ Object
- #test_format_is_reflected ⇒ Object
- #test_ignored_subvalidations_are_not_reflected ⇒ Object
- #test_numeric_integer_is_reflected ⇒ Object
- #test_numeric_is_reflected ⇒ Object
- #test_sanity ⇒ Object
- #test_string_limit_is_reflected ⇒ Object
- #test_subvalidations_are_reflected ⇒ Object
- #test_validates_presence_of_is_reflected ⇒ Object
- #test_validation_options_are_reflected ⇒ Object
Methods inherited from Test::Unit::TestCase
example_method?, #initialize, #run, suite, test_method?
Methods included from Spec::Example::ExampleGroupMethods
build_description_from, #describe, #described_class, #described_type, #description, #description_args, #description_parts, #example, #example_group_hierarchy, #example_implementations, #example_proxies, #examples, #include_constants_in, #inherited, #it_should_behave_like, #let, #nested_descriptions, #notify, #number_of_examples, #options, #pending_implementation, #run, #set_description, #xexample
Methods included from Spec::Example::ArgsAndOptions
#add_options, #args_and_options, #set_location
Methods included from Spec::Example::PredicateMatchers
#define_methods_from_predicate_matchers, #predicate_matchers
Methods included from Spec::Example::Subject::ExampleGroupMethods
Methods included from Spec::Example::BeforeAndAfterHooks
#after_all_parts, #after_each_parts, after_suite_parts, #after_suite_parts, #append_after, #append_before, #before_all_parts, #before_each_parts, before_suite_parts, #before_suite_parts, #prepend_after, #prepend_before
Methods included from Spec::Example::ExampleMethods
#description, #eval_each_fail_fast, #eval_each_fail_slow, #execute, #expect, #initialize, #instance_variable_hash, #options, #run_after_each, #run_before_each, #set_instance_variables_from_hash, #violated
Methods included from Spec::Example::ModuleReopeningFix
#child_modules, #include, #included
Methods included from Spec::Example::Pending
Methods included from Spec::Matchers
#be, #be_a, #be_a_kind_of, #be_an_instance_of, #be_close, #change, clear_generated_description, #eql, #equal, #exception_from, #exist, #fail, #fail_with, generated_description, #have, #have_at_least, #have_at_most, #include, #map_specs, #match, #method_missing, #raise_error, #respond_to, #run_with, #satisfy, #simple_matcher, #throw_symbol, #with_ruby, #wrap_expectation
Methods included from Spec::Matchers::DSL
Methods included from Spec::Example::Subject::ExampleMethods
#__should_for_example_group__, #__should_not_for_example_group__, #should, #should_not, #subject
Constructor Details
This class inherits a constructor from Test::Unit::TestCase
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Spec::Matchers
Instance Method Details
#test_custom_validations_are_reflected ⇒ Object
102 103 104 105 106 |
# File 'lib/vendor/plugins/validation_reflection/test/validation_reflection_test.rb', line 102 def test_custom_validations_are_reflected reflections = Dummy.reflect_on_validations_for(:col6) assert reflections.any? { |r| r.macro == :validates_something_weird } assert reflections.any? { |r| r.macro == :validates_format_of } end |
#test_custom_validations_with_options_are_reflected ⇒ Object
108 109 110 111 |
# File 'lib/vendor/plugins/validation_reflection/test/validation_reflection_test.rb', line 108 def reflections = Dummy.reflect_on_validations_for(:col7) assert reflections.any? { |r| r.macro == :validates_something_selfcontained } end |
#test_format_is_reflected ⇒ Object
81 82 83 84 |
# File 'lib/vendor/plugins/validation_reflection/test/validation_reflection_test.rb', line 81 def test_format_is_reflected reflections = Dummy.reflect_on_validations_for(:col3) assert reflections.any? { |r| r.macro == :validates_format_of && r.[:with] == /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i } end |
#test_ignored_subvalidations_are_not_reflected ⇒ Object
118 119 120 121 |
# File 'lib/vendor/plugins/validation_reflection/test/validation_reflection_test.rb', line 118 def test_ignored_subvalidations_are_not_reflected reflections = Dummy.reflect_on_validations_for(:col7) assert_equal 1, reflections.size end |
#test_numeric_integer_is_reflected ⇒ Object
86 87 88 89 |
# File 'lib/vendor/plugins/validation_reflection/test/validation_reflection_test.rb', line 86 def test_numeric_integer_is_reflected reflections = Dummy.reflect_on_validations_for(:col4) assert reflections.any? { |r| r.macro == :validates_numericality_of && r.[:only_integer] } end |
#test_numeric_is_reflected ⇒ Object
91 92 93 94 |
# File 'lib/vendor/plugins/validation_reflection/test/validation_reflection_test.rb', line 91 def test_numeric_is_reflected reflections = Dummy.reflect_on_validations_for(:col5) assert reflections.any? { |r| r.macro == :validates_numericality_of } end |
#test_sanity ⇒ Object
66 67 68 |
# File 'lib/vendor/plugins/validation_reflection/test/validation_reflection_test.rb', line 66 def test_sanity assert_equal [], Dummy.reflect_on_validations_for(:col0) end |
#test_string_limit_is_reflected ⇒ Object
76 77 78 79 |
# File 'lib/vendor/plugins/validation_reflection/test/validation_reflection_test.rb', line 76 def test_string_limit_is_reflected reflections = Dummy.reflect_on_validations_for(:col2) assert reflections.any? { |r| r.macro == :validates_length_of && r.[:maximum] == 100 } end |
#test_subvalidations_are_reflected ⇒ Object
113 114 115 116 |
# File 'lib/vendor/plugins/validation_reflection/test/validation_reflection_test.rb', line 113 def test_subvalidations_are_reflected reflections = Dummy.reflect_on_validations_for(:col6) assert_equal 2, reflections.size end |
#test_validates_presence_of_is_reflected ⇒ Object
70 71 72 73 74 |
# File 'lib/vendor/plugins/validation_reflection/test/validation_reflection_test.rb', line 70 def test_validates_presence_of_is_reflected reflections = Dummy.reflect_on_validations_for(:col1) assert reflections.all? { |r| r.name.to_s == 'col1' } assert reflections.find { |r| r.macro == :validates_presence_of } end |