Sha256: 5d196a13bae40cb2fce8b358eb2ac3ee87e89b32ee4c7b99d0bec94b8b5477b1

Contents?: true

Size: 794 Bytes

Versions: 80

Compression:

Stored size: 794 Bytes

Contents

module ThoughtBot # :nodoc:
  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
end

Version data entries

80 entries across 80 versions & 19 rubygems

Version Path
akitaonrails-resource_controller-0.5.2 test/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb
akitaonrails-resource_controller-0.5.3 test/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb
emschwar-shoulda-2.0.6.1 lib/shoulda/private_helpers.rb
francois-shoulda-2.0.5.1 lib/shoulda/private_helpers.rb
francois-shoulda-2.0.5.2 lib/shoulda/private_helpers.rb
francois-shoulda-2.0.5.4 lib/shoulda/private_helpers.rb
giraffesoft-resource_controller-0.4.10 test/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb
giraffesoft-resource_controller-0.4.12 test/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb
giraffesoft-resource_controller-0.4.9 test/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb
giraffesoft-resource_controller-0.5.2 test/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb
giraffesoft-resource_controller-0.5.3 test/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb
gsterndale-warrant-0.2.0 test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.6/lib/shoulda/private_helpers.rb
gsterndale-warrant-0.3.0 test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.6/lib/shoulda/private_helpers.rb
hashrocket-clearance-0.4.0 test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/private_helpers.rb
hashrocket-clearance-0.4.1 test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/private_helpers.rb
hashrocket-clearance-0.4.2 test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/private_helpers.rb
hashrocket-clearance-0.4.3 test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/private_helpers.rb
jcnetdev-shoulda-4.2 lib/shoulda/private_helpers.rb
korin-resource_controller-0.5.3 test/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb
mattknox-goaloc-0.3.0 lib/goaloc/generators/resources/shoulda/lib/shoulda/private_helpers.rb