Created
April 25, 2018 13:04
-
-
Save Ezku/9e969e91975a276bb46d70b0ba9c80e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'hypothesis' | |
require_dependency 'nuugeo' | |
RSpec.describe Nuugeo::Viewport::Union do | |
include Hypothesis | |
include Hypothesis::Possibilities | |
def union(left, right) | |
described_class.call(left, right) | |
end | |
def arbitrary_degrees | |
integers(min: -180, max: 180) | |
end | |
def arbitrary_viewport | |
hash_of_shape( | |
south: arbitrary_degrees, | |
west: arbitrary_degrees, | |
north: arbitrary_degrees, | |
east: arbitrary_degrees | |
).map do |cardinal_points| | |
Nuugeo::Viewport.build(cardinal_points) | |
end | |
end | |
describe 'smoke spec' do | |
it 'accepts two viewports and returns a viewport' do | |
expect(union(Nuugeo::Viewport.empty, Nuugeo::Viewport.empty)) | |
.to be_kind_of(Nuugeo::Viewport) | |
end | |
end | |
it 'any union of two viewports contains both of the two viewports' do | |
hypothesis do | |
left_viewport = any arbitrary_viewport | |
right_viewport = any arbitrary_viewport | |
left_right_union = union(left_viewport, right_viewport) | |
expect(left_right_union.contains?(left_viewport)).to be true | |
expect(left_right_union.contains?(right_viewport)).to be true | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment