how to test ruby inheritance with rspec
For something like this
class Child < Parent; end
I usually do:
it 'should inherit behavior from Parent' do
expect(Child.superclass).to eq(Parent)
end
Here's an easy way to test for class inheritance with RSpec:
Given
class A < B; end
a much simpler way to test inheritance with RSpec would be:
describe A do
it { expect(described_class).to be < B }
end