Sha256: a6dab69cc89fa2dfb9d52425f8e1f9807fe1220b4fce8c966007cfe4017aba1e

Contents?: true

Size: 922 Bytes

Versions: 21

Compression:

Stored size: 922 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

21 entries across 21 versions & 1 rubygems

Version Path
sinclair-1.6.7 spec/integration/readme/my_class_spec.rb
sinclair-1.6.6 spec/integration/readme/my_class_spec.rb
sinclair-1.6.5 spec/integration/readme/my_class_spec.rb
sinclair-1.6.4 spec/integration/readme/my_class_spec.rb
sinclair-1.6.3 spec/integration/readme/my_class_spec.rb
sinclair-1.6.2 spec/integration/readme/my_class_spec.rb
sinclair-1.6.1 spec/integration/readme/my_class_spec.rb
sinclair-1.6.0 spec/integration/readme/my_class_spec.rb
sinclair-1.5.2 spec/integration/readme/my_class_spec.rb
sinclair-1.5.1 spec/integration/readme/my_class_spec.rb
sinclair-1.5.0 spec/integration/readme/my_class_spec.rb
sinclair-1.4.2 spec/integration/readme/my_class_spec.rb
sinclair-1.4.1 spec/integration/readme/my_class_spec.rb
sinclair-1.4.0 spec/integration/readme/my_class_spec.rb
sinclair-1.3.4 spec/integration/readme/my_class_spec.rb
sinclair-1.3.3 spec/integration/readme/my_class_spec.rb
sinclair-1.3.2 spec/integration/readme/my_class_spec.rb
sinclair-1.3.1 spec/integration/readme/my_class_spec.rb
sinclair-1.3.0 spec/integration/readme/my_class_spec.rb
sinclair-1.2.1 spec/integration/readme/my_class_spec.rb