Sha256: f88d8e682d307494cdd5b9326c4f17b82758f194b63c3a43e36229e5dc3a89b2

Contents?: true

Size: 881 Bytes

Versions: 1

Compression:

Stored size: 881 Bytes

Contents

require 'spec_helper'

describe MyClass do
  subject { klass.new(attributes) }
  let(:klass) { MyClass }
  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(subject).to respond_to(field)
    end

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

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

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

    context 'when a string attribute is a symbol' do
      let(:name) { :name }
      it do
        expect(subject).not_to be_valid
      end
    end

    context 'when an attribute is nil' do
      let(:age) { nil }
      it do
        expect(subject).not_to be_valid
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sinclair-1.1.1 spec/integration/readme/my_class_spec.rb