Skip to content

Commit

Permalink
fix tests according to expected wrap: behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
elShiaLabeouf committed Jun 22, 2023
1 parent ee73fe0 commit d81728a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test/object_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,13 @@ class AlbumRepresenter < Representable::Decorator
it do
represented_array = AlbumRepresenter.for_collection.new(albums).to_object(wrap: wrapper)
represented_object = AlbumRepresenter.new(album).to_object(wrap: second_wrapper)
_(represented_array[0].respond_to?(wrapper)).must_equal true
_(represented_array[0].send(wrapper).songs[0].name).must_equal albums[0].songs[0].name

_(represented_array[0].class.object_id).must_equal represented_array[1].class.object_id # wrapper struct class is the same for collection
_(represented_array[0].class.object_id).wont_equal represented_object.class.object_id # wrapper structs classes are different for different wrappers
_(represented_array.respond_to?(wrapper)).must_equal true

_(represented_array.send(wrapper)[0].respond_to?(wrapper)).must_equal true
_(represented_array.send(wrapper)[0].send(wrapper).songs[0].title).must_equal albums[0].songs[0].title.upcase

_(represented_array.send(wrapper)[0].class.object_id).must_equal represented_array.send(wrapper)[1].class.object_id # wrapper struct class is the same for collection
_(represented_array.send(wrapper)[0].class.object_id).wont_equal represented_object.class.object_id # wrapper structs classes are different for different wrappers
end
end

0 comments on commit d81728a

Please sign in to comment.