Sha256: 124e01bce3c4ca3e6d7fc3c775b3e160fc65acc44a75934251657cf358f479da

Contents?: true

Size: 968 Bytes

Versions: 1

Compression:

Stored size: 968 Bytes

Contents

# (c) 2017 Ribose Inc.
#

require "spec_helper"

RSpec.describe "db:mask", :suppress_progressbar do
  subject { Rake::Task["db:mask"] }

  let(:config_file_path) do
    File.expand_path("../dummy/config/attr_masker.rb", __dir__)
  end

  it "loads all application's models eagerly" do
    expect(Rails.application).to receive(:eager_load!)
    subject.execute
    expect(defined? NonPersistedModel).to be_truthy
  end

  it "loads configuration file if it exists", :force_config_file_reload do
    allow(File).to receive(:file?).and_call_original
    allow(File).to receive(:file?).with(config_file_path).and_return(true)
    expect { subject.execute }.to change { $CONFIG_LOADED_AT }
  end

  it "works without configuration file", :force_config_file_reload do
    allow(File).to receive(:file?).and_call_original
    allow(File).to receive(:file?).with(config_file_path).and_return(false)
    expect { subject.execute }.not_to change { $CONFIG_LOADED_AT }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
attr_masker-0.3.1 spec/unit/rake_task_spec.rb