Machinist-caching

852 views

Published on

Presentation about machinist-caching in RS on Rails 2011

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Machinist-caching

  1. 1. Machinist-caching @tomas_stefano http://rubycasts.com.br SuccesSoft Nohup
  2. 2. Fixtures/factories/etc.• Object Daddy (último commit em 2009 : )• Factory Girl• Machinist• Fabrication• Fixtures
  3. 3. Scenarioclass Country < ActiveRecord::Base validates :name, presence: true, uniqueness: { allow_blank: true }endclass State < ActiveRecord::Base validates :name, presence: true, uniqueness: { allow_blank: true }endclass City < ActiveRecord::Base validates :name, presence: true, uniqueness: { allow_blank: true }end
  4. 4. ScenarioCountry.blueprint(:brasil) do name { Brasil sil sil!! }end
  5. 5. ScenarioState.blueprint(:minas_gerais) do name { Minas Gerais } acronym { MG } country { Country.make!(:brasil) }endState.blueprint(:rio_grande_do_sul) do name { Rio Grande do Sul } acronym { RS } country { Country.make!(:brasil) }end
  6. 6. ScenarioCity.blueprint(:belo_horizonte) do name { Belo Horizonte(Belzonte!) } state { State.make!(:minas_gerais) }endCity.blueprint(:porto_alegre) do name { Porto Alegre } state { State.make!(:rio_grande_do_sul) }end
  7. 7. ProblemaCity.make!(:belo_horizonte)City.make!(:porto_alegre)=> Country: Nome está em uso# :S
  8. 8. Problemabrasil = Country.make!(:brasil)mg = State.make!(:minas_gerais, country: brasil)rs = State.make!(:rio_grande_do_sul, country: brasil)City.make!(:belo_horizonte, state: mg)City.make!(:porto_alegre, state: rs)
  9. 9. Parece que Algo está errado
  10. 10. Soluçãogem install machinist-caching
  11. 11. RSpecRSpec.configure do |config| config.before do Machinist::Caching::Shop.instance.reset! endend
  12. 12. Test::unitclass Test::Unit::TestCase def setup Machinist::Caching::Shop.instance.reset! endend
  13. 13. ProntoCity.make!(:belo_horizonte)City.make!(:porto_alegre)
  14. 14. Obrigado! @tomas_stefanohttp://rubycasts.com.br

×