Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe 'self.inherited' do
- before do
- class Foo
- def self.inherited klass; end
- end
- Foo.stub(:inherited)
- class Bar < Foo; end
- end
- it 'should call self.inherited' do
- # this fails if it doesn't run first
- expect(Foo).to have_received(:inherited).with Bar
- end
- it 'should do something else' do
- expect(true).to eq true
- end
- end
- describe 'self.inherited once' do
- before do
- class Foo
- def self.inherited klass; end
- end
- Foo.stub(:inherited)
- class Bar < Foo; end
- end
- it 'should call self.inherited' do
- @tested ||= false
- unless @tested
- expect(Foo).to have_receive(:inherited).with Bar
- @tested = true
- end
- end
- it 'should do something else' do
- expect(true).to eq true
- end
- end
- describe 'self.inherited' do
- before do
- class Foo
- def self.inherited klass; end
- end
- # For testing other properties of subclasses
- class Baz < Foo; end
- end
- it 'should call self.inherited' do
- Foo.stub(:inherited)
- class Bar < Foo; end
- expect(Foo).to have_received(:inherited).with Bar
- end
- it 'should do something else' do
- expect(true).to eq true
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement