local_pac 0.1.13 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/{LICENSE.txt → LICENSE.md} +0 -0
- data/README.DEVELOPER.md +7 -0
- data/README.md +138 -2
- data/Rakefile +16 -8
- data/app/controllers/application_controller.rb +5 -3
- data/app/controllers/assets_controller.rb +3 -2
- data/app/controllers/file_serve_controller.rb +3 -6
- data/app/controllers/lookup_controller.rb +9 -9
- data/app/locales/en.yml +1 -0
- data/app/views/application.haml +1 -1
- data/bin/local_pac +49 -64
- data/config.ru +24 -7
- data/features/initializer.feature +4 -4
- data/features/show_status.feature +2 -2
- data/files/config.yaml +2 -2
- data/files/example-config.erb +10 -12
- data/files/git-hook.erb +1 -0
- data/lib/local_pac.rb +22 -5
- data/lib/local_pac/actions/create_directory.rb +2 -2
- data/lib/local_pac/actions/create_file.rb +8 -2
- data/lib/local_pac/actions/create_repository.rb +6 -8
- data/lib/local_pac/actions/get_system_information.rb +78 -0
- data/lib/local_pac/actions/print_newline.rb +19 -0
- data/lib/local_pac/actions/print_title.rb +41 -0
- data/lib/local_pac/actions/reload_configuration.rb +21 -0
- data/lib/local_pac/actions/reload_local_storage.rb +22 -0
- data/lib/local_pac/actions/send_signal.rb +32 -0
- data/lib/local_pac/actions/show_config.rb +10 -0
- data/lib/local_pac/actions/show_process_information.rb +94 -0
- data/lib/local_pac/application_status.rb +34 -0
- data/lib/local_pac/cli/helper.rb +34 -0
- data/lib/local_pac/cli/reload.rb +36 -0
- data/lib/local_pac/config.rb +15 -13
- data/lib/local_pac/exceptions.rb +6 -0
- data/lib/local_pac/file.rb +32 -0
- data/lib/local_pac/git.rb +20 -6
- data/lib/local_pac/git_repository.rb +40 -28
- data/lib/local_pac/git_storage.rb +60 -0
- data/lib/local_pac/initializer.rb +8 -5
- data/lib/local_pac/local_storage.rb +3 -4
- data/lib/local_pac/main.rb +2 -2
- data/lib/local_pac/{null_pac_file.rb → null_file.rb} +5 -1
- data/lib/local_pac/server.rb +1 -1
- data/lib/local_pac/spec_helper_file_server.rb +6 -5
- data/lib/local_pac/template_file.rb +1 -1
- data/lib/local_pac/template_repository.rb +3 -3
- data/lib/local_pac/version.rb +1 -1
- data/local_pac.gemspec +13 -9
- data/script/console +1 -1
- data/share/archlinux/PKGBUILD +4 -1
- data/share/archlinux/config.yaml +1 -1
- data/spec/actions/create_directory_spec.rb +3 -3
- data/spec/actions/create_file_spec.rb +23 -2
- data/spec/actions/create_repository_spec.rb +3 -3
- data/spec/actions/get_system_information_spec.rb +22 -0
- data/spec/actions/print_new_line_spec.rb +36 -0
- data/spec/actions/print_title_spec.rb +50 -0
- data/spec/actions/reload_configuration_spec.rb +38 -0
- data/spec/actions/reload_repository_spec.rb +35 -0
- data/spec/actions/send_signal_spec.rb +58 -0
- data/spec/actions/show_config_spec.rb +22 -0
- data/spec/actions/show_process_information_spec.rb +45 -0
- data/spec/application_status_spec.rb +40 -0
- data/spec/config_spec.rb +11 -11
- data/spec/features/fetch_proxy_pac_spec.rb +11 -10
- data/spec/features/lookup_proxy_spec.rb +32 -40
- data/spec/file_spec.rb +56 -0
- data/spec/git_spec.rb +13 -7
- data/spec/git_storage_spec.rb +64 -0
- data/spec/initializer_spec.rb +7 -5
- data/spec/{null_pac_file_spec.rb → null_file_spec.rb} +6 -6
- data/spec/proxy_pac/pac_result_html_stylist_spec.rb +3 -2
- data/spec/runner_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/spec_helper_features.rb +2 -2
- data/spec/support/config.rb +5 -0
- data/spec/support/filesystem.rb +1 -1
- data/spec/support/git.rb +23 -2
- data/spec/support/helper_features.rb +23 -0
- data/spec/template_repository_spec.rb +2 -2
- metadata +113 -32
- data/lib/local_pac/git_file.rb +0 -18
- data/lib/local_pac/pac_file.rb +0 -27
- data/spec/git_repository_spec.rb +0 -60
- data/spec/pac_file_spec.rb +0 -44
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Actions::PrintTitle do
|
5
|
+
context '#initialize' do
|
6
|
+
it 'requires a title' do
|
7
|
+
expect {
|
8
|
+
Actions::PrintTitle.new('title')
|
9
|
+
}.not_to raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'accepts a title width as well' do
|
13
|
+
expect {
|
14
|
+
Actions::PrintTitle.new('title', 25)
|
15
|
+
}.not_to raise_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context '#run' do
|
20
|
+
it 'prints a title' do
|
21
|
+
action = Actions::PrintTitle.new('Hello World')
|
22
|
+
|
23
|
+
result = capture(:stdout) do
|
24
|
+
action.run
|
25
|
+
end
|
26
|
+
|
27
|
+
expect(result).to include('Hello World')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'prints a title with #' do
|
31
|
+
action = Actions::PrintTitle.new('Hello World' )
|
32
|
+
|
33
|
+
result = capture(:stdout) do
|
34
|
+
action.run
|
35
|
+
end
|
36
|
+
|
37
|
+
expect(result).to eq("###############\n# Hello World #\n###############\n\n")
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'prints a title with 25 #' do
|
41
|
+
action = Actions::PrintTitle.new('Hello World', 25 )
|
42
|
+
|
43
|
+
result = capture(:stdout) do
|
44
|
+
action.run
|
45
|
+
end
|
46
|
+
|
47
|
+
expect(result).to eq("###########################\n####### Hello World #######\n###########################\n\n")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Actions::ReloadConfiguration do
|
5
|
+
context '#initialize' do
|
6
|
+
it 'accepts a config instance' do
|
7
|
+
config = double(config)
|
8
|
+
|
9
|
+
expect {
|
10
|
+
Actions::ReloadConfiguration.new(config)
|
11
|
+
}.not_to raise_error
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context '#run' do
|
16
|
+
it 'reloads configuration from known places' do
|
17
|
+
config_file = create_file 'config.yaml', <<-EOS.strip_heredoc
|
18
|
+
---
|
19
|
+
:gem_path: '/asdf/bin/local_pac'
|
20
|
+
EOS
|
21
|
+
|
22
|
+
LocalPac.config = LocalPac::Config.new(config_file)
|
23
|
+
|
24
|
+
config_file = create_file 'config.yaml', <<-EOS.strip_heredoc
|
25
|
+
---
|
26
|
+
:gem_path: 'asdf'
|
27
|
+
EOS
|
28
|
+
|
29
|
+
config = LocalPac::Config.new(config_file)
|
30
|
+
|
31
|
+
with_environment 'HOME' => working_directory do
|
32
|
+
Actions::ReloadConfiguration.new(config).run
|
33
|
+
end
|
34
|
+
|
35
|
+
expect(LocalPac.config.gem_path).to eq('asdf')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Actions::ReloadLocalStorage do
|
5
|
+
context '#initialize' do
|
6
|
+
it 'requires a sinatra app' do
|
7
|
+
expect {
|
8
|
+
Actions::ReloadLocalStorage.new(sintra_app)
|
9
|
+
}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context '#run' do
|
14
|
+
it 'reloads local storage' do
|
15
|
+
storage = double('local_storage')
|
16
|
+
|
17
|
+
sintra_app = double('sintra_app')
|
18
|
+
expect(sintra_app).to receive(:set).with(:local_storage, storage)
|
19
|
+
|
20
|
+
Actions::ReloadLocalStorage.new(sintra_app, storage).run
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'reloads local storage for multiple apps' do
|
24
|
+
storage = double('local_storage')
|
25
|
+
|
26
|
+
sintra_app1 = double('sintra_app1')
|
27
|
+
expect(sintra_app1).to receive(:set).with(:local_storage, storage)
|
28
|
+
|
29
|
+
sintra_app2 = double('sintra_app2')
|
30
|
+
expect(sintra_app2).to receive(:set).with(:local_storage, storage)
|
31
|
+
|
32
|
+
Actions::ReloadLocalStorage.new([sintra_app1, sintra_app2], storage).run
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Actions::SendSignal do
|
5
|
+
context '#initialize' do
|
6
|
+
it 'requires a signal' do
|
7
|
+
expect {
|
8
|
+
Actions::SendSignal.new
|
9
|
+
}.to raise_error ArgumentError
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'accepts a pid_file' do
|
13
|
+
expect {
|
14
|
+
Actions::SendSignal.new(:USR1, 'asdf')
|
15
|
+
}.not_to raise_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context '#run' do
|
20
|
+
it 'sends a signal to process' do
|
21
|
+
read_pipe, write_pipe = IO.pipe
|
22
|
+
|
23
|
+
unless child_pid = Kernel.fork # Child process
|
24
|
+
read_pipe.close
|
25
|
+
|
26
|
+
trap :USR1 do
|
27
|
+
write_pipe.print "Received signal"
|
28
|
+
write_pipe.close
|
29
|
+
Kernel.exit!
|
30
|
+
end
|
31
|
+
|
32
|
+
loop { sleep 1 }
|
33
|
+
end
|
34
|
+
|
35
|
+
write_pipe.close
|
36
|
+
|
37
|
+
pid_file = create_file 'pid_file', child_pid
|
38
|
+
|
39
|
+
sleep 1
|
40
|
+
|
41
|
+
Actions::SendSignal.new(:USR1, pid_file).run
|
42
|
+
|
43
|
+
expect(read_pipe.read).to eq('Received signal')
|
44
|
+
read_pipe.close
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'logs a warning if pid file does not exist' do
|
48
|
+
LocalPac.ui_logger.level = ::Logger::WARN
|
49
|
+
|
50
|
+
result = capture(:stderr) do
|
51
|
+
Actions::SendSignal.new(:USR1, 'pid_file').run
|
52
|
+
end
|
53
|
+
|
54
|
+
expect(result).to include("does not exist. I'm not able to send daemon signal")
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Actions::ShowConfig do
|
5
|
+
context '#initialize' do
|
6
|
+
it 'has no special requirements' do
|
7
|
+
expect {
|
8
|
+
Actions::ShowConfig.new
|
9
|
+
}.not_to raise_error
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context '#run' do
|
14
|
+
it 'gathers all relevant information and prints them to stdout' do
|
15
|
+
result = capture(:stdout) do
|
16
|
+
Actions::ShowConfig.new.run
|
17
|
+
end
|
18
|
+
|
19
|
+
expect(result).to include('pid_file')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Actions::ShowProcessInformation do
|
5
|
+
context '#initialize' do
|
6
|
+
it 'requires a pid or a pid file' do
|
7
|
+
expect {
|
8
|
+
Actions::ShowProcessInformation.new($$)
|
9
|
+
}.not_to raise_error
|
10
|
+
|
11
|
+
file = create_file 'pid_file', '1'
|
12
|
+
|
13
|
+
expect {
|
14
|
+
Actions::ShowProcessInformation.new(::File.new(file))
|
15
|
+
}.not_to raise_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context '#run' do
|
20
|
+
it 'gathers information about a running process' do
|
21
|
+
result = capture(:stdout) do
|
22
|
+
Actions::ShowProcessInformation.new($$).run
|
23
|
+
end
|
24
|
+
|
25
|
+
expect(result).to include('pid')
|
26
|
+
expect(result).to include($$.to_s)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'reports an error if process cannot be found' do
|
30
|
+
result = capture(:stdout) do
|
31
|
+
Actions::ShowProcessInformation.new(99999999999).run
|
32
|
+
end
|
33
|
+
|
34
|
+
expect(result).to include('Process "99999999999" cannot be found. It is not a running process.')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'reports an error if process cannot be found and gives a hint if pid file was used.' do
|
38
|
+
result = capture(:stdout) do
|
39
|
+
Actions::ShowProcessInformation.new('/path/not/exist').run
|
40
|
+
end
|
41
|
+
|
42
|
+
expect(result).to include('Pid-file /path/not/exist cannot be found. Please choose a correct path and try again.')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe ApplicationStatus do
|
5
|
+
context '#initialize' do
|
6
|
+
it 'has no special requirements' do
|
7
|
+
expect {
|
8
|
+
ApplicationStatus.new
|
9
|
+
}.not_to raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'let you deactivate paging' do
|
13
|
+
expect {
|
14
|
+
ApplicationStatus.new(pager: false)
|
15
|
+
}.not_to raise_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context '#show' do
|
20
|
+
it 'show application status' do
|
21
|
+
config_string = <<-EOS.strip_heredoc
|
22
|
+
:pid_file: #{::File.join(working_directory, 'run', 'pid')}
|
23
|
+
EOS
|
24
|
+
|
25
|
+
config_file = create_file('config.yaml', config_string)
|
26
|
+
pid_file = create_file('run/pid', $$)
|
27
|
+
|
28
|
+
config = LocalPac::Config.new(config_file)
|
29
|
+
|
30
|
+
result = capture(:stdout) do
|
31
|
+
ApplicationStatus.new(pager: false, config: config).show
|
32
|
+
end
|
33
|
+
|
34
|
+
expect(result).to include('osfamily')
|
35
|
+
expect(result).to include('pid_file')
|
36
|
+
expect(result).to include('pid_file')
|
37
|
+
expect(result).to include('cmdline')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/config_spec.rb
CHANGED
@@ -23,7 +23,7 @@ describe LocalPac::Config do
|
|
23
23
|
|
24
24
|
it 'returns default value if no config file is available' do
|
25
25
|
config = LocalPac::Config.new(config_file)
|
26
|
-
file = File.join(ENV['HOME'], '.local', 'share', 'local_pac', 'run', 'pid')
|
26
|
+
file = ::File.join(ENV['HOME'], '.local', 'share', 'local_pac', 'run', 'pid')
|
27
27
|
|
28
28
|
expect(config.pid_file).to eq(file)
|
29
29
|
end
|
@@ -33,37 +33,37 @@ describe LocalPac::Config do
|
|
33
33
|
it 'returns value of config file' do
|
34
34
|
config_file = create_file 'config.yaml', <<-EOS.strip_heredoc
|
35
35
|
---
|
36
|
-
:local_storage: '/asdf/
|
36
|
+
:local_storage: '/asdf/storage.git'
|
37
37
|
EOS
|
38
38
|
|
39
39
|
config = LocalPac::Config.new(config_file)
|
40
|
-
expect(config.local_storage).to eq('/asdf/
|
40
|
+
expect(config.local_storage).to eq('/asdf/storage.git')
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'returns default value if no config file is available' do
|
44
44
|
config = LocalPac::Config.new(config_file)
|
45
|
-
file = File.join(ENV['HOME'], '.local', 'share', 'local_pac', 'data')
|
45
|
+
file = ::File.join(ENV['HOME'], '.local', 'share', 'local_pac', 'data', 'storage.git')
|
46
46
|
|
47
47
|
expect(config.local_storage).to eq(file)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
context '#
|
51
|
+
context '#access_log' do
|
52
52
|
it 'returns value of config file' do
|
53
53
|
config_file = create_file 'config.yaml', <<-EOS.strip_heredoc
|
54
54
|
---
|
55
|
-
:
|
55
|
+
:access_log: '/asdf/log/access.log'
|
56
56
|
EOS
|
57
57
|
|
58
58
|
config = LocalPac::Config.new(config_file)
|
59
|
-
expect(config.
|
59
|
+
expect(config.access_log).to eq('/asdf/log/access.log')
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'returns default value if no config file is available' do
|
63
63
|
config = LocalPac::Config.new(config_file)
|
64
|
-
file = File.join(ENV['HOME'], '.local', 'share', 'local_pac', 'log')
|
64
|
+
file = ::File.join(ENV['HOME'], '.local', 'share', 'local_pac', 'log', 'access.log')
|
65
65
|
|
66
|
-
expect(config.
|
66
|
+
expect(config.access_log).to eq(file)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -80,7 +80,7 @@ describe LocalPac::Config do
|
|
80
80
|
|
81
81
|
it 'returns default value if no config file is available' do
|
82
82
|
config = LocalPac::Config.new(config_file)
|
83
|
-
file = File.expand_path('../../bin/local_pac', __FILE__)
|
83
|
+
file = ::File.expand_path('../../bin/local_pac', __FILE__)
|
84
84
|
|
85
85
|
expect(config.executable).to eq(file)
|
86
86
|
end
|
@@ -107,7 +107,7 @@ describe LocalPac::Config do
|
|
107
107
|
context '#to_s' do
|
108
108
|
it 'outputs a nice config overview' do
|
109
109
|
config = LocalPac::Config.new(config_file)
|
110
|
-
expect(config.to_s).to include File.join('.local', 'share', 'local_pac', 'run', 'pid')
|
110
|
+
expect(config.to_s).to include ::File.join('.local', 'share', 'local_pac', 'run', 'pid')
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -16,7 +16,8 @@ describe 'Fetch proxy pac', :type => :feature do
|
|
16
16
|
|
17
17
|
before :each do
|
18
18
|
git_init(git_repo)
|
19
|
-
|
19
|
+
git_set_author(git_repo)
|
20
|
+
create_file(::File.join(git_repo, 'file.pac'), valid_pac_file)
|
20
21
|
git_add(git_repo, 'file.pac')
|
21
22
|
git_commit(git_repo)
|
22
23
|
end
|
@@ -26,11 +27,11 @@ describe 'Fetch proxy pac', :type => :feature do
|
|
26
27
|
include FeduxOrg::Stdlib::Filesystem
|
27
28
|
|
28
29
|
def root_directory
|
29
|
-
File.expand_path('../../../', __FILE__)
|
30
|
+
::File.expand_path('../../../', __FILE__)
|
30
31
|
end
|
31
32
|
|
32
33
|
def local_storage
|
33
|
-
File.join(working_directory, 'git_repo', '.git')
|
34
|
+
::File.join(working_directory, 'git_repo', '.git')
|
34
35
|
end
|
35
36
|
end.new
|
36
37
|
|
@@ -38,27 +39,27 @@ describe 'Fetch proxy pac', :type => :feature do
|
|
38
39
|
Capybara.app = LocalPac::App::FileServeController
|
39
40
|
end
|
40
41
|
|
41
|
-
it 'finds an existing proxy pac'
|
42
|
+
it 'finds an existing proxy pac' do
|
42
43
|
visit('/file.pac')
|
43
44
|
expect(page).to have_content('function FindProxyForURL(){return"DIRECT"}')
|
44
45
|
end
|
45
46
|
|
46
|
-
it 'exits with 404 if file does not exist'
|
47
|
+
it 'exits with 404 if file does not exist' do
|
47
48
|
visit('/does_not_exist.pac')
|
48
49
|
expect(page.status_code).to eq(404)
|
49
50
|
end
|
50
51
|
|
51
|
-
it 'compresses data for transit if requested'
|
52
|
+
it 'compresses data for transit if requested' do
|
52
53
|
def app
|
53
54
|
config = Class.new do
|
54
55
|
include FeduxOrg::Stdlib::Filesystem
|
55
56
|
|
56
57
|
def root_directory
|
57
|
-
File.expand_path('../../../', __FILE__)
|
58
|
+
::File.expand_path('../../../', __FILE__)
|
58
59
|
end
|
59
60
|
|
60
61
|
def local_storage
|
61
|
-
File.join(working_directory, 'git_repo', '.git')
|
62
|
+
::File.join(working_directory, 'git_repo', '.git')
|
62
63
|
end
|
63
64
|
end.new
|
64
65
|
|
@@ -78,11 +79,11 @@ describe 'Fetch proxy pac', :type => :feature do
|
|
78
79
|
include FeduxOrg::Stdlib::Filesystem
|
79
80
|
|
80
81
|
def root_directory
|
81
|
-
File.expand_path('../../../', __FILE__)
|
82
|
+
::File.expand_path('../../../', __FILE__)
|
82
83
|
end
|
83
84
|
|
84
85
|
def local_storage
|
85
|
-
File.join(working_directory, 'git_repo', '.git')
|
86
|
+
::File.join(working_directory, 'git_repo', '.git')
|
86
87
|
end
|
87
88
|
end.new
|
88
89
|
|
@@ -2,8 +2,8 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'spec_helper_features'
|
4
4
|
|
5
|
-
describe '
|
6
|
-
context '/v1/
|
5
|
+
describe 'Lookup proxy for url' do
|
6
|
+
context '/v1/lookup' do
|
7
7
|
let(:valid_pac_file) do <<-EOS.strip_heredoc.chomp
|
8
8
|
function FindProxyForURL(url, host) {
|
9
9
|
return "DIRECT";
|
@@ -29,7 +29,8 @@ describe 'Fetch proxy pac' do
|
|
29
29
|
|
30
30
|
before(:each) do
|
31
31
|
git_init(git_repo)
|
32
|
-
|
32
|
+
git_set_author(git_repo)
|
33
|
+
create_file(::File.join(git_repo, 'file.pac'), valid_pac_file)
|
33
34
|
git_add(git_repo, 'file.pac')
|
34
35
|
git_commit(git_repo)
|
35
36
|
end
|
@@ -39,11 +40,11 @@ describe 'Fetch proxy pac' do
|
|
39
40
|
include FeduxOrg::Stdlib::Filesystem
|
40
41
|
|
41
42
|
def root_directory
|
42
|
-
File.expand_path('../../../', __FILE__)
|
43
|
+
::File.expand_path('../../../', __FILE__)
|
43
44
|
end
|
44
45
|
|
45
46
|
def local_storage
|
46
|
-
File.join(working_directory, 'git_repo', '.git')
|
47
|
+
::File.join(working_directory, 'git_repo', '.git')
|
47
48
|
end
|
48
49
|
end.new
|
49
50
|
|
@@ -51,52 +52,43 @@ describe 'Fetch proxy pac' do
|
|
51
52
|
Capybara.app = LocalPac::App::LookupController
|
52
53
|
end
|
53
54
|
|
54
|
-
it 'looks up proxy'
|
55
|
+
it 'looks up proxy for valid url' do
|
56
|
+
search_for 'http://www.example.org', 'You asked me to look up'
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns a error message for a invalid url' do
|
55
60
|
visit('/file.pac')
|
56
61
|
within('#search') do
|
57
|
-
fill_in 'url', :with => '
|
62
|
+
fill_in 'url', :with => '§ASDF$$'
|
58
63
|
end
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
it 'shows a result output' do
|
63
|
-
rendered_view = <<-EOS.strip_heredoc
|
64
|
-
EOS
|
65
|
-
response = post('/file.pac', {:url => 'http://example.org'})
|
66
|
-
expect(last_response).to be_ok
|
67
|
-
expect(response.body).to eq('Please enter fully quallified url')
|
64
|
+
click_on('Search')
|
65
|
+
expect(page).to have_content('Invalid URL...')
|
68
66
|
end
|
69
67
|
|
70
|
-
it '
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
EOS
|
77
|
-
|
78
|
-
response = post('/file_nil.pac', {:url => 'http://example.org'})
|
68
|
+
it 'returns a error message for a invalid url on the second page' do
|
69
|
+
visit('/file.pac')
|
70
|
+
within('#search') do
|
71
|
+
fill_in 'url', :with => 'http://www.example.org'
|
72
|
+
end
|
73
|
+
click_on('Search')
|
79
74
|
|
80
|
-
|
81
|
-
|
82
|
-
|
75
|
+
within('#search') do
|
76
|
+
fill_in 'url', :with => '§ASDF$$'
|
77
|
+
end
|
83
78
|
|
84
|
-
|
85
|
-
create_file(File.join(git_repo, 'invalid.pac'), invalid_pac_file)
|
86
|
-
git_add(git_repo, 'invalid.pac')
|
87
|
-
git_commit(git_repo)
|
79
|
+
click_on('Search')
|
88
80
|
|
89
|
-
expect
|
90
|
-
response = post('/invalid.pac', {:url => 'http://example.org'})
|
91
|
-
}.to raise_error RuntimeError
|
81
|
+
expect(page).to have_content('Invalid URL...')
|
92
82
|
end
|
93
83
|
|
94
|
-
it 'returns a
|
95
|
-
|
84
|
+
it 'returns a error message for a invalid url' do
|
85
|
+
visit('/file.pac')
|
86
|
+
within('#search') do
|
87
|
+
fill_in 'url', :with => ''
|
88
|
+
end
|
89
|
+
click_on('Search')
|
90
|
+
expect(page).to have_content('Invalid URL...')
|
96
91
|
end
|
97
92
|
|
98
|
-
it 'returns a error if file does not exist' do
|
99
|
-
pending
|
100
|
-
end
|
101
93
|
end
|
102
94
|
end
|