Sha256: c62823ce199d4bd4b9466de345d05a6f9d5783ddfbb6192b84dde151d14b3a8e

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Validations::Format do

  let(:validator) { Class.new.extend(described_class) }

  context '#_validate_params_values' do
    let(:permitted) {
      {
        'param_a' => ['a', 'b'],
        'param_b' => /^github$/
      }
    }

    it 'fails to accept unkown value for a given parameter key' do
      actual = { 'param_a' => 'x' }
      expect {
        validator._validate_params_values(permitted, actual)
      }.to raise_error(ArgumentError)
    end

    it 'accepts known value for a given parameter key' do
      actual = { 'param_a' => 'a'}
      validator._validate_params_values(permitted, actual)
    end

    it 'fails to match regex value for a given parameter key' do
      actual = { 'param_b' => 'xgithub' }
      expect {
        validator._validate_params_values(permitted, actual)
      }.to raise_error(ArgumentError)
    end

    it 'matches regex value for a given parameter key' do
      actual = { 'param_b' => 'github'}
      validator._validate_params_values(permitted, actual)
    end
  end

end # Github::Validations::Format

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
github_api-0.5.4 spec/github/validations/format_spec.rb
github_api-0.5.3 spec/github/validations/format_spec.rb
github_api-0.5.2 spec/github/validations/format_spec.rb
github_api-0.5.1 spec/github/validations/format_spec.rb
github_api-0.5.0 spec/github/validations/format_spec.rb
github_api-0.5.0.rc1 spec/github/validations/format_spec.rb