我们有一些测试(规格)在日期/时间前后失败。猜测这是UTC的问题,但不知道为什么这些规格通过了上一次接触项目(约8个月前)!?!
#规范/特征/注释/创建_规范rb
feature 'Comment creation', type: :feature, js: true do
include CommentsPageHelpers
...
let!(:current_date) { Date.parse('2017-01-03') }
...
background do
Timecop.freeze(current_date)
...
end
after do
Timecop.return
end
shared_examples 'added comment' do |position:, text:|
scenario 'adds single comment' do
...
expect(page).to have_text 'January 3rd, 2017'
end
end
end
视图(角度模板)
#应用程序/视图/模板/注释.html.slim
.comment
...
{{ comment.createdAt | moment: 'MMMM Do, YYYY' }}
Comment creation for image behaves like added comment adds single comment
Failure/Error: expect(page).to have_text 'January 3rd, 2017'
expected to find text "January 3rd, 2017" in "John Snow First comment message January 2nd, 2017Remove"
Shared Example Group: "added comment" called from ./spec/features/comments/creation_spec.rb:76
# ./spec/features/comments/creation_spec.rb:42:in `block (4 levels) in <top (required)>'
# ./spec/features/comments/creation_spec.rb:39:in `block (3 levels) in <top (required)>'