require 'spec_helper'
require 'torrentz'

RSpec.describe Search do
  context 'when searching for a torrent' do
    before :all do
      VCR.use_cassette('search', record: :new_episodes) do
        @results = Torrentz::Search.new('Ubuntu 14').get
      end
    end

    it 'returns valid results for a search term' do
      expect(@results.size).to be >= 1

      @results.each do |result|
        expect(result.url).to_not be_nil
        expect(result.name).to_not be_nil
        expect(result.size).to_not be_nil
        expect(result.seeds).to_not be_nil
        expect(result.peers).to_not be_nil
        expect(result.hash).to_not be_nil
      end
    end

    it 'converts the seeds & peers to a numeric value' do
      @results.each do |result|
        expect(result.seeds).to be_a_kind_of(Integer)
        expect(result.peers).to be_a_kind_of(Integer)
      end
    end
  end
end
