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.

scraper_spec.rb 681B

12345678910111213141516171819202122232425262728
  1. require 'dotenv/load'
  2. require 'spec_helper'
  3. require_relative '../db/scraper'
  4. RSpec.describe Scraper do
  5. around(:each) do |example|
  6. DB.transaction(rollback: :always, auto_savepoint: true) { example.run }
  7. end
  8. subject { described_class.new(log: true) }
  9. describe '#initialize' do
  10. it 'authenticates' do
  11. expect(subject.send(:cookie)).to_not be_nil
  12. end
  13. end
  14. describe '#scrape' do
  15. it 'creates new threads and posts' do
  16. VCR.use_cassette "create_new_threads_and_posts" do
  17. expect { subject.scrape }
  18. .to change { VLV::Thread.count }.by(109)
  19. .and change { VLV::Post.count }.by_at_least(5000)
  20. end
  21. end
  22. end
  23. end