Sha256: e9431f1b43a8a66d40449572aa492afd218769d9237797f9019ed8365a59e230

Contents?: true

Size: 924 Bytes

Versions: 20

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe MyClass do
  subject(:model) { klass.new(**attributes) }

  let(:klass) { described_class }
  let(:name)  { 'name' }
  let(:age)   { 20 }
  let(:attributes) do
    {
      name: name,
      surname: 'surname',
      age: age,
      legs: 2
    }
  end

  %i[name surname age legs].each do |field|
    it do
      expect(model).to respond_to(field)
    end

    it do
      expect(model).to respond_to("#{field}_valid?")
    end
  end

  it do
    expect(model).to respond_to(:valid?)
  end

  describe '#valid?' do
    it do
      expect(model).to be_valid
    end

    context 'when a string attribute is a symbol' do
      let(:name) { :name }

      it do
        expect(model).not_to be_valid
      end
    end

    context 'when an attribute is nil' do
      let(:age) { nil }

      it do
        expect(model).not_to be_valid
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
sinclair-2.1.1 spec/integration/readme/my_class_spec.rb
sinclair-2.1.0 spec/integration/readme/my_class_spec.rb
sinclair-2.0.1 spec/integration/readme/my_class_spec.rb
sinclair-2.0.0 spec/integration/readme/my_class_spec.rb
sinclair-1.16.3 spec/integration/readme/my_class_spec.rb
sinclair-1.16.2 spec/integration/readme/my_class_spec.rb
sinclair-1.16.1 spec/integration/readme/my_class_spec.rb
sinclair-1.16.0 spec/integration/readme/my_class_spec.rb
sinclair-1.15.0 spec/integration/readme/my_class_spec.rb
sinclair-1.14.2 spec/integration/readme/my_class_spec.rb
sinclair-1.14.1 spec/integration/readme/my_class_spec.rb
sinclair-1.14.0 spec/integration/readme/my_class_spec.rb
sinclair-1.13.0 spec/integration/readme/my_class_spec.rb
sinclair-1.12.1 spec/integration/readme/my_class_spec.rb
sinclair-1.12.0 spec/integration/readme/my_class_spec.rb
sinclair-1.11.0 spec/integration/readme/my_class_spec.rb
sinclair-1.10.0 spec/integration/readme/my_class_spec.rb
sinclair-1.9.0 spec/integration/readme/my_class_spec.rb
sinclair-1.8.0 spec/integration/readme/my_class_spec.rb
sinclair-1.7.0 spec/integration/readme/my_class_spec.rb