Skip to content

Commit

Permalink
Add spec for wrong argument to .surrealize_with
Browse files Browse the repository at this point in the history
  • Loading branch information
nesaulov committed Jan 12, 2018
1 parent b18abf2 commit 85dab45
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/serializer_spec.rb
Expand Up @@ -48,6 +48,13 @@ def color
end
end

class WrongSerializer
include Surrealist
json_schema { { name: String } }
end



RSpec.describe Surrealist::Serializer do
describe 'Explicit surrealization through `Serializer.new`' do
describe 'instance' do
Expand Down Expand Up @@ -110,4 +117,18 @@ def color
it { is_expected.to eq expectation }
end
end

describe 'Wrong class specified in .surrealize_with' do
[WrongSerializer, Integer, ActiveRecord].each do |klass|
it 'raises error' do
expect do
Class.new do
include Surrealist

surrealize_with klass
end
end.to raise_error(ArgumentError, "#{klass} should be inherited from Surrealist::Serializer")
end
end
end
end

0 comments on commit 85dab45

Please sign in to comment.