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 736B

123456789101112131415161718192021222324252627282930
  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. VCR.use_cassette "authentication" do
  12. expect(subject.send(:cookie)).to_not be_nil
  13. end
  14. end
  15. end
  16. describe '#scrape' do
  17. it 'creates new threads and posts' do
  18. VCR.use_cassette "create_new_threads_and_posts" do
  19. expect { subject.scrape }
  20. .to change { VLV::Thread.count }.by(109)
  21. .and change { VLV::Post.count }.by_at_least(5000)
  22. end
  23. end
  24. end
  25. end