You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fetcher_spec.rb 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  1. require 'dotenv/load'
  2. require_relative '../lib/auth'
  3. require_relative '../lib/fetcher'
  4. RSpec.describe Fetcher do
  5. let(:cookie) { login(ENV['VLV_USERNAME'], ENV['VLV_PASSWORD']) }
  6. let(:thread_id) { 49668 }
  7. subject { Fetcher.new(cookie: cookie) }
  8. describe '#thread' do
  9. it "fetches a thread" do
  10. VCR.use_cassette "fetch_a_thread" do
  11. result = subject.thread({ remote_id: 49668 })
  12. aggregate_failures do
  13. expect(result).to be_a(Nokogiri::HTML::Document)
  14. expect(result.at_css('.post:first-child').text)
  15. .to include('reddwarf posted this March 30th, 2020 @ 3:29:23 am')
  16. end
  17. end
  18. end
  19. end
  20. describe '#page' do
  21. it "fetches a page of threads" do
  22. VCR.use_cassette "fetch_a_page_of_threads" do
  23. result = subject.page(0)
  24. aggregate_failures do
  25. expect(result).to be_a(Nokogiri::HTML::Document)
  26. expect(result.at_css('h3').text).to eq('VLV: politics, food, and aging')
  27. expect(result.css('.even, .odd').length).to eq(110)
  28. end
  29. end
  30. end
  31. end
  32. end