local_pac 0.1.13 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module LocalPac
|
3
|
+
class GitStorage
|
4
|
+
private
|
5
|
+
|
6
|
+
attr_reader :storage_path, :data, :repository, :file_creator, :null_file
|
7
|
+
|
8
|
+
public
|
9
|
+
|
10
|
+
def initialize(storage_path, compressor_engine = JavaScriptCompressor, file_creator = LocalPac::File, null_file = LocalPac::NullFile.new)
|
11
|
+
@storage_path = ::File.expand_path(storage_path)
|
12
|
+
@file_creator = file_creator
|
13
|
+
@null_file = null_file
|
14
|
+
|
15
|
+
begin
|
16
|
+
@repository = Rugged::Repository.new(storage_path)
|
17
|
+
rescue Rugged::RepositoryError
|
18
|
+
GitRepository.create(storage_path)
|
19
|
+
@repository = Rugged::Repository.new(storage_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
mutex = Mutex.new
|
23
|
+
mutex.synchronize do
|
24
|
+
@data = pac_files.reduce({}) do |memo, file|
|
25
|
+
compressor_engine.new.prepare(file)
|
26
|
+
memo[file.name.to_sym] = file
|
27
|
+
|
28
|
+
memo
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def [](key)
|
34
|
+
data.fetch(key, null_file)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def pac_files
|
40
|
+
LocalPac.ui_logger.debug "I'm using the following storage path: \"#{storage_path}\"."
|
41
|
+
files = files_in_repository.keep_if { |f| f.extension? '.pac' }
|
42
|
+
LocalPac.ui_logger.debug "Found the following files: \"#{files.join(", ")}\"."
|
43
|
+
|
44
|
+
files
|
45
|
+
end
|
46
|
+
|
47
|
+
def files_in_repository
|
48
|
+
head_commit = repository.lookup(repository.head.target)
|
49
|
+
|
50
|
+
files = []
|
51
|
+
head_commit.tree.walk_blobs(:postorder) do |root, entry|
|
52
|
+
files << file_creator.new("#{root}#{entry[:name]}", repository.lookup(entry[:oid]).content )
|
53
|
+
end
|
54
|
+
|
55
|
+
files
|
56
|
+
rescue Rugged::ReferenceError
|
57
|
+
[]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -16,8 +16,8 @@ module LocalPac
|
|
16
16
|
LocalPac.ui_logger.info "Creating pid directory: #{::File.dirname(config.pid_file)}"
|
17
17
|
Actions::CreateDirectory.new(::File.dirname(config.pid_file), force: options[:force]).run
|
18
18
|
|
19
|
-
LocalPac.ui_logger.info "Creating log
|
20
|
-
Actions::CreateDirectory.new(config.
|
19
|
+
LocalPac.ui_logger.info "Creating log directory: #{::File.dirname(config.access_log)}"
|
20
|
+
Actions::CreateDirectory.new(::File.dirname(config.access_log), force: options[:force]).run
|
21
21
|
|
22
22
|
LocalPac.ui_logger.info "Creating sass cache #{config.sass_cache}"
|
23
23
|
Actions::CreateDirectory.new(config.sass_cache, force: options[:force]).run
|
@@ -26,10 +26,13 @@ module LocalPac
|
|
26
26
|
Actions::CreateRepository.new(config.local_storage, bare: true, force: options[:force]).run
|
27
27
|
|
28
28
|
LocalPac.ui_logger.info "Creating pre-receive hook in local storage \"#{config.local_storage}\"."
|
29
|
-
Actions::CreateFile.new(:'git-hook', File.join(config.local_storage, 'hooks', 'pre-receive'), Data.new(config), force: options[:force], executable: true).run
|
29
|
+
Actions::CreateFile.new(:'git-hook', ::File.join(config.local_storage, 'hooks', 'pre-receive'), Data.new(config), force: options[:force], executable: true).run
|
30
30
|
|
31
|
-
LocalPac.ui_logger.info "Creating
|
32
|
-
Actions::
|
31
|
+
LocalPac.ui_logger.info "Creating config file at \"#{config.config_file}\"."
|
32
|
+
Actions::CreateFile.new(:'example-config', config.config_file, Data.new(config), force: options[:force], create_directories: true).run
|
33
|
+
|
34
|
+
LocalPac.ui_logger.warn "Showing the configuration of local_pac on your system."
|
35
|
+
Actions::CreateOutput.new(:'example-config', $stdout, Data.new(config)).run
|
33
36
|
end
|
34
37
|
end
|
35
38
|
end
|
@@ -3,19 +3,18 @@ module LocalPac
|
|
3
3
|
class LocalStorage
|
4
4
|
private
|
5
5
|
|
6
|
-
attr_reader :storage
|
6
|
+
attr_reader :storage
|
7
7
|
|
8
8
|
public
|
9
9
|
|
10
|
-
def initialize(storage =
|
10
|
+
def initialize(storage = GitStorage.new(LocalPac.config.local_storage))
|
11
11
|
@storage = storage
|
12
|
-
@null_file = null_file
|
13
12
|
end
|
14
13
|
|
15
14
|
def find(name)
|
16
15
|
name = name.sub(/.pac$/, '').camelize.downcase.to_sym
|
17
16
|
LocalPac.ui_logger.debug "Using the following name to find pac file: \":#{name}\"."
|
18
|
-
storage[name]
|
17
|
+
storage[name]
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
data/lib/local_pac/main.rb
CHANGED
@@ -33,8 +33,8 @@ module LocalPac
|
|
33
33
|
def routing
|
34
34
|
routing_semaphore.synchronize do
|
35
35
|
@routing ||= Rack::Builder.new do
|
36
|
-
require_relative File.expand_path('../../../app/controllers/application_controller.rb', __FILE__)
|
37
|
-
Dir.glob(File.expand_path('../../../app/controllers/*.rb', __FILE__)).each { |f| require_relative f }
|
36
|
+
require_relative ::File.expand_path('../../../app/controllers/application_controller.rb', __FILE__)
|
37
|
+
Dir.glob(::File.expand_path('../../../app/controllers/*.rb', __FILE__)).each { |f| require_relative f }
|
38
38
|
|
39
39
|
map '/' do
|
40
40
|
run LocalPac::App::FileServeController
|
data/lib/local_pac/server.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require_relative File.expand_path('../../../spec/support/git', __FILE__)
|
2
|
+
require_relative ::File.expand_path('../../../spec/support/git', __FILE__)
|
3
3
|
|
4
4
|
module LocalPac
|
5
5
|
class FileServeController
|
@@ -13,11 +13,11 @@ module LocalPac
|
|
13
13
|
include FeduxOrg::Stdlib::Filesystem
|
14
14
|
|
15
15
|
def root_directory
|
16
|
-
File.expand_path('../../../', __FILE__)
|
16
|
+
::File.expand_path('../../../', __FILE__)
|
17
17
|
end
|
18
18
|
|
19
19
|
def local_storage
|
20
|
-
File.join(working_directory, 'git_repo', '.git')
|
20
|
+
::File.join(working_directory, 'git_repo', '.git')
|
21
21
|
end
|
22
22
|
end.new
|
23
23
|
|
@@ -30,9 +30,10 @@ function FindProxyForURL(url, host) {
|
|
30
30
|
EOS
|
31
31
|
git_repo = 'git_repo'
|
32
32
|
|
33
|
-
FileUtils.rm_rf File.join(working_directory, git_repo)
|
33
|
+
FileUtils.rm_rf ::File.join(working_directory, git_repo)
|
34
34
|
git_init(git_repo)
|
35
|
-
|
35
|
+
git_set_author(git_repo)
|
36
|
+
create_file(::File.join(git_repo, 'file.pac'), valid_pac_file)
|
36
37
|
git_add(git_repo, 'file.pac')
|
37
38
|
git_commit(git_repo)
|
38
39
|
end
|
@@ -7,13 +7,13 @@ module LocalPac
|
|
7
7
|
|
8
8
|
public
|
9
9
|
|
10
|
-
def initialize(root_directory = File.expand_path('../../../files', __FILE__), creator = TemplateFile)
|
11
|
-
@root_directory = File.expand_path(root_directory)
|
10
|
+
def initialize(root_directory = ::File.expand_path('../../../files', __FILE__), creator = TemplateFile)
|
11
|
+
@root_directory = ::File.expand_path(root_directory)
|
12
12
|
@creator = creator
|
13
13
|
end
|
14
14
|
|
15
15
|
def find(name)
|
16
|
-
path = File.join(root_directory, "#{name.to_s}.erb")
|
16
|
+
path = ::File.join(root_directory, "#{name.to_s}.erb")
|
17
17
|
fail Exceptions::ErbTemplateIsUnknown, "Template \"#{name}\" could not be found!" unless ::File.exist? path
|
18
18
|
|
19
19
|
creator.new(path)
|
data/lib/local_pac/version.rb
CHANGED
data/local_pac.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
lib = ::File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'local_pac/version'
|
5
5
|
|
@@ -16,20 +16,15 @@ EOS
|
|
16
16
|
spec.license = "MIT"
|
17
17
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0")
|
19
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| ::File.basename(f) }
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_runtime_dependency 'sinatra'
|
24
23
|
spec.add_runtime_dependency 'thor'
|
25
|
-
spec.add_runtime_dependency '
|
24
|
+
spec.add_runtime_dependency 'sass'
|
25
|
+
spec.add_runtime_dependency 'haml'
|
26
26
|
spec.add_runtime_dependency 'uglifier'
|
27
27
|
spec.add_runtime_dependency 'therubyracer'
|
28
|
-
spec.add_runtime_dependency 'pac'
|
29
|
-
spec.add_runtime_dependency 'haml'
|
30
|
-
spec.add_runtime_dependency 'sass'
|
31
|
-
spec.add_runtime_dependency 'git_hook-pre_receive', '~>0.1.0'
|
32
|
-
spec.add_runtime_dependency 'fedux_org-stdlib'
|
33
28
|
spec.add_runtime_dependency 'bootstrap-sass'
|
34
29
|
spec.add_runtime_dependency 'sprockets'
|
35
30
|
spec.add_runtime_dependency 'sprockets-helpers'
|
@@ -38,4 +33,13 @@ EOS
|
|
38
33
|
spec.add_runtime_dependency 'addressable'
|
39
34
|
spec.add_runtime_dependency 'i18n'
|
40
35
|
spec.add_runtime_dependency 'rack-contrib'
|
36
|
+
spec.add_runtime_dependency 'sinatra'
|
37
|
+
spec.add_runtime_dependency 'activesupport'
|
38
|
+
spec.add_runtime_dependency 'pac'
|
39
|
+
spec.add_runtime_dependency 'git_hook-pre_receive', '~>0.1.0'
|
40
|
+
spec.add_runtime_dependency 'facter'
|
41
|
+
spec.add_runtime_dependency 'pager'
|
42
|
+
spec.add_runtime_dependency 'sys-proctable'
|
43
|
+
spec.add_runtime_dependency 'rugged'
|
44
|
+
# spec.add_runtime_dependency 'fedux_org-stdlib'
|
41
45
|
end
|
data/script/console
CHANGED
data/share/archlinux/PKGBUILD
CHANGED
@@ -8,11 +8,14 @@ url="https://github.com/dg-vrnetze/${pkgname}"
|
|
8
8
|
license=('MIT')
|
9
9
|
depends=(ruby)
|
10
10
|
install=${pkgname}.install
|
11
|
-
makedepends=(rubygems filegen)
|
11
|
+
makedepends=(rubygems filegen phantomjs)
|
12
12
|
source=(http://gems.rubyforge.org/gems/$pkgname-$pkgver.gem)
|
13
13
|
noextract=($pkgname-$pkgver.gem)
|
14
14
|
sha256sums=('cc2695dd44527e942a1d4cc3370480e1fbb44ff2eb3a050fe8714e371178ac39')
|
15
15
|
|
16
|
+
test() {
|
17
|
+
}
|
18
|
+
|
16
19
|
package() {
|
17
20
|
cd "$srcdir"
|
18
21
|
|
data/share/archlinux/config.yaml
CHANGED
@@ -10,7 +10,7 @@ describe Actions::CreateDirectory do
|
|
10
10
|
|
11
11
|
context '#run' do
|
12
12
|
it 'runs the action' do
|
13
|
-
action = Actions::CreateDirectory.new(File.join(working_directory, 'repo'))
|
13
|
+
action = Actions::CreateDirectory.new(::File.join(working_directory, 'repo'))
|
14
14
|
silence(:stderr) do
|
15
15
|
action.run
|
16
16
|
end
|
@@ -21,7 +21,7 @@ describe Actions::CreateDirectory do
|
|
21
21
|
it 'respects existing path' do
|
22
22
|
create_directory('repo')
|
23
23
|
|
24
|
-
action = Actions::CreateDirectory.new(File.join(working_directory, 'repo'))
|
24
|
+
action = Actions::CreateDirectory.new(::File.join(working_directory, 'repo'))
|
25
25
|
|
26
26
|
result = capture(:stderr) do
|
27
27
|
LocalPac.ui_logger.level = ::Logger::INFO
|
@@ -34,7 +34,7 @@ describe Actions::CreateDirectory do
|
|
34
34
|
it 'does not respect existing path if forced to' do
|
35
35
|
create_directory('repo')
|
36
36
|
|
37
|
-
action = Actions::CreateDirectory.new(File.join(working_directory, 'repo'), force: true)
|
37
|
+
action = Actions::CreateDirectory.new(::File.join(working_directory, 'repo'), force: true)
|
38
38
|
|
39
39
|
result = capture(:stderr) do
|
40
40
|
LocalPac.ui_logger.level = ::Logger::INFO
|
@@ -15,7 +15,7 @@ describe Actions::CreateFile do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
Actions::CreateFile.new(:template, File.join(working_directory, 'file'), {}, data, engine_klass, repository)
|
18
|
+
Actions::CreateFile.new(:template, ::File.join(working_directory, 'file'), {}, data, engine_klass, repository)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -34,7 +34,7 @@ describe Actions::CreateFile do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
action = Actions::CreateFile.new(:template, File.join(working_directory, 'file'), data, {}, engine_klass, repository)
|
37
|
+
action = Actions::CreateFile.new(:template, ::File.join(working_directory, 'file'), data, {}, engine_klass, repository)
|
38
38
|
silence(:stderr) do
|
39
39
|
action.run
|
40
40
|
end
|
@@ -42,6 +42,27 @@ describe Actions::CreateFile do
|
|
42
42
|
expect(path_exists?('file')).to be_true
|
43
43
|
end
|
44
44
|
|
45
|
+
it 'creates sub directories' do
|
46
|
+
repository = double('TemplateRepository')
|
47
|
+
expect(repository).to receive(:find).with(:template)
|
48
|
+
|
49
|
+
data = double('Data')
|
50
|
+
|
51
|
+
engine_klass = Class.new do
|
52
|
+
def initialize(data)
|
53
|
+
end
|
54
|
+
|
55
|
+
def compile(template, destination)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
action = Actions::CreateFile.new(:template, ::File.join(working_directory, 'data', 'file'), data, {create_directories: true}, engine_klass, repository)
|
60
|
+
silence(:stderr) do
|
61
|
+
action.run
|
62
|
+
end
|
63
|
+
|
64
|
+
expect(path_exists?('data/file')).to be_true
|
65
|
+
end
|
45
66
|
it 'respects existing path' do
|
46
67
|
repository = double('TemplateRepository')
|
47
68
|
|
@@ -10,7 +10,7 @@ describe Actions::CreateRepository do
|
|
10
10
|
|
11
11
|
context '#run' do
|
12
12
|
it 'runs the action' do
|
13
|
-
action = Actions::CreateRepository.new(File.join(working_directory, 'repo'))
|
13
|
+
action = Actions::CreateRepository.new(::File.join(working_directory, 'repo'))
|
14
14
|
silence(:stderr) do
|
15
15
|
action.run
|
16
16
|
end
|
@@ -21,7 +21,7 @@ describe Actions::CreateRepository do
|
|
21
21
|
it 'respects existing path' do
|
22
22
|
create_directory('repo')
|
23
23
|
|
24
|
-
action = Actions::CreateRepository.new(File.join(working_directory, 'repo'))
|
24
|
+
action = Actions::CreateRepository.new(::File.join(working_directory, 'repo'))
|
25
25
|
|
26
26
|
result = capture(:stderr) do
|
27
27
|
LocalPac.ui_logger.level = ::Logger::INFO
|
@@ -34,7 +34,7 @@ describe Actions::CreateRepository do
|
|
34
34
|
it 'does not respect existing path if forced to' do
|
35
35
|
create_directory('repo')
|
36
36
|
|
37
|
-
action = Actions::CreateRepository.new(File.join(working_directory, 'repo'), force: true)
|
37
|
+
action = Actions::CreateRepository.new(::File.join(working_directory, 'repo'), force: true)
|
38
38
|
|
39
39
|
result = capture(:stderr) do
|
40
40
|
LocalPac.ui_logger.level = ::Logger::INFO
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Actions::GetSystemInformation do
|
5
|
+
context '#initialize' do
|
6
|
+
it 'has no special requirements' do
|
7
|
+
expect {
|
8
|
+
Actions::GetSystemInformation.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::GetSystemInformation.new.run
|
17
|
+
end
|
18
|
+
|
19
|
+
expect(result).to include('osfamily')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Actions::PrintNewline do
|
5
|
+
context '#initialize' do
|
6
|
+
it 'has no special requirements' do
|
7
|
+
expect {
|
8
|
+
Actions::PrintNewline.new
|
9
|
+
}.not_to raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'accepts a count' do
|
13
|
+
expect {
|
14
|
+
Actions::PrintNewline.new(2)
|
15
|
+
}.not_to raise_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context '#run' do
|
20
|
+
it 'prints 1 newline' do
|
21
|
+
result = capture(:stdout) do
|
22
|
+
Actions::PrintNewline.new.run
|
23
|
+
end
|
24
|
+
|
25
|
+
expect(result).to eq("\n")
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'prints 2 newlines' do
|
29
|
+
result = capture(:stdout) do
|
30
|
+
Actions::PrintNewline.new(2).run
|
31
|
+
end
|
32
|
+
|
33
|
+
expect(result).to eq("\n\n")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|