| |   |
| 334 | 334 | end |
| 335 | 335 | |
| 336 | 336 | |
| 337 | end |
| 338 | |
| 339 | describe "ImplementsSomeName with multiple implements" do |
| 340 | |
| 341 | before(:each) do |
| 342 | setup_default_store |
| 343 | setup_index |
| 344 | |
| 345 | Object.send!(:remove_const,'SomeName') if defined?(SomeName) |
| 346 | SomeName = Meta.new(:some_slot => 'some_value') do |
| 347 | def some_name_meta |
| 348 | end |
| 349 | end |
| 350 | Object.send!(:remove_const,'SomeName1') if defined?(SomeName1) |
| 351 | SomeName1 = Meta.new(:some_slot1 => 'some_value1') do |
| 352 | def some_name_meta1 |
| 353 | end |
| 354 | end |
| 355 | Object.send!(:remove_const,'ImplementsSomeName') if defined?(ImplementsSomeName) |
| 356 | ImplementsSomeName = Meta.new(:some_another_slot => 'some_another_value') do |
| 357 | def implements_some_name_meta |
| 358 | end |
| 359 | implements SomeName |
| 360 | implements SomeName1 |
| 361 | end |
| 362 | end |
| 363 | |
| 364 | it "should create a document which is both SomeName, SomeName1, and ImplementsSomeName" do |
| 365 | doc = ImplementsSomeName.create!.reload |
| 366 | doc.should be_a_kind_of(SomeName) |
| 367 | doc.should be_a_kind_of(SomeName1) |
| 368 | doc.should be_a_kind_of(ImplementsSomeName) |
| 369 | end |
| 370 | |
| 371 | it "should have SomeName's and SomeName1's slots merged in" do |
| 372 | ImplementsSomeName.document.slotnames.should include('some_another_slot') |
| 373 | ImplementsSomeName.document.some_another_slot.should == "some_another_value" |
| 374 | ImplementsSomeName.document.slotnames.should include('some_slot') |
| 375 | ImplementsSomeName.document.some_slot.should == "some_value" |
| 376 | ImplementsSomeName.document.slotnames.should include('some_slot1') |
| 377 | ImplementsSomeName.document.some_slot1.should == "some_value1" |
| 378 | |
| 379 | end |
| 380 | |
| 381 | it "should not share the same uuid with either SomeName or SomeName1" do |
| 382 | ImplementsSomeName.document.uuid.should_not == SomeName.document.uuid |
| 383 | ImplementsSomeName.document.uuid.should_not == SomeName1.document.uuid |
| 384 | end |
| 385 | |
| 386 | it "should create document that responds both to #some_name_meta, #some_name_meta1, #implements_some_name_meta" do |
| 387 | doc = ImplementsSomeName.create!.reload |
| 388 | doc.should respond_to(:some_name_meta) |
| 389 | doc.should respond_to(:some_name_meta1) |
| 390 | doc.should respond_to(:implements_some_name_meta) |
| 391 | end |
| 392 | |
| 393 | it "should preserve its name" do |
| 394 | ImplementsSomeName.name.should == "ImplementsSomeName" |
| 395 | end |
| 396 | |
| 397 | |
| 337 | 398 | end |
| toggle raw diff |
--- a/spec/lib/strokedb/document/meta_spec.rb
+++ b/spec/lib/strokedb/document/meta_spec.rb
@@ -334,4 +334,65 @@ describe "ImplementsSomeName with implements SomeName meta" do
end
+end
+
+describe "ImplementsSomeName with multiple implements" do
+
+ before(:each) do
+ setup_default_store
+ setup_index
+
+ Object.send!(:remove_const,'SomeName') if defined?(SomeName)
+ SomeName = Meta.new(:some_slot => 'some_value') do
+ def some_name_meta
+ end
+ end
+ Object.send!(:remove_const,'SomeName1') if defined?(SomeName1)
+ SomeName1 = Meta.new(:some_slot1 => 'some_value1') do
+ def some_name_meta1
+ end
+ end
+ Object.send!(:remove_const,'ImplementsSomeName') if defined?(ImplementsSomeName)
+ ImplementsSomeName = Meta.new(:some_another_slot => 'some_another_value') do
+ def implements_some_name_meta
+ end
+ implements SomeName
+ implements SomeName1
+ end
+ end
+
+ it "should create a document which is both SomeName, SomeName1, and ImplementsSomeName" do
+ doc = ImplementsSomeName.create!.reload
+ doc.should be_a_kind_of(SomeName)
+ doc.should be_a_kind_of(SomeName1)
+ doc.should be_a_kind_of(ImplementsSomeName)
+ end
+
+ it "should have SomeName's and SomeName1's slots merged in" do
+ ImplementsSomeName.document.slotnames.should include('some_another_slot')
+ ImplementsSomeName.document.some_another_slot.should == "some_another_value"
+ ImplementsSomeName.document.slotnames.should include('some_slot')
+ ImplementsSomeName.document.some_slot.should == "some_value"
+ ImplementsSomeName.document.slotnames.should include('some_slot1')
+ ImplementsSomeName.document.some_slot1.should == "some_value1"
+
+ end
+
+ it "should not share the same uuid with either SomeName or SomeName1" do
+ ImplementsSomeName.document.uuid.should_not == SomeName.document.uuid
+ ImplementsSomeName.document.uuid.should_not == SomeName1.document.uuid
+ end
+
+ it "should create document that responds both to #some_name_meta, #some_name_meta1, #implements_some_name_meta" do
+ doc = ImplementsSomeName.create!.reload
+ doc.should respond_to(:some_name_meta)
+ doc.should respond_to(:some_name_meta1)
+ doc.should respond_to(:implements_some_name_meta)
+ end
+
+ it "should preserve its name" do
+ ImplementsSomeName.name.should == "ImplementsSomeName"
+ end
+
+
end
\ No newline at end of file |