Module: Veneer::Lint::Adapter::ClassWrapperLint
- Defined in:
- lib/veneer/lint/adapter.rb
Instance Method Summary collapse
- #test_collection_associations ⇒ Object
- #test_conditions ⇒ Object
- #test_implementst_create_with_invalid_attributes ⇒ Object
- #test_member_associations ⇒ Object
- #test_should_create_an_object_from_a_hash ⇒ Object
- #test_should_create_the_object_from_the_hash_with_create! ⇒ Object
- #test_should_destory_all ⇒ Object
- #test_should_find_all ⇒ Object
- #test_should_find_first ⇒ Object
- #test_should_have_the_correct_inner_constants_for_veneer ⇒ Object
- #test_should_implement_limit ⇒ Object
- #test_should_implement_offset ⇒ Object
- #test_should_implement_order ⇒ Object
- #test_should_implement_order_with_desc ⇒ Object
- #test_should_instantiate_a_new_instance_of_the_object ⇒ Object
- #test_should_not_raise_when_create_can_save ⇒ Object
- #test_should_provide_invalid_attributes ⇒ Object
- #test_should_provide_valid_attributes ⇒ Object
- #test_should_setup_the_veneer_lint_class_wrapper_with_a_klass ⇒ Object
Instance Method Details
#test_collection_associations ⇒ Object
156 157 158 159 160 161 162 163 164 |
# File 'lib/veneer/lint/adapter.rb', line 156 def test_collection_associations result = Veneer(@klass).collection_associations assert result.kind_of?(Array) assert result.size > 0 hash = result.first assert hash.kind_of?(Hash) assert_not_nil hash[:name] assert_not_nil hash[:class] end |
#test_conditions ⇒ Object
147 148 149 150 151 152 153 154 |
# File 'lib/veneer/lint/adapter.rb', line 147 def test_conditions create_valid_items(3) Veneer(@klass).create(@valid_attributes) result = Veneer(@klass).all(:conditions => @valid_attributes) assert_equal 1, result.size ensure _veneer_teardown end |
#test_implementst_create_with_invalid_attributes ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/veneer/lint/adapter.rb', line 69 def test_implementst_create_with_invalid_attributes assert_raise Veneer::Errors::NotSaved do Veneer(@klass).create!(@invalid_attributes) end ensure _veneer_teardown end |
#test_member_associations ⇒ Object
166 167 168 169 170 171 172 173 174 |
# File 'lib/veneer/lint/adapter.rb', line 166 def test_member_associations result = Veneer(@klass).member_associations assert result.kind_of?(Array) assert result.size > 0 hash = result.first assert hash.kind_of?(Hash) assert_not_nil hash[:name] assert_not_nil hash[:class] end |
#test_should_create_an_object_from_a_hash ⇒ Object
48 49 50 51 52 53 |
# File 'lib/veneer/lint/adapter.rb', line 48 def test_should_create_an_object_from_a_hash r = Veneer(@klass).create(@valid_attributes) assert_instance_of @klass::VeneerInterface::InstanceWrapper, r ensure _veneer_teardown end |
#test_should_create_the_object_from_the_hash_with_create! ⇒ Object
55 56 57 58 59 60 |
# File 'lib/veneer/lint/adapter.rb', line 55 def test_should_create_the_object_from_the_hash_with_create! r = Veneer(@klass).create!(@valid_attributes) assert_instance_of @klass::VeneerInterface::InstanceWrapper, r ensure _veneer_teardown end |
#test_should_destory_all ⇒ Object
85 86 87 88 89 90 |
# File 'lib/veneer/lint/adapter.rb', line 85 def test_should_destory_all Veneer(@klass).create(@valid_attributes) assert Veneer(@klass).all.size > 0 Veneer(@klass).destroy_all assert_equal 0, Veneer(@klass).all.size end |
#test_should_find_all ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/veneer/lint/adapter.rb', line 92 def test_should_find_all create_valid_items(4) result = Veneer(@klass).all assert_kind_of Array, result assert_equal 4, result.size ensure _veneer_teardown end |
#test_should_find_first ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/veneer/lint/adapter.rb', line 101 def test_should_find_first create_valid_items(3) result = Veneer(@klass).all assert_not_nil result ensure _veneer_teardown end |
#test_should_have_the_correct_inner_constants_for_veneer ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/veneer/lint/adapter.rb', line 18 def test_should_have_the_correct_inner_constants_for_veneer assert_nothing_raised do @klass::VeneerInterface @klass::VeneerInterface::ClassWrapper @klass::VeneerInterface::InstanceWrapper end assert @klass::VeneerInterface::ClassWrapper.ancestors.include?(::Veneer::Base::ClassWrapper) assert @klass::VeneerInterface::InstanceWrapper.ancestors.include?(::Veneer::Base::InstanceWrapper) end |
#test_should_implement_limit ⇒ Object
109 110 111 112 113 114 115 |
# File 'lib/veneer/lint/adapter.rb', line 109 def test_should_implement_limit create_valid_items(4) result = Veneer(@klass).all(:limit => 2) assert_equal 2, result.size ensure _veneer_teardown end |
#test_should_implement_offset ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/veneer/lint/adapter.rb', line 138 def test_should_implement_offset create_valid_items(4) result = Veneer(@klass).all offset_result = Veneer(@klass).all(:offset => 2, :limit => 2) assert_equal result[2..4], offset_result ensure _veneer_teardown end |
#test_should_implement_order ⇒ Object
117 118 119 120 121 122 123 124 125 126 |
# File 'lib/veneer/lint/adapter.rb', line 117 def test_should_implement_order create_valid_items(4) key = @valid_attributes.keys.first ordered_result = Veneer(@klass).all(:order => key) result = Veneer(@klass).all result = result.sort_by{ |i| i.send(key) } assert_equal ordered_result, result ensure _veneer_teardown end |
#test_should_implement_order_with_desc ⇒ Object
128 129 130 131 132 133 134 135 136 |
# File 'lib/veneer/lint/adapter.rb', line 128 def test_should_implement_order_with_desc create_valid_items(4) ordered_result = Veneer(@klass).all(:order => "name desc") result = Veneer(@klass).all result = result.sort_by{ |i| i.name }.reverse assert_equal ordered_result, result ensure _veneer_teardown end |
#test_should_instantiate_a_new_instance_of_the_object ⇒ Object
62 63 64 65 66 67 |
# File 'lib/veneer/lint/adapter.rb', line 62 def test_should_instantiate_a_new_instance_of_the_object r = Veneer(@klass).new(@valid_attributes) assert_instance_of @klass::VeneerInterface::InstanceWrapper, r ensure _veneer_teardown end |
#test_should_not_raise_when_create_can_save ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/veneer/lint/adapter.rb', line 77 def test_should_not_raise_when_create_can_save assert_nothing_raised do Veneer(@klass).create(@invalid_attributes) end ensure _veneer_teardown end |
#test_should_provide_invalid_attributes ⇒ Object
41 42 43 44 45 46 |
# File 'lib/veneer/lint/adapter.rb', line 41 def test_should_provide_invalid_attributes assert_not_nil @invalid_attributes assert_kind_of Hash, @invalid_attributes ensure _veneer_teardown end |
#test_should_provide_valid_attributes ⇒ Object
34 35 36 37 38 39 |
# File 'lib/veneer/lint/adapter.rb', line 34 def test_should_provide_valid_attributes assert_not_nil @valid_attributes assert_kind_of Hash, @valid_attributes ensure _veneer_teardown end |
#test_should_setup_the_veneer_lint_class_wrapper_with_a_klass ⇒ Object
28 29 30 31 32 |
# File 'lib/veneer/lint/adapter.rb', line 28 def test_should_setup_the_veneer_lint_class_wrapper_with_a_klass super ensure _veneer_teardown end |