Pro Yearly is on sale from $80 to $50! »

Teaching RSpec to play nice with Rails

Teaching RSpec to play nice with Rails

Presented at Railsconf 2017. Video here: https://www.youtube.com/watch?v=jyPfrK1y1nc

C727e695ffdc7bf95f9f1a97da592648?s=128

Penelope Phippen

April 25, 2017
Tweet

Transcript

  1. Teaching RSpec to play nice with Rails @samphippen

  2. Friends, it’s good to be back

  3. Last year I had a life threatening illness

  4. None
  5. A precious bag of ceftriaxone, saving my life

  6. None
  7. Thanks @searls

  8. Thanks @searls #samphippenisjustin searlsconfirmed

  9. 5.1

  10. Yes*

  11. ActionChatbox::TestCase

  12. ActionDispatch ::BeliefSystemTestCase

  13. Have some faith in us

  14. 5.1 has not been released yet

  15. No changes required by you

  16. Released soon in 3.6.0

  17. No system test integration

  18. but I would welcome a PR

  19. RSpec + Rails

  20. RSpec

  21. RSpec isn’t a monolith

  22. gem “rspec”, “~> 3.5”

  23. Does nothing on it’s own

  24. None
  25. None
  26. None
  27. None
  28. Internal shared code

  29. rspec-rails

  30. None
  31. None
  32. RSpec Rails

  33. RSpec Rails our code Your rails version

  34. gem “rspec”, “~> 3.5” gem “rspec-rails”, “~> 3.5”

  35. gem “rspec-rails”, “~> 3.5”

  36. Rails

  37. Rails is a big complicated library

  38. RSpec is extremely permissive about rails versions

  39. >= 3.0

  40. None
  41. None
  42. None
  43. Don’t ask

  44. 5

  45. RSpec’s rails 5 compatability was not a smooth ride

  46. Lesson 1: 5.0 means they break things

  47. None
  48. None
  49. None
  50. None
  51. None
  52. Let’s just make sure this works with RSpec

  53. None
  54. View specs don’t work

  55. Specifically path helpers

  56. None
  57. None
  58. Switch back to working version of rails

  59. None
  60. Work out what changed

  61. controller .singleton_class .ancestors

  62. None
  63. None
  64. So we lost 3 random anonymous modules

  65. WTF even are they?

  66. actionpack-5.0.0.beta2/ lib/action_dispatch/ routing/route_set.rb:283

  67. At this point we call in an emergency rails maintainer

  68. None
  69. None
  70. None
  71. This is a huge win for collaboration

  72. Lesson 2: Some bugs are in Rails

  73. None
  74. What the hell is a signed cookie?

  75. None
  76. None
  77. None
  78. None
  79. None
  80. So now the fun begins

  81. git clone rails/rails

  82. Point the app at that rails clone

  83. git bisect bad

  84. git checkout v4.2.0.beta4

  85. git bisect good

  86. None
  87. None
  88. None
  89. and then I left it for a while

  90. and went to Rubyconf

  91. “You have a breaking commit sha? Show me”

  92. None
  93. None
  94. None
  95. “can be replicated purely with Rails using public API”

  96. There exists a twisty turny maze of dependencies

  97. Before filling an issue on a gem, check it’s not

    in a dep
  98. Lesson 3: Sometimes you can’t call in @sgrif

  99. None
  100. None
  101. None
  102. None
  103. “I made a short screencast”

  104. None
  105. None
  106. Do the bisect shimmy and shake

  107. None
  108. None
  109. None
  110. None
  111. Explaining a lot of context in a PR message is

    super useful
  112. None
  113. Gets merged!

  114. None
  115. It is fine to poke a maintainer to close an

    issue once they’ve fixed it
  116. Summary

  117. A lot of bugs that appear in RSpec can be

    because of rails
  118. Literally every fix we saw today was in a rails

    gem
  119. A Rails reproduction script is a great place to start

  120. None
  121. I will almost always ask you for a reproduction sample

    app
  122. Just calling @sgrif is a great way to get rails

    bugs fixed
  123. None
  124. Working on open source is really hard

  125. None
  126. This work represented 40+ hours of donated maintainer time

  127. Hug a maintainer

  128. Find some time to work on open source

  129. Pay a maintainer?

  130. None
  131. None
  132. Thanks @samphippen sphippen@do.co Let’s have some questions