Sha256: 4095c12e845ae86ed9985e217b8b6f8ae1e3f67c64e47b63a3540222e60e8634

Contents?: true

Size: 1020 Bytes

Versions: 3

Compression:

Stored size: 1020 Bytes

Contents

require_relative '../spec_helper'

feature 'refreshing pooled processes state', subject: :process do
	scenario 'by default processes are restarted on refresh' do
		instance = subject.start

		expect {
			instance.refresh
		}.to change {
			instance.pid
		}
	end

	context 'with custom command' do
		let! :test_marker do
			Pathname.new('/tmp/processtest1')
		end

		before do
			test_marker.exist? and test_marker.unlink
		end

		scenario 'refresh executes custom command' do
			instance = subject.with do |process|
				process.refresh_command "touch #{test_marker}"
			end.start

			expect(test_marker).not_to exist

			instance.refresh

			expect(test_marker).to exist
		end

		scenario 'refresh execute command in current working directory of the process' do
			instance = subject.with do |process|
				process.refresh_command "pwd > /tmp/pwd"
			end.start

			instance.refresh

			expect(Pathname.new(Pathname.new('/tmp/pwd').read.strip).realpath.to_s).to eq instance.working_directory.realpath.to_s
		end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rspec-background-process-0.1.2 spec/features/refresh_spec.rb
rspec-background-process-0.1.1 spec/features/refresh_spec.rb
rspec-background-process-0.1.0 spec/features/refresh_spec.rb