Module: ThoughtBot::Shoulda::Private
- Included in:
- Macros
- Defined in:
- lib/shoulda/private_helpers.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#get_options!(args, *wanted) ⇒ Object
Returns the values for the entries in the args hash who’s keys are listed in the wanted array.
-
#model_class ⇒ Object
Returns the model class constant, as determined by the test class name.
Instance Method Details
#get_options!(args, *wanted) ⇒ Object
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.
6 7 8 9 10 11 12 |
# File 'lib/shoulda/private_helpers.rb', line 6 def (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 |
#model_class ⇒ Object
Returns the model class constant, as determined by the test class name.
class TestUser; model_class; end => User
17 18 19 |
# File 'lib/shoulda/private_helpers.rb', line 17 def model_class self.name.gsub(/Test$/, '').constantize end |