test/include_exclude_test.rb in representable-3.0.4 vs test/include_exclude_test.rb in representable-3.1.0
- old
+ new
@@ -22,19 +22,19 @@
describe "#from_hash" do
it "accepts :exclude option" do
decorator.from_hash({"title"=>"Don't Smile In Trouble", "artist"=>{"id"=>2}}, exclude: [:title])
- song.title.must_equal "Listless"
- song.artist.must_equal Artist.new(nil, 2)
+ _(song.title).must_equal "Listless"
+ _(song.artist).must_equal Artist.new(nil, 2)
end
it "accepts :include option" do
decorator.from_hash({"title"=>"Don't Smile In Trouble", "artist"=>{"id"=>2}}, include: [:title])
- song.title.must_equal "Don't Smile In Trouble"
- song.artist.must_equal Artist.new("7yearsbadluck", 1)
+ _(song.title).must_equal "Don't Smile In Trouble"
+ _(song.artist).must_equal Artist.new("7yearsbadluck", 1)
end
it "accepts nested :exclude/:include option" do
decorator.from_hash({"title"=>"Don't Smile In Trouble", "artist"=>{"name"=>"Foo", "id"=>2, "songs"=>[{"id"=>1, "title"=>"Listless"}]}},
exclude: [:title],
@@ -42,34 +42,34 @@
exclude: [:id],
songs: { include: [:title] }
}
)
- song.title.must_equal "Listless"
- song.artist.must_equal Artist.new("Foo", nil, [Song.new("Listless", nil, nil)])
+ _(song.title).must_equal "Listless"
+ _(song.artist).must_equal Artist.new("Foo", nil, [Song.new("Listless", nil, nil)])
end
end
describe "#to_hash" do
it "accepts :exclude option" do
- decorator.to_hash(exclude: [:title]).must_equal({"artist"=>{"name"=>"7yearsbadluck", "id"=>1}})
+ _(decorator.to_hash(exclude: [:title])).must_equal({"artist"=>{"name"=>"7yearsbadluck", "id"=>1}})
end
it "accepts :include option" do
- decorator.to_hash(include: [:title]).must_equal({"title"=>"Listless"})
+ _(decorator.to_hash(include: [:title])).must_equal({"title"=>"Listless"})
end
it "accepts nested :exclude/:include option" do
decorator = representer.new(Song.new("Listless", Artist.new("7yearsbadluck", 1, [Song.new("C.O.A.B.I.E.T.L.")])))
- decorator.to_hash(
+ _(decorator.to_hash(
exclude: [:title],
artist: {
exclude: [:id],
songs: { include: [:title] }
}
- ).must_equal({"artist"=>{"name"=>"7yearsbadluck", "songs"=>[{"title"=>"C.O.A.B.I.E.T.L."}]}})
+ )).must_equal({"artist"=>{"name"=>"7yearsbadluck", "songs"=>[{"title"=>"C.O.A.B.I.E.T.L."}]}})
end
end
it "xdoes not propagate private options to nested objects" do
Cover = Struct.new(:title, :original)
@@ -80,9 +80,9 @@
property :original, extend: self
end
# FIXME: we should test all representable-options (:include, :exclude, ?)
- Cover.new("Roxanne", Cover.new("Roxanne (Don't Put On The Red Light)")).extend(cover_rpr).
- to_hash(:include => [:original]).must_equal({"original"=>{"title"=>"Roxanne (Don't Put On The Red Light)"}})
+ _(Cover.new("Roxanne", Cover.new("Roxanne (Don't Put On The Red Light)")).extend(cover_rpr).
+ to_hash(:include => [:original])).must_equal({"original"=>{"title"=>"Roxanne (Don't Put On The Red Light)"}})
end
end