Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. describe 'self.inherited' do
  2. before do
  3. class Foo
  4. def self.inherited klass; end
  5. end
  6.  
  7. Foo.stub(:inherited)
  8.  
  9. class Bar < Foo; end
  10. end
  11.  
  12. it 'should call self.inherited' do
  13. # this fails if it doesn't run first
  14. expect(Foo).to have_received(:inherited).with Bar
  15. end
  16.  
  17. it 'should do something else' do
  18. expect(true).to eq true
  19. end
  20. end
  21.  
  22. describe 'self.inherited once' do
  23. before do
  24. class Foo
  25. def self.inherited klass; end
  26. end
  27.  
  28. Foo.stub(:inherited)
  29.  
  30. class Bar < Foo; end
  31. end
  32.  
  33. it 'should call self.inherited' do
  34. @tested ||= false
  35. unless @tested
  36. expect(Foo).to have_receive(:inherited).with Bar
  37. @tested = true
  38. end
  39. end
  40.  
  41. it 'should do something else' do
  42. expect(true).to eq true
  43. end
  44. end
  45.  
  46. describe 'self.inherited' do
  47.  
  48. before do
  49. class Foo
  50. def self.inherited klass; end
  51. end
  52. # For testing other properties of subclasses
  53. class Baz < Foo; end
  54. end
  55.  
  56. it 'should call self.inherited' do
  57. Foo.stub(:inherited)
  58. class Bar < Foo; end
  59. expect(Foo).to have_received(:inherited).with Bar
  60. end
  61.  
  62. it 'should do something else' do
  63. expect(true).to eq true
  64. end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement