Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Revert "Rubinius does not work when stubbing out DateTime.now or Date…
Browse files Browse the repository at this point in the history
….today"

This reverts commit 69c18b9.

The bug has been fix in Rubinius in latest master
  • Loading branch information
dbussink committed Feb 26, 2011
1 parent 69c18b9 commit 3381631
Showing 1 changed file with 31 additions and 42 deletions.
73 changes: 31 additions & 42 deletions spec/integration/timestamps_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,18 @@
green_smoothie.save
green_smoothie.updated_at.should be_a_kind_of(DateTime)
green_smoothie.updated_on.should be_a_kind_of(Date)

# rubinius does not work with rspec class method stubs
unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
original_updated_at = green_smoothie.updated_at
original_updated_on = green_smoothie.updated_on
time_tomorrow = DateTime.now + 1
date_tomorrow = Date.today + 1
DateTime.stub!(:now).and_return { time_tomorrow }
Date.stub!(:today).and_return { date_tomorrow }
green_smoothie.name = 'Cranberry Mango'
green_smoothie.save
green_smoothie.updated_at.should_not eql(original_updated_at)
green_smoothie.updated_on.should_not eql(original_updated_on)
green_smoothie.updated_at.should eql(time_tomorrow)
green_smoothie.updated_on.should eql(date_tomorrow)
end
original_updated_at = green_smoothie.updated_at
original_updated_on = green_smoothie.updated_on
time_tomorrow = DateTime.now + 1
date_tomorrow = Date.today + 1
DateTime.stub!(:now).and_return { time_tomorrow }
Date.stub!(:today).and_return { date_tomorrow }
green_smoothie.name = 'Cranberry Mango'
green_smoothie.save
green_smoothie.updated_at.should_not eql(original_updated_at)
green_smoothie.updated_on.should_not eql(original_updated_on)
green_smoothie.updated_at.should eql(time_tomorrow)
green_smoothie.updated_on.should eql(date_tomorrow)
end

it "should only set the updated_at/on fields on dirty objects" do
Expand All @@ -71,39 +67,32 @@
green_smoothie.save
green_smoothie.updated_at.should be_a_kind_of(DateTime)
green_smoothie.updated_on.should be_a_kind_of(Date)
original_updated_at = green_smoothie.updated_at
original_updated_on = green_smoothie.updated_on
time_tomorrow = DateTime.now + 1
date_tomorrow = Date.today + 1
DateTime.stub!(:now).and_return { time_tomorrow }
Date.stub!(:today).and_return { date_tomorrow }
green_smoothie.save
green_smoothie.updated_at.should_not eql(time_tomorrow)
green_smoothie.updated_on.should_not eql(date_tomorrow)
green_smoothie.updated_at.should eql(original_updated_at)
green_smoothie.updated_on.should eql(original_updated_on)
end

describe '#touch' do
it 'should update the updated_at/on fields' do
green_smoothie = GreenSmoothie.create(:name => 'Mango')

# rubinius does not work with rspec class method stubs
unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
original_updated_at = green_smoothie.updated_at
original_updated_on = green_smoothie.updated_on
time_tomorrow = DateTime.now + 1
date_tomorrow = Date.today + 1
DateTime.stub!(:now).and_return { time_tomorrow }
Date.stub!(:today).and_return { date_tomorrow }
green_smoothie.save
green_smoothie.updated_at.should_not eql(time_tomorrow)
green_smoothie.updated_on.should_not eql(date_tomorrow)
green_smoothie.updated_at.should eql(original_updated_at)
green_smoothie.updated_on.should eql(original_updated_on)
end
end

describe '#touch' do
# rubinius does not work with rspec class method stubs
unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
it 'should update the updated_at/on fields' do
green_smoothie = GreenSmoothie.create(:name => 'Mango')

time_tomorrow = DateTime.now + 1
date_tomorrow = Date.today + 1
DateTime.stub!(:now).and_return { time_tomorrow }
Date.stub!(:today).and_return { date_tomorrow }

green_smoothie.touch
green_smoothie.touch

green_smoothie.updated_at.should eql(time_tomorrow)
green_smoothie.updated_on.should eql(date_tomorrow)
end
green_smoothie.updated_at.should eql(time_tomorrow)
green_smoothie.updated_on.should eql(date_tomorrow)
end

it 'should not update the created_at/on fields' do
Expand Down

0 comments on commit 3381631

Please sign in to comment.