This repository has been archived on 2022-08-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
wikiufc/vendor/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/private_helpers.rb

21 lines
724 B
Ruby

module Shoulda # :nodoc:
module Private # :nodoc:
# Returns the values for the entries in the args hash who's keys are listed in the wanted array.
# Will raise if there are keys in the args hash that aren't listed.
def get_options!(args, *wanted)
ret = []
opts = (args.last.is_a?(Hash) ? args.pop : {})
wanted.each {|w| ret << opts.delete(w)}
raise ArgumentError, "Unsupported options given: #{opts.keys.join(', ')}" unless opts.keys.empty?
return *ret
end
# Returns the model class constant, as determined by the test class name.
#
# class TestUser; model_class; end => User
def model_class
self.name.gsub(/Test$/, '').constantize
end
end
end