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

Inside 30days Album - Fighting against legacy R...

Kensuke Nagae
September 16, 2012

Inside 30days Album - Fighting against legacy Rails #sprk2012

Kensuke Nagae

September 16, 2012
Tweet

More Decks by Kensuke Nagae

Other Decks in Technology

Transcript

  1. Stub def pay! if credit_card.valid? # validate with complex process

    Payment.create! end end credit_card.stub(:valid?).and_return(true) expects { pay! }.change { Payment.count }.by(1) 12೥9݄17೔݄༵೔
  2. “I was worried about writing tests against existent code. It

    seems stupid. Is it worth?” 12೥9݄17೔݄༵೔
  3. def sleep_sort(ary) ary.map{|n|Thread.new{sleep n; $*<<n}}.join # What? end def test_sleep_sort

    ary = [*1..10] sleep_sort(ary) assert_equal ary, $* # need to wait 10+ seconds :P end 12೥9݄17೔݄༵೔
  4. if Rails::VERSION::STRING <= '2.1.2' unless Time.singleton_methods.include?(:zone) class Time def self.zone

    Time # enable to call Time.zone.now end end end end 12೥9݄17೔݄༵೔
  5. SELECT * FROM photos WHERE album_id = ? AND (deleted_at

    IS NULL OR deleted_at >= ?) SQL modification by acts_as_paranoid 12೥9݄17೔݄༵೔