Skip to content

Commit

Permalink
move desribe blocks into specs to allow subject to be setup in spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ConorSheehan1 committed Oct 4, 2018
1 parent 3a02c90 commit 7624a04
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
6 changes: 2 additions & 4 deletions spec/support/shared_examples/json_format.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
shared_examples 'it has symmetric as_json and to_json methods' do
describe '#as_json' do
it 'should return a json representation of the object as a ruby hash' do
expect(subject.as_json).to eq JSON.parse(subject.to_json)
end
it 'should return a json representation of the object as a ruby hash' do
expect(subject.as_json).to eq JSON.parse(subject.to_json)
end
end
4 changes: 3 additions & 1 deletion spec/unit/iiif/presentation/annotation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
it_behaves_like 'it has the appropriate methods for abstract_resource_only_keys'
end

it_behaves_like 'it has symmetric as_json and to_json methods'
describe "#{described_class}.as_json" do
it_behaves_like 'it has symmetric as_json and to_json methods'
end
end
4 changes: 3 additions & 1 deletion spec/unit/iiif/presentation/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
describe '#validate' do
end

it_behaves_like 'it has symmetric as_json and to_json methods'
describe '#as_json' do
it_behaves_like 'it has symmetric as_json and to_json methods'
end
end


19 changes: 19 additions & 0 deletions spec/unit/iiif/presentation/image_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,23 @@
it_behaves_like 'it has the appropriate methods for integer-only keys'
end

let(:fixed_values) do
{
"@context" => "http://iiif.io/api/presentation/2/context.json",
"@id" => "http://www.example.org/iiif/image",
"label" => "p. 1",
"height" => 1000,
"width" => 750,
}
end

# describe '#as_json' do
# # must have @id, width, height etc to pass validation in to_ordered_hash
# # could also use to_oredered_hash(force: true) to skip validation
# subject do
# IIIF::Presentation::Canvas.new(fixed_values)
# end
# it_behaves_like 'it has symmetric as_json and to_json methods'
# end
it_behaves_like 'it has symmetric as_json and to_json methods'
end
7 changes: 7 additions & 0 deletions spec/unit/iiif/presentation/layer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,12 @@
it_behaves_like 'it has the appropriate methods for any-type keys'
end

describe "#{described_class}.as_json" do
subject do
IIIF::Presentation::Layer.new(fixed_values)
end
it_behaves_like 'it has symmetric as_json and to_json methods'
end

end

5 changes: 3 additions & 2 deletions spec/unit/iiif/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def self.singleton_class?
end
end


it_behaves_like 'it has symmetric as_json and to_json methods'
describe '#as_json' do
it_behaves_like 'it has symmetric as_json and to_json methods'
end

end

0 comments on commit 7624a04

Please sign in to comment.