Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Intro to RSpec

Intro to RSpec

Introduction to RSpec

Stephanie Viccari

December 14, 2020
Tweet

More Decks by Stephanie Viccari

Other Decks in Education

Transcript

  1. W lc me! L 's e o c o .

    4 i c y f 4 s a y 'r e l i c 2
  2. S ep an e ic ar T am ea @

    t ou ht ot I'm xc te t l ar ... J sh la to M na in D re to @ t ou ht ot I'm xc te t l ar ... 3
  3. B fo e e et ta te ... 4 J

    h S c ! 4 E q n i n 4 T o w ! # 4
  4. C as S he ul (C ) ! a -

    C ☕ 1 :3 - B (1 m ) ☕ 1 :3 - B (1 m ) # 1 :2 - l u S (1 m ) $ 1 :3 - D ! 5
  5. C as S he ul (P ) ! p -

    C ☕ 2:3 - B (1 m ) ☕ 3:3 - B (1 m ) # 4:2 - l u S (1 m ) $ 4:3 - D ! 6
  6. W o s hi c as f r? P h

    a : - e w t - e w t t R - e n n l o e p & t 7
  7. W at e'l C ve i t is ou se

    4 I c T t R 4 R M s n S E s 4 M , S , n S 4 F e n let 4 M i F T 4 T T -P A 4 T U d C 8
  8. W y o e ri e es s? 4 R

    b 4 S d t 4 I h d u c 9
  9. W en o e ri e es s? T F

    D m n s A D m 1
  10. T st ir t ev lo me t 1. w

    a f t 2. w d k h s p 3. r r 4 A k a : T -D D m (T ) R /G /R r 1
  11. T st ft r ev lo me t 1. w

    a t c 2. w p t 1
  12. T st ir t ev lo me t B t

    4 V e i a a i 4 E g r r 4 I u h d u c 1
  13. T st ir t ev lo me t C 4

    T p e 4 R s w a s e o h l a h p 1
  14. T st ir t ev lo me t H a

    I "t r " e u d d a e ? 1) W t o e g b r. * (ex: test the Happy Path) 2) W t o e b r. 1
  15. T st ft r ev lo me t B t

    4 A w u s t (e.g., T a F S ) 4 W t e o o r a h p 1
  16. T st ft r ev lo me t C 4

    S f k u m t 4 D a i n r r 4 F w s a u d r t 1
  17. T rm no og 4 U t * 4 M

    t 4 C l t 4 V t 4 F t 4 R i t 4 E -t -E t * 4 C n t 4 C t t 4 I t t * 4 U t 4 S t 1
  18. U it es s... ...t d i o , i

    d h s d s . E s: 4 t a s c m 4 V s 1
  19. I te ra io T st ... ...e e u

    u s e s e p d r t r. E s: 4 C l s 4 J s 2
  20. E d-t -E d es s... ...e e h s

    a w . e r t l w o h u 's p t . E s: 4 F s 2
  21. C ea in a al nc d es P rt

    ol o s v a o i t , w a f n f . e n v a s n i t t a a e s n e -t -e t , w y h c d t s o u r s f n r o r . 2
  22. L t's ri e om c de! G : s

    h R , G , R r c i n a c t a c : 4 a w n 4 c t f a 2
  23. E er is C de ce F s : -

    I'l a t e . S s : - W 'l o p h s e . ("W W a M a " S ) 2
  24. R vi w W e R , G , R

    r t : 4 d u c 's i c 4 g t h e m s 4 r r s 4 c w d t c d 2
  25. O ga iz ng ur es s RSpec.describe MyClass do

    describe "used to describe behavior" do it "describes a specific example" do; end context "highlights a special circumstance" do it "describes a specific example" do; end end end end 2
  26. F ur ha e es RSpec.describe Calculator do describe "#add"

    do it "returns the sum of the two arguments" do setup (required setup) exercise (exercise system under test) verify (result is verified against an expectation) teardown (system under test is reset) end end end 2
  27. R pe F cu F lt r R v <=

    3.4 RSpec.configure do |config| config.filter_run_including :focus => true config.run_all_when_everything_filtered = true end 3
  28. R pe F cu F lt r R v >=

    3.5 RSpec.configure do |config| config.filter_run_when_matching: :focus end 3
  29. R so rc s M F T a - h

    ://m o .c /b /T a .h R .d e d e - h ://r p .c /r /r -c /v/3-7/d /c g n/z -m -p g-m F -P T - h ://t b .c /b /f -p -t R F F v .4 - h ://r p .c /r /r -c /v/3-4/d / l /i o - l - h ://r p .c /r /r -c /v/3-4/d /c g n/r -a -w -e i - l R F F v .5 - h ://r p .c /r /r -c /v/3-5/d / l / l -r -w -m g 3