Skip to content

Instantly share code, notes, and snippets.

@bolshakov
Created September 27, 2017 08:16
Show Gist options
  • Select an option

  • Save bolshakov/5d17f998efeee1bb1f13ca1f67d8bc54 to your computer and use it in GitHub Desktop.

Select an option

Save bolshakov/5d17f998efeee1bb1f13ca1f67d8bc54 to your computer and use it in GitHub Desktop.
abstract struct A
def self.build(value)
if value.nil?
B.new
else
C.new
end
end
end
struct B < A
end
struct C < A
end
describe A do
it "C" do
result = A.build(42)
result.should eq(C.new)
end
it "B" do
result = A.build(nil)
result.should eq(B.new)
end
end
@bolshakov
Copy link
Author

.F

Failures:

  1) A B
     Failure/Error: result.should eq(B.new)

       Expected: B() : B
            got: B() : B

     # spec/a_spec.cr:51

Finished in 887 microseconds
2 examples, 1 failures, 0 errors, 0 pending

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment