spec/lib/percy/capybara/loaders/sprockets_loader_spec.rb in percy-capybara-3.0.0 vs spec/lib/percy/capybara/loaders/sprockets_loader_spec.rb in percy-capybara-3.0.1

- old
+ new

@@ -5,20 +5,25 @@ [200, {}, 'Hello World'] end end RSpec.describe Percy::Capybara::Loaders::SprocketsLoader do + let(:test_data_path) do + File.expand_path('../../client/test_data', __FILE__) + end + let(:rails_public_test_data_path) do + File.expand_path('../../client/rails_public_test_data', __FILE__) + end let(:loader) do described_class.new( page: page, sprockets_environment: environment, sprockets_options: sprockets_options, ) end let(:environment) do - root = File.expand_path('../../client/test_data', __FILE__) - environment = Sprockets::Environment.new(root) + environment = Sprockets::Environment.new(test_data_path) environment.append_path '.' environment end let(:digest_enabled) { false } let(:sprockets_options) do @@ -76,20 +81,21 @@ before do # Pretend like we're in a Rails app right now, all we care about is Rails.public_path. rails_double = double('Rails') # Pretend like the entire test_data directory is the public/ folder. expect(rails_double).to receive(:application).and_return(nil) - expect(rails_double).to receive(:public_path).and_return(environment.root + '/public') + expect(rails_double).to receive(:public_path).and_return(rails_public_test_data_path) expect(loader).to receive(:_rails).at_least(:once).and_return(rails_double) end it 'includes files from the public folder (non-asset-pipeline)' do resources = loader.build_resources # Weak test that more things are in this list, because it merges asset pipeline with public. expect(resources.length).to be > 5 resource_urls = resources.map(&:resource_url) expect(resource_urls).to include('/assets/images/bg-relative.png') # From asset pipeline. expect(resource_urls).to include('/percy-from-public.svg') # Public merged into root. + expect(resource_urls).to include('/symlink_to_images/test.png') # Symlink in public dir. expect(resource_urls).not_to include('/large-file-skipped.png') # Public merged into root. end context 'digest enabled' do let(:digest_enabled) { true }