Created
October 29, 2012 06:21
-
-
Save suzukimilanpaak/3971913 to your computer and use it in GitHub Desktop.
Spec wiht let! and Timecop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
require 'spec_helper' | |
describe Time do | |
TIMETABLE = [Time.local(2012, 10, 26, 21), Time.local(2012, 11, 2, 21)] | |
describe '#now' do | |
let!(:now) { | |
now = Time.now | |
puts "in let! #{now}" | |
now | |
} | |
shared_examples "Time is?" do | |
it "now should depend on the datetiem Timecopped" do | |
puts "in example #{Time.now}" | |
Time.now.to_s.should eq(now.to_s) | |
end | |
end | |
2.times.each do |@@i| | |
context "Test" do | |
around :each do |example| | |
puts @@i | |
Timecop.travel(TIMETABLE[@@i]) do | |
example.run | |
@@i += 1 | |
end | |
end | |
include_examples "Time is?" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment