Sha256: 11650c6ac399bc144bbd536e631e1208f2180caee346365bfec31230f38f758e

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 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 unknown value for a given parameter key' do
      actual = { 'param_a' => 'x' }
      expect {
        validator.assert_valid_values(permitted, actual)
      }.to raise_error(Github::Error::UnknownValue)
    end

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

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

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

end # Github::Validations::Format

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
github_api-0.12.3 spec/github/validations/format_spec.rb
github_api-0.12.2 spec/github/validations/format_spec.rb
github_api-0.12.1 spec/github/validations/format_spec.rb
github_api-0.12.0 spec/github/validations/format_spec.rb