Sha256: 40ce1d6d135784e38e4e4fc990ab5c28b75d0d742daa3379742de7d3dca530cd

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

require 'test_helper'

class BestBetsSearcherTest < ActiveSupport::TestCase

  setup do
    @best_bets = QuickSearch::BestBetsSearcher.new(HTTPClient.new, 'printing', 1)
    @best_bets_journal = QuickSearch::BestBetsSearcher.new(HTTPClient.new, 'journal of cell science', 1)
    @best_bets_database = QuickSearch::BestBetsSearcher.new(HTTPClient.new, 'encyclopedia of life sciences', 1)
  end

  test "should have http client, query, and per_page" do
    assert @best_bets.http.is_a? HTTPClient
    assert @best_bets.q == 'printing'
    assert_equal 1, @best_bets.per_page
  end

  vcr_test "should have parsed results", 'searches', cassette: 'best_bets_printing' do
    @best_bets.search
    parsed_results = @best_bets.results
    assert parsed_results.first.title.include?('Print')
  end

  vcr_test "should have journal result", 'searches', cassette: 'best_bets_journal' do
    @best_bets_journal.search
    parsed_results = @best_bets_journal.results
    assert parsed_results.first.title.include?('Journal of cell science')
  end

  vcr_test "should have database result", 'searches', cassette: 'best_bets_database' do
    @best_bets_database.search
    parsed_results = @best_bets_database.results
    assert parsed_results.first.title.include?('Encyclopedia of life sciences')
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quick_search-core-0.0.1 test/searcher/best_bets_test.rb
quick_search-core-0.0.1.test test/searcher/best_bets_test.rb