Sha256: 1a7f2378d0f9bc1bf6922c00dccc27566d2acd922fe61325f09b2712f70d7e17

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe Redirus::Worker::RmProxy do
  let(:proxy_file) { double('proxy file') }
  let(:nginx_pid_file) { double('nginx pid file') }
  let(:config) {
    double('worker configuration',
      configs_path: 'configs_base_path',
      nginx_pid_file: 'nginx_pid_file'
    )
  }

  before do
    allow(Redirus).to receive(:config).and_return(config)
    allow(File).to receive(:open).with('nginx_pid_file').and_yield(nginx_pid_file)
    allow(nginx_pid_file).to receive(:read).and_return('123')
    allow(Process).to receive(:kill).with(:SIGHUP, 123)
    allow(File).to receive(:delete)
  end


  context 'when http redirection' do
    before { subject.perform('subdomain', :http) }

    it 'removes redirection configuration file' do
      expect(File).to have_received(:delete).with('configs_base_path/subdomain_http')
    end

    it 'restarts nginx' do
      expect(Process).to have_received(:kill).with(:SIGHUP, 123)
    end
  end

  context 'when https redirection' do
    before { subject.perform('subdomain', :https) }

    it 'removes redirection configuration file' do
      expect(File).to have_received(:delete).with('configs_base_path/subdomain_https')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
redirus-0.3.1 spec/redirus/worker/rm_proxy_spec.rb
redirus-0.2.1 spec/redirus/worker/rm_proxy_spec.rb
redirus-0.1.2 spec/redirus/worker/rm_proxy_spec.rb
redirus-0.1.1 spec/redirus/worker/rm_proxy_spec.rb
redirus-0.1.0 spec/redirus/worker/rm_proxy_spec.rb