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
|
before do
|
||||||
movie.release_year = 2008
|
movie.release_year = 2008
|
||||||
MovieSerializer.attribute :released_in_year, &:release_year
|
MovieSerializer.attribute :released_in_year, &:release_year
|
||||||
|
MovieSerializer.attribute :name, &:local_name
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
@ -242,7 +243,7 @@ describe FastJsonapi::ObjectSerializer do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'returns correct hash when serializable_hash is called' do
|
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
|
expect(serializable_hash[:data][:attributes][:released_in_year]).to eq movie.release_year
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -54,6 +54,10 @@ RSpec.shared_context 'movie class' do
|
|||||||
"#{id}"
|
"#{id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def local_name(locale = :english)
|
||||||
|
"#{locale} #{name}"
|
||||||
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"http://movies.com/#{id}"
|
"http://movies.com/#{id}"
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user