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

RSpecと非同期関数テスト

 RSpecと非同期関数テスト

於 TokyuRubyKaigi11 2017/07/29
https://tokyurubykaigi.github.io/tokyu11/

shigeru. nakajima

July 29, 2017
Tweet

More Decks by shigeru. nakajima

Other Decks in Technology

Transcript

  1. ඇಉظؔ਺ͷ݁ՌΛϝΠϯεϨουʹ໭͢ it 'ඇಉظؔ਺ͷࣦഊΛั·͑ΒΕΔ͜ͱ' do result = async_play do |curtail| async_func

    do |result| curtail.call result end end expect(result).to eq(expected_value) end ͜ΕͳΒςετͰ͖ͦ͏
  2. ΩϡʔΛ࢖͏ def async_play q = Queue.new yield (reuslt) -> {

    q.push result } q.pop end Ωϡʔ͸pop͢Δͱ push͞ΕΔ·Ͱ଴ͭ
  3. ࢼ͔ͨͬͨ͠Βgem͋Δ gem 'async_play' results = AsyncPlay.opening{ | curtain | Thread.new

    { curtain.call 1 } } ৄࡉ͸ http://qiita.com/ledsun/items/ 0e1dd4ece43dc56653c7