Sha256: 1e22a182c67c3d86be47a060276d1cac12751364b09516130f71f11f1c81f205

Contents?: true

Size: 1.14 KB

Versions: 20

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'
require 'models/validators/shared_examples_for_validators'

describe Volt::FormatValidator do
  subject { described_class.new(*init_params) }

  let(:init_params) { [ model, field_name ] }
  let(:validate_params) { [ model, field_name, options ] }

  let(:model) { Volt::Model.new field: field_content }
  let(:field_name) { :field }
  let(:options) { regex_opts }

  let(:regex) { /^valid/ }
  let(:proc_regex) { /^valid/ }
  let(:test_proc) { ->(content) { proc_regex.match content } }

  let(:proc_opts) { { with: test_proc, message: proc_message } }
  let(:regex_opts) { { with: regex, message: regex_message } }

  let(:proc_message) { 'proc is invalid' }
  let(:regex_message) { 'regex is invalid' }

  let(:field_content) { valid_content }
  let(:invalid_content) { 'invalid_content' }
  let(:valid_content) { 'valid_content' }

  let(:validate) { described_class.validate(*validate_params) }

  it_behaves_like 'a format validator'

  context 'when no criteria is provided' do
    before { validate }

    it 'should have no errors' do
      expect(subject.errors).to eq({})
    end

    specify { expect(subject).to be_valid }
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
volt-0.9.1 spec/models/validators/format_validator_spec.rb
volt-0.9.1.pre5 spec/models/validators/format_validator_spec.rb
volt-0.9.1.pre4 spec/models/validators/format_validator_spec.rb
volt-0.9.1.pre3 spec/models/validators/format_validator_spec.rb
volt-0.9.1.pre2 spec/models/validators/format_validator_spec.rb
volt-0.9.1.pre1 spec/models/validators/format_validator_spec.rb
volt-0.9.0 spec/models/validators/format_validator_spec.rb
volt-0.9.0.pre7 spec/models/validators/format_validator_spec.rb
volt-0.9.0.pre6 spec/models/validators/format_validator_spec.rb
volt-0.9.0.pre5 spec/models/validators/format_validator_spec.rb
volt-0.9.0.pre4 spec/models/validators/format_validator_spec.rb
volt-0.9.0.pre3 spec/models/validators/format_validator_spec.rb
volt-0.9.0.pre2 spec/models/validators/format_validator_spec.rb
volt-0.9.0.pre1 spec/models/validators/format_validator_spec.rb
volt-0.8.27.beta9 spec/models/validators/format_validator_spec.rb
volt-0.8.27.beta8 spec/models/validators/format_validator_spec.rb
volt-0.8.27.beta7 spec/models/validators/format_validator_spec.rb
volt-0.8.27.beta6 spec/models/validators/format_validator_spec.rb
volt-0.8.27.beta5 spec/models/validators/format_validator_spec.rb
volt-0.8.27.beta4 spec/models/validators/format_validator_spec.rb