rspec-time_stop (0.1.0): Stop current time in example. https://t.co/7RArS5QO0o
— RubyGems (@rubygems) 2018å¹´8æ25æ¥
ã¢ããã¼ã·ã§ã³
åè·ã® spec/support/
ã«ãããã£ããã¹ãç³»ã®ä¾¿å©ãã«ããç¾è·ã§ã使ããããªã£ãã®ã§è¨æ¶ãããµã«ãã¼ã¸ãã¦gemåãã¾ãã
使ãæ¹
it
ã describe
ã« :time_stop
ãã¤ããã ãã§ç¾å¨æå»ãæ¢ããç¶æ
ã§ãã¹ããå®è¡ãã¾ã
å®è£ ã¯ãã£ãããã ãã§ã
https://github.com/sue445/rspec-time_stop/blob/v0.1.0/lib/rspec/time_stop.rb
ä¾
READMEããã³ãã
RSpec.describe Rspec::TimeStop do context "with :time_stop", :time_stop do it "current time is freezed" do before_time = Time.now sleep 1 after_time = Time.now expect(after_time).to eq before_time end end context "without :time_stop" do it "current time is not freezed" do before_time = Time.now sleep 1 after_time = Time.now expect(after_time).to be > before_time end it "current time is freezed when :time_stop is granted", :time_stop do before_time = Time.now sleep 1 after_time = Time.now expect(after_time).to eq before_time end end end
åè
åç¶å¯¾å¿ãã¦ãã®ã¯ ActiveSupport::Testing::TimeHelpers
ã ãã§ãã
ï¼timecop対å¿ãä¸å¿èãããã ãã©CIè¾¼ã¿ã ã¨ä¸¡æ¹å¯¾å¿ããã®ãã¡ããé¢åã ã£ãï¼