Sha256: cd4d12fe06d697bad3e5b05f97f9d6d31291fdb8047b2a57c1f989faf7f0d9ad

Contents?: true

Size: 724 Bytes

Versions: 27

Compression:

Stored size: 724 Bytes

Contents

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

Version data entries

27 entries across 27 versions & 9 rubygems

Version Path
Flamefork-shoulda-2.10.1 lib/shoulda/private_helpers.rb
Flamefork-shoulda-2.10.2 lib/shoulda/private_helpers.rb
francois-shoulda-2.10.1 lib/shoulda/private_helpers.rb
gnip-gnip-1.1.1 test/lib/shoulda/private_helpers.rb
ratnikov-shoulda-2.0.6.1 lib/shoulda/private_helpers.rb
ratnikov-shoulda-2.0.6.2 lib/shoulda/private_helpers.rb
ratnikov-shoulda-2.0.6.3 lib/shoulda/private_helpers.rb
ratnikov-shoulda-2.9.0.1 lib/shoulda/private_helpers.rb
ratnikov-shoulda-2.9.0.2 lib/shoulda/private_helpers.rb
ratnikov-shoulda-2.9.0.3 lib/shoulda/private_helpers.rb
ratnikov-shoulda-2.9.0 lib/shoulda/private_helpers.rb
rmm5t-shoulda-2.9.1 lib/shoulda/private_helpers.rb
technicalpickles-shoulda-2.10.0 lib/shoulda/private_helpers.rb
thoughtbot-shoulda-2.10.0 lib/shoulda/private_helpers.rb
thoughtbot-shoulda-2.10.1 lib/shoulda/private_helpers.rb
thoughtbot-shoulda-2.9.0 lib/shoulda/private_helpers.rb
thoughtbot-shoulda-2.9.1 lib/shoulda/private_helpers.rb
thoughtbot-shoulda-2.9.2 lib/shoulda/private_helpers.rb
shoulda-2.9.0 lib/shoulda/private_helpers.rb
shoulda-2.9.1 lib/shoulda/private_helpers.rb