I just tried to use Rails' time helper method travel
in one of my feature specs:
scenario 'published_at allows to set a publishing date in the future' do
magazine_article.update_attribute(:published_at, Time.now + 1.day)
expect { visit magazine_article_path(magazine_article.magazine_category, magazine_article) }
.to raise_error(ActiveRecord::RecordNotFound)
travel 2.days do
visit magazine_article_path(magazine_article.magazine_category, magazine_article)
expect(page).to have_content('Super awesome article')
end
end
It's giving me this:
NoMethodError:
undefined method `travel' for #<RSpec::ExampleGroups::MagazineArticles::AsUser::Viewing:0x007f84a7a95640>
What am I missing?
http://api.rubyonrails.org/classes/ActiveSupport/Testing/TimeHelpers.html
require 'active_support/testing/time_helpers'
– Collar