Closed janko closed 9 years ago
The "JSON round trip" test skips the mapper. It only tests JSON-API -> Yaks::Resource -> JSON-API
RSpec.shared_examples_for 'JSON round trip' do |yaks, format, name|
let(:json) { load_json_fixture("#{name}.#{format}") }
subject {
resource = yaks.read(json, hooks: [[:skip, :parse]])
yaks.call(resource, hooks: [[:skip, :map]], mapper: Struct.new(:context))
}
it { should deep_eql json }
end
Seems the JSON reader wasn't kept up to date with the writer's capabilities, and because our acceptance tests weren't functioning properly nobody noticed. I have some work in progress stuff in #88 to improve/fix the tests, after that's in I'll see if I can get your changes in and bring the Reader up to date with the Writer.
Great that you're updating it. I can also just rebase to master after you merge it, and try to fix it in this branch, I know what I should write in the *.json fixtures.
TODO (for myself): I need to still add the test for case when there is no id
, to test that Yaks doesn't add the id
containing an empty string (Mutant will probably remind me about this missing test).
Updated!
There are still a lot of issues in the 1.0 milestone for JSON-API, so I think I will completely finish the spec in Yaks when JSON-API reaches 1.0. But I think now it's really close enough :)
Ok, fixed the mentioned things, now just to wait for the build to finish.
What the heck, I really want to stay updated with JSON-API, and hopefully 1.0 will be released soon. The new change with the "attributes" key was totally justified, even though it wouldn't be necessary if there wasn't for "data" key in the first place.
I couldn't figure out how to get acceptance tests passing, regarding the links. I tried in the console, and the links are generated fine. But in acceptance tests the links are just eaten up, and there is always this "href", even though JSON-API doesn't set it anywhere (I removed it because JSON-API removed it). After a lot of debugging I found out that the JSON-API acceptance test doesn't even use
Yaks::Mapper#call
. What is going on there? :P