Dependencies Testing With Appraisal And Bundler

Dependencies Testing With Appraisal And Bundler

Revised talk after given at RubyKaigi 2013 (https://speakerdeck.com/sikachu/you-have-to-test-multiple-versions-of-your-gems-dependencies-you-used-appraisal-its-super-affective)

Presented at RedDotRubyConf 2013 on June 8, 2013.

F1c4a3bb1606cc4a61711e61e2fe6146?s=128

Prem Sichanugrist

June 08, 2013
Tweet

Transcript

  1. 3.
  2. 4.
  3. 5.
  4. 6.
  5. 7.
  6. 9.
  7. 12.
  8. 13.
  9. 14.

    I use a gem called “Appraisal” to test my gems

    against multiple versions of its dependencies. You should give it a try! #RDRC
  10. 15.

    I use a gem called “Appraisal” to test my gems

    against multiple versions of its dependencies. You should give it a try! #RDRC http://git.io/i-love-appraisal
  11. 16.
  12. 19.
  13. 22.

    ~>

  14. 24.
  15. 25.
  16. 26.
  17. 29.
  18. 35.
  19. 38.
  20. 41.
  21. 43.

    Why was this so bad? • Time consuming • Can’t

    test against multiple versions at once • Doesn’t handle dependency of dependency • Dependency hell • $ rm -Rf $GEM_HOME
  22. 45.
  23. 47.

    $ rvm gemset create rails-3-2 $ rvm gemset use rails-3-2

    $ gem install rails -v 3.2.13 $ rake $ rvm gemset create rails-3-1 $ rvm gemset use rails-3-1 $ gem install rails -v 3.1.12 $ rake # ...
  24. 49.
  25. 50.

    This is good, but ... • Waste of space; gems

    are not shared • Contributors need to use Ruby manager that supports Gemset • May need to have bootstrap script to setup gemsets
  26. 51.
  27. 56.

    $ bundle install --gemfile=rails-3-2.gemfile $ export BUNDLE_GEMFILE=rails-3-2.gemfile $ bundle exec

    rake $ bundle install --gemfile=rails-3-1.gemfile $ export BUNDLE_GEMFILE=rails-3-1.gemfile $ bundle exec rake
  28. 57.
  29. 58.
  30. 65.
  31. 67.
  32. 71.
  33. 72.
  34. 75.
  35. 79.

    # Run "test" task against all versions $ rake appraisal

    test # Run "test" task against a single version $ rake appraisal:rails-3-1 test
  36. 80.

    Appraisal • Allow you to set dependencies in a single

    place • Generate sub-Gemfiles for you • Install multiple versions of dependencies • Setup Bundler to use the correct version of dependency
  37. 81.
  38. 82.
  39. 86.
  40. 87.
  41. 88.
  42. 90.
  43. 92.

    1.0

  44. 95.

    Already in master • source • ruby • gem •

    git • group • gemspec * Not tested in Appraisals file yet
  45. 96.
  46. 102.

    W ork In Progress # Run "test" task against all

    versions $ rake appraisal test
  47. 103.

    W ork In Progress # Run "test" task against all

    versions $ appraisal rake test
  48. 104.

    W ork In Progress # Run "test" task against a

    single version $ rake appraisal:rails-3-1 test
  49. 105.

    W ork In Progress # Run "test" task against a

    single version $ appraisal rails3-1 rake test
  50. 106.

    W ork In Progress # Run Ruby test on a

    single file $ appraisal rails3-1 ruby -Itest test/foo_test.rb
  51. 107.
  52. 108.
  53. 109.
  54. 112.
  55. 113.
  56. 114.

    Thank you! Prem Sichanugrist (@sikachu) Tweet your love: http://git.io/i-love-appraisal http://learn.thoughtbot.com

    – Promo code: REDDOT $49 off first month of Prime I also have some stickers