require 'dotenv/load' require_relative '../lib/auth' require_relative '../lib/fetcher' RSpec.describe Fetcher do let(:cookie) { login(ENV['VLV_USERNAME'], ENV['VLV_PASSWORD']) } let(:thread_id) { 49668 } subject { Fetcher.new(cookie: cookie) } describe '#thread' do it "fetches a thread" do VCR.use_cassette "fetch_a_thread" do result = subject.thread({ remote_id: 49668 }) aggregate_failures do expect(result).to be_a(Nokogiri::HTML::Document) expect(result.at_css('.post:first-child').text) .to include('reddwarf posted this March 30th, 2020 @ 3:29:23 am') end end end end describe '#page' do it "fetches a page of threads" do VCR.use_cassette "fetch_a_page_of_threads" do result = subject.page(0) aggregate_failures do expect(result).to be_a(Nokogiri::HTML::Document) expect(result.at_css('h3').text).to eq('VLV: politics, food, and aging') expect(result.css('.even, .odd').length).to eq(110) end end end end end