Sha256: 67dc7f679cad988790f3473e200407d204f13a9e8f037eefae4b2d5a077a6423

Contents?: true

Size: 472 Bytes

Versions: 6

Compression:

Stored size: 472 Bytes

Contents

RSpec.shared_examples_for "stripable" do |attrs|
  let(:model) { described_class }
  let(:dirty_string) { ' First  Second  ' }

  it "is stripable" do
    params = {}
    attrs.each do |attr|
      params[attr] = dirty_string
    end
    obj = FactoryBot.build(model.to_s.underscore.to_sym, params)
    obj.update!(params)
    attrs.each do |attr|
      value = obj.instance_eval(attr.to_s)
      expect(value).to eq params[attr].to_s.strip.squeeze(" ")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
commons_yellowme-0.16.0 spec/support/shared-examples/stripable.rb
commons_yellowme-0.15.0 spec/support/shared-examples/stripable.rb
commons_yellowme-0.12.0 spec/support/shared-examples/stripable.rb
commons_yellowme-0.11.3 spec/support/shared-examples/stripable.rb
commons_yellowme-0.11.2 spec/support/shared-examples/stripable.rb
commons_yellowme-0.11.1 spec/support/shared-examples/stripable.rb