spec/serializable/paging_spec.rb in restpack_serializer-0.4.11 vs spec/serializable/paging_spec.rb in restpack_serializer-0.4.12
- old
+ new
@@ -5,12 +5,14 @@
@album1 = FactoryGirl.create(:album_with_songs, song_count: 11)
@album2 = FactoryGirl.create(:album_with_songs, song_count: 7)
end
context "#page" do
- let(:page) { MyApp::SongSerializer.page(params) }
+ let(:page) { MyApp::SongSerializer.page(params, scope, context) }
let(:params) { { } }
+ let(:scope) { nil }
+ let(:context) { { } }
context "with defaults" do
it "page defaults to 1" do
page[:meta][:songs][:page].should == 1
end
@@ -56,9 +58,18 @@
context "invalid :title" do
let(:params) { { title: "this doesn't exist" } }
it "returns the album" do
page[:meta][:songs][:count].should == 0
end
+ end
+ end
+
+ context "with context" do
+ let(:context) { { reverse_title?: true } }
+
+ it "returns reversed titles" do
+ first = MyApp::Song.first
+ page[:songs].first[:title].should == first.title.reverse
end
end
it "serializes results" do
first = MyApp::Song.first