Last Post By:lastposter2 on Fri Apr 10 2020 01:23 am
HTML
end
it 'parses threads' do
expect(subject.threads(html)).to eq([
{remote_id: '12345', title: 'Sticky: Thread title 1', creator: 'creator1', is_sticky: true},
{remote_id: '123456', title: 'Thread title 2', creator: 'creator2', is_sticky: false},
])
end
end
describe '#posts' do
let(:html) do
Nokogiri::HTML(<<~HTML)
User1
posted this October 26th, 2021 @ 12:34:56 am
This is the body of the first post
User2
posted this October 27th, 2021 @ 12:34:56 am
This is the body of the second post
HTML
end
it 'parses posts' do
expect(subject.posts({ id: 666 }, html)).to match_array([
{
remote_id: 69,
creator: 'User1',
thread_id: 666,
created_at: Time.new(2021, 10, 26, 0, 34, 56),
body: 'This is the body of the first post'
},
{
remote_id: 420,
creator: 'User2',
thread_id: 666,
created_at: Time.new(2021, 10, 27, 0, 34, 56),
body: 'This is the body of the second post'
}
])
end
end
describe '#thread_created_at' do
let(:html) do
Nokogiri::HTML(<<~HTML)
User1
posted this October 27th, 2021 @ 12:34:56 am
HTML
end
it 'parses the timestamp of the first post' do
expect(subject.thread_created_at(html))
.to eq(Time.new(2021, 10, 27, 00, 34, 56))
end
end
end