Sha256: 3fcc39c4223348b5f62071a7fe2c79d1d57b12f08ba82ed9b41653736e4e8091

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper')

describe ApipieBindings::Param do

  let(:param) {ApipieBindings::Param.new({
          "allow_nil" => false,
          "description" => "<p>Architecture</p>",
          "expected_type" => "hash",
          "full_name" => "architecture",
          "name" => "architecture",
          "params" => [
              {
                  "allow_nil" => false,
                  "description" => "",
                  "expected_type" => "string",
                  "full_name" => "architecture[name]",
                  "name" => "name",
                  "required" => false,
                  "validator" => "Must be String"
              }

          ],
          "required" => true,
          "validator" => "Must be a Hash"
      }
    )}
  it "should create nested params" do
    param.params.first.name.must_equal 'name'
  end

  it "should have expected_type" do
    param.expected_type.must_equal :hash
  end

  it "should have description that strip html tags" do
    param.description.must_equal "Architecture"
  end

  it "should have required?" do
    param.required?.must_equal true
    param.params.first.required?.must_equal false
  end

  it "should have validator" do
    param.validator.must_equal "Must be a Hash"
  end

  it "should have full name, type and required visible in puts" do
    out, err = capture_io { puts param }
    out.must_equal "<Param *architecture (Hash)>\n"
  end

  it "should have full name, type and required visible in inspect" do
    param.inspect.must_equal "<Param *architecture (Hash)>"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
apipie-bindings-0.3.0 test/unit/param_test.rb
apipie-bindings-0.2.3 test/unit/param_test.rb