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