Skip to content

Commit

Permalink
changed sample param in docs to max 100, added test for random_dois t…
Browse files Browse the repository at this point in the history
…o test this

fix #30
bumped dev version
  • Loading branch information
sckott committed Oct 20, 2016
1 parent b124dc1 commit cf11951
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 2 additions & 1 deletion lib/serrano.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/serrano/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Serrano
VERSION = "0.2.2"
VERSION = "0.2.2.1"
end
33 changes: 33 additions & 0 deletions test/test-random_dois.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cf11951

Please sign in to comment.