Sha256: 2d7fd6bae604033f7e7ed17ecf57d19bf3bae18fb99faa02c2deff31d35ffc98

Contents?: true

Size: 669 Bytes

Versions: 37

Compression:

Stored size: 669 Bytes

Contents

module ModelHelpers

  def self.included(includee)
    includee.extend(ClassMethods)
  end
  
  module ClassMethods

    # Is a document (looked up from +symbol+) missing +key+?
    #
    # @param [Symbol] document
    #
    # @param [Symbol] missing
    def missing_key(symbol, key)
      test "should be invalid" do
        document = instance_variable_get("@#{symbol}")
        assert_equal false, document.valid?
      end

      test "should have errors" do
        document = instance_variable_get("@#{symbol}")
        document.valid?
        expected = "can't be empty"
        assert_include expected, document.errors.errors[key]
      end
    end

  end

end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
sinatra_resource-0.4.21 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.20 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.19 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.18 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.17 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.16 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.15 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.14 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.13 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.12 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.11 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.10 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.9 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.8 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.7 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.6 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.5 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.4 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.3 examples/datacatalog/test/helpers/lib/model_helpers.rb
sinatra_resource-0.4.2 examples/datacatalog/test/helpers/lib/model_helpers.rb