diff --git a/Gemfile.lock b/Gemfile.lock index 835df6a..fc5f4c2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - serrano (0.2.2) + serrano (0.2.2.1) faraday (~> 0.9.2) faraday_middleware (~> 0.10.0) multi_json (~> 1.12, >= 1.12.1) diff --git a/lib/serrano.rb b/lib/serrano.rb index ec4e11c..e49d491 100644 --- a/lib/serrano.rb +++ b/lib/serrano.rb @@ -14,6 +14,7 @@ # @param limit [Fixnum] Number of results to return. Not relavant when searching with specific dois. Default: 20. Max: 1000 # @param sample [Fixnum] Number of random results to return. when you use the sample parameter, # the limit and offset parameters are ignored. This parameter only used when works requested. +# Max: 100. # @param sort [String] Field to sort on, one of score, relevance, # updated (date of most recent change to metadata - currently the same as deposited), # deposited (time of most recent deposit), indexed (time of most recent index), or @@ -393,7 +394,7 @@ def self.registration_agency(ids:, options: nil, verbose: false) # Get a random set of DOI's # # @!macro serrano_options - # @param sample [Fixnum] Number of random DOIs to return + # @param sample [Fixnum] Number of random DOIs to return. Max: 100. Default: 10 # @param verbose [Boolean] Print request headers to stdout. Default: false # @return [Array] A list of strings, each a DOI # @note This method uses {Serrano.works} internally, but doesn't allow you to pass on diff --git a/lib/serrano/version.rb b/lib/serrano/version.rb index 9ad8bf2..f187a46 100644 --- a/lib/serrano/version.rb +++ b/lib/serrano/version.rb @@ -1,3 +1,3 @@ module Serrano - VERSION = "0.2.2" + VERSION = "0.2.2.1" end diff --git a/test/test-random_dois.rb b/test/test-random_dois.rb new file mode 100644 index 0000000..5249416 --- /dev/null +++ b/test/test-random_dois.rb @@ -0,0 +1,33 @@ +require 'simplecov' +SimpleCov.start +if ENV['CI']=='true' + require 'codecov' + SimpleCov.formatter = SimpleCov::Formatter::Codecov +end + +require "serrano" +require "serrano/error" +require 'fileutils' +require "test/unit" +require "json" + +class TestRandomDois < Test::Unit::TestCase + + def test_random_dois + res = Serrano.random_dois() + assert_equal(10, res.length) + assert_equal(Array, res.class) + assert_equal(String, res[0].class) + end + + def test_random_dois_limit + res = Serrano.random_dois(sample: 3) + assert_equal(3, res.length) + end + + def test_random_dois_errors + assert_raise Serrano::BadRequest do + puts Serrano.random_dois(sample: 101) + end + end +end