Add spec for proc methods with optional arguments
This commit is contained in:
parent
449c1bf05f
commit
e05193fb5e
@ -235,6 +235,7 @@ describe FastJsonapi::ObjectSerializer do
|
||||
before do
|
||||
movie.release_year = 2008
|
||||
MovieSerializer.attribute :released_in_year, &:release_year
|
||||
MovieSerializer.attribute :name, &:local_name
|
||||
end
|
||||
|
||||
after do
|
||||
@ -242,7 +243,7 @@ describe FastJsonapi::ObjectSerializer do
|
||||
end
|
||||
|
||||
it 'returns correct hash when serializable_hash is called' do
|
||||
expect(serializable_hash[:data][:attributes][:name]).to eq movie.name
|
||||
expect(serializable_hash[:data][:attributes][:name]).to eq "english #{movie.name}"
|
||||
expect(serializable_hash[:data][:attributes][:released_in_year]).to eq movie.release_year
|
||||
end
|
||||
end
|
||||
|
||||
@ -54,6 +54,10 @@ RSpec.shared_context 'movie class' do
|
||||
"#{id}"
|
||||
end
|
||||
|
||||
def local_name(locale = :english)
|
||||
"#{locale} #{name}"
|
||||
end
|
||||
|
||||
def url
|
||||
"http://movies.com/#{id}"
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user