From 9464b99a5bc35868c725704688bff06458adf488 Mon Sep 17 00:00:00 2001 From: Roman Heinrich Date: Sun, 23 Nov 2014 01:34:44 +0100 Subject: [PATCH] for test coverage --- test/base_test.rb | 2 -- test/default_test.rb | 30 ++++++++++++++++++++++++++++++ test/engine_test.rb | 22 ++++++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 test/default_test.rb create mode 100644 test/engine_test.rb diff --git a/test/base_test.rb b/test/base_test.rb index 4610a67..078ff39 100644 --- a/test/base_test.rb +++ b/test/base_test.rb @@ -1,7 +1,6 @@ require './test/test_helper' describe 'ApiView::Base' do - before do ApiView::Engine.skip_serialization = true end @@ -60,7 +59,6 @@ def instance_convert end describe 'instance methods' do - describe '#convert' do class ConvertSimpleApiView < ::ApiView::Base attributes :some_value diff --git a/test/default_test.rb b/test/default_test.rb new file mode 100644 index 0000000..c5dd330 --- /dev/null +++ b/test/default_test.rb @@ -0,0 +1,30 @@ +require './test/test_helper' + +describe 'ApiView::Default' do + describe 'class methods' do + describe 'convert' do + it "works with to_api" do + mock = Minitest::Mock.new.expect(:to_api, {field: 'to_api'}) + res = ApiView::Default.convert(mock) + res.must_equal({:field=>"to_api"}) + end + + it "works with to_hash" do + mock = Minitest::Mock.new.expect(:to_hash, {field: 'to_hash'}) + res = ApiView::Default.convert(mock) + res.must_equal({:field=>"to_hash"}) + end + + it "works with serializable_hash" do + mock = Minitest::Mock.new.expect(:serializable_hash, {field: 'serializable_hash'}) + res = ApiView::Default.convert(mock) + res.must_equal({:field=>"serializable_hash"}) + end + + it "works with serializable_hash" do + res = ApiView::Default.convert({hey: 'hey'}) + res.must_equal({:hey=>"hey"}) + end + end + end +end diff --git a/test/engine_test.rb b/test/engine_test.rb new file mode 100644 index 0000000..24fb7f9 --- /dev/null +++ b/test/engine_test.rb @@ -0,0 +1,22 @@ +require './test/test_helper' + +describe 'ApiView::Engine' do + describe 'class methods' do + describe 'render' do + it "just works" do + res = ApiView::Engine.render('hey') + res.must_equal 'hey' + end + end + + describe 'render' do + it "just works" do + res = ApiView::Engine.convert('hey') + res.must_equal 'hey' + end + end + end + + describe 'instance methods' do + end +end \ No newline at end of file