Skip to content

Commit

Permalink
Time Helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson Pires authored and Jackson Pires committed Nov 25, 2017
1 parent e7fc2cb commit a252689
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test_app/spec/models/customer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,13 @@
expect(customer.vip).to eq(true)
end

it 'travel_to' do
travel_to Time.zone.local(2004, 11, 23, 01, 04, 44) do
@customer = create(:customer_vip)
end

expect(@customer.created_at).to be < Time.now
end

it { expect{ create(:customer) }.to change{Customer.all.size}.by(1) }
end
3 changes: 3 additions & 0 deletions test_app/spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

RSpec.configure do |config|

# Time Helper
config.include ActiveSupport::Testing::TimeHelpers

# FactoryBot
config.include FactoryBot::Syntax::Methods

Expand Down

0 comments on commit a252689

Please sign in to comment.