Skip to content

Commit

Permalink
for test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mindreframer committed Nov 23, 2014
1 parent f82e940 commit 9464b99
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
2 changes: 0 additions & 2 deletions test/base_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require './test/test_helper'

describe 'ApiView::Base' do

before do
ApiView::Engine.skip_serialization = true
end
Expand Down Expand Up @@ -60,7 +59,6 @@ def instance_convert
end

describe 'instance methods' do

describe '#convert' do
class ConvertSimpleApiView < ::ApiView::Base
attributes :some_value
Expand Down
30 changes: 30 additions & 0 deletions test/default_test.rb
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions test/engine_test.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9464b99

Please sign in to comment.