Sha256: e3c359c3bcad9dfde8b28d397ef2686f64126474a70aa0149fd9422b6d00f7fc

Contents?: true

Size: 1000 Bytes

Versions: 14

Compression:

Stored size: 1000 Bytes

Contents

require 'spec_helper'

RSpec.describe ActsAsScrubbable::Scrub do

  describe '.scrub' do

    # update_columns cannot be run on a new record
    subject{ ScrubbableModel.new }
    before(:each) { subject.save }

    it 'changes the first_name attribute when scrub is run' do
      subject.first_name = "Ted"
      allow(Faker::Name).to receive(:first_name).and_return("John")
      subject.scrub!
      expect(subject.first_name).to eq "John"
    end

    it 'calls street address on faker and updates address1' do
      subject.address1 = "123 abc"
      subject.save
      allow(Faker::Address).to receive(:street_address).and_return("1 Embarcadero")
      subject.scrub!
      expect(subject.address1).to eq "1 Embarcadero"
    end

    it "doesn't update the field if it's blank" do
      subject.address1 = nil
      subject.save
      allow(Faker::Address).to receive(:street_address).and_return("1 Embarcadero")
      subject.scrub!
      expect(subject.address1).to be_nil
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
acts_as_scrubbable-0.1.4 spec/lib/acts_as_scrubbable/scrub_spec.rb
acts_as_scrubbable-0.1.3 spec/lib/acts_as_scrubbable/scrub_spec.rb
acts_as_scrubbable-0.1.2 spec/lib/acts_as_scrubbable/scrub_spec.rb
acts_as_scrubbable-0.1.1 spec/lib/acts_as_scrubbable/scrub_spec.rb
acts_as_scrubbable-0.1.0 spec/lib/acts_as_scrubbable/scrub_spec.rb
acts_as_scrubbable-0.0.9 spec/lib/acts_as_scrubbable/scrub_spec.rb
acts_as_scrubbable-0.0.8 spec/lib/acts_as_scrubbable/scrub_spec.rb
acts_as_scrubbable-0.0.7 spec/lib/acts_as_scrubbable/scrub_spec.rb
acts_as_scrubbable-0.0.6 spec/lib/acts_as_scrubbable/scrub_spec.rb
acts_as_scrubbable-0.0.5 spec/lib/acts_as_scrubbable/scrub_spec.rb
acts_as_scrubbable-0.0.4 spec/lib/acts_as_scrubbable/scrub_spec.rb
acts_as_scrubbable-0.0.3 spec/lib/acts_as_scrubbable/scrub_spec.rb
acts_as_scrubbable-0.0.2 spec/lib/acts_as_scrubbable/scrub_spec.rb
acts_as_scrubbable-0.0.1 spec/lib/acts_as_scrubbable/scrub_spec.rb