Class: Goz::Group::TestCase
- Defined in:
- lib/goz/group/test_case.rb
Overview
Instance Method Summary collapse
- #setup ⇒ Object
- #skip? ⇒ Boolean
- #test_create ⇒ Object
- #test_create_with_invalid_parameters ⇒ Object
- #test_default_initialization ⇒ Object
- #test_find_by_name_for_group_that_does_exist ⇒ Object
- #test_find_by_name_for_group_that_does_not_exist ⇒ Object
- #test_sync_with_provider ⇒ Object
- #test_sync_with_provider_add_admin ⇒ Object
- #test_sync_with_provider_add_member ⇒ Object
- #test_sync_with_provider_no_admin_or_member_changes ⇒ Object
- #test_sync_with_provider_remove_admin ⇒ Object
- #test_sync_with_provider_remove_member ⇒ Object
- #test_update ⇒ Object
Instance Method Details
#setup ⇒ Object
22 23 24 25 26 |
# File 'lib/goz/group/test_case.rb', line 22 def setup super @klass ||= self.class @skip = @klass == Goz::Group::TestCase end |
#skip? ⇒ Boolean
28 29 30 |
# File 'lib/goz/group/test_case.rb', line 28 def skip? @skip end |
#test_create ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/goz/group/test_case.rb', line 131 def test_create return if skip? t = Time.now g = @klass.create @groups[:a].merge( :klass => @klass.name ) assert_not_nil g assert_kind_of @klass, g assert_equal @groups[:a][:display_name], g.display_name assert_equal @groups[:a][:identifier], g.identifier assert_equal @klass.name, g.klass assert_equal @groups[:a][:name], g.name assert_not_nil g.created_at assert g.created_at >= t end |
#test_create_with_invalid_parameters ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/goz/group/test_case.rb', line 73 def test_create_with_invalid_parameters return if skip? assert_raise(RuntimeError, 'invalid display_name') { @klass.create(nil) } assert_raise(RuntimeError, 'invalid display_name') { @klass.create( :identifier => @groups[:a][:identifier], :klass => @klass.name, :name => @groups[:a][:name] ) } assert_raise(RuntimeError, 'invalid display_name') { @klass.create( :display_name => '', :identifier => @groups[:a][:identifier], :klass => @klass.name, :name => @groups[:a][:name] ) } assert_raise(RuntimeError, 'invalid identifier') { @klass.create( :display_name => @groups[:a][:display_name], :klass => @klass.name, :name => @groups[:a][:name] ) } assert_raise(RuntimeError, 'invalid identifier') { @klass.create( :display_name => @groups[:a][:display_name], :identifier => '', :klass => @klass.name, :name => @groups[:a][:name] ) } assert_raise(RuntimeError, 'invalid klass') { @klass.create( :display_name => @groups[:a][:display_name], :identifier => @groups[:a][:identifier], :name => @groups[:a][:name] ) } assert_raise(RuntimeError, 'invalid klass') { @klass.create( :display_name => @groups[:a][:display_name], :identifier => @groups[:a][:identifier], :klass => '', :name => @groups[:a][:name] ) } assert_raise(RuntimeError, 'invalid name') { @klass.create( :display_name => @groups[:a][:display_name], :identifier => @groups[:a][:identifier], :klass => @klass.name ) } assert_raise(RuntimeError, 'invalid name') { @klass.create( :display_name => @groups[:a][:display_name], :identifier => @groups[:a][:identifier], :klass => @klass.name, :name => '' ) } end |
#test_default_initialization ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/goz/group/test_case.rb', line 33 def test_default_initialization return if skip? blockable = false group = @klass.new do |g| assert_kind_of @klass, g assert_nil g.display_name assert_nil g.identifier assert_nil g.klass assert_nil g.name assert_nil g.created_at assert_nil g.modified_at assert_nil g.synchronized_at blockable = true end assert blockable, 'works as block' assert_kind_of Goz::Group, group assert_kind_of @klass, group unless @klass == Goz::Group assert_kind_of @klass, @klass.new assert_nil group.display_name assert_nil group.identifier assert_nil group.klass assert_nil group.name assert_nil group.created_at assert_nil group.modified_at assert_nil group.synchronized_at end |
#test_find_by_name_for_group_that_does_exist ⇒ Object
67 68 69 70 71 |
# File 'lib/goz/group/test_case.rb', line 67 def test_find_by_name_for_group_that_does_exist return if skip? return if @klass == Goz::Group fail("not implemented") end |
#test_find_by_name_for_group_that_does_not_exist ⇒ Object
61 62 63 64 65 |
# File 'lib/goz/group/test_case.rb', line 61 def test_find_by_name_for_group_that_does_not_exist return if skip? assert_nil @klass.find_by_name @groups[:a][:name] end |
#test_sync_with_provider ⇒ Object
160 161 162 163 164 |
# File 'lib/goz/group/test_case.rb', line 160 def test_sync_with_provider return if skip? return if @klass == Goz::Group fail("not implemented") end |
#test_sync_with_provider_add_admin ⇒ Object
172 173 174 175 176 |
# File 'lib/goz/group/test_case.rb', line 172 def test_sync_with_provider_add_admin return if skip? return if @klass == Goz::Group fail("not implemented") end |
#test_sync_with_provider_add_member ⇒ Object
184 185 186 187 188 |
# File 'lib/goz/group/test_case.rb', line 184 def test_sync_with_provider_add_member return if skip? return if @klass == Goz::Group fail("not implemented") end |
#test_sync_with_provider_no_admin_or_member_changes ⇒ Object
166 167 168 169 170 |
# File 'lib/goz/group/test_case.rb', line 166 def test_sync_with_provider_no_admin_or_member_changes return if skip? return if @klass == Goz::Group fail("not implemented") end |
#test_sync_with_provider_remove_admin ⇒ Object
178 179 180 181 182 |
# File 'lib/goz/group/test_case.rb', line 178 def test_sync_with_provider_remove_admin return if skip? return if @klass == Goz::Group fail("not implemented") end |
#test_sync_with_provider_remove_member ⇒ Object
190 191 192 193 194 |
# File 'lib/goz/group/test_case.rb', line 190 def test_sync_with_provider_remove_member return if skip? return if @klass == Goz::Group fail("not implemented") end |
#test_update ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/goz/group/test_case.rb', line 146 def test_update return if skip? g = Goz::Group.create @groups[:a].merge( :klass => @klass.name ) g.name = g.name.reverse g.save assert_not_nil g.modified_at assert_kind_of Time, g.modified_at assert g.modified_at > g.created_at assert_nil g.synchronized_at end |