Guest User

Untitled

a guest
Jul 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. ## normal.rb
  2.  
  3. class Base
  4. def foo; 1 end
  5. end
  6.  
  7. describe Base do
  8. it "should work" { Base.new.foo.should == 1 }
  9. end
  10.  
  11. class Derived
  12. def bar
  13. foo + 1
  14. end
  15. end
  16.  
  17. describe Derived do
  18. it "should work" { Derived.new.bar.should == 2 }
  19. end
  20.  
  21. ## database.rb
  22.  
  23. class Base
  24. def foo; SQL['SELECT id FROM table'].to_i end
  25. end
  26.  
  27. describe Base do
  28. before { @base = Base.new; @base.stub!(:SQL).returns(1) } # not actually valid, i know
  29. it "should work" { @base.foo.should == 1 }
  30. end
  31.  
  32. class Derived
  33. def bar
  34. foo + 1
  35. end
  36. end
  37.  
  38. describe Derived do
  39. it "should work" { Derived.new.bar.should == 2 }
  40. end
Add Comment
Please, Sign In to add comment