kopflos 0.0.2
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.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +28 -0
- data/LICENSE.txt +676 -0
- data/README.rdoc +52 -0
- data/Rakefile +23 -0
- data/kopflos.gemspec +53 -0
- data/lib/kopflos.rb +63 -0
- data/lib/kopflos/cucumber.rb +16 -0
- data/lib/kopflos/rspec.rb +10 -0
- data/lib/kopflos/xvfb.rb +207 -0
- data/spec/kopflos/xvfb_spec.rb +81 -0
- data/spec/kopflos_spec.rb +112 -0
- data/spec/spec_helper.rb +12 -0
- metadata +87 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Kopflos" do
|
4
|
+
it "should default to Xvfb" do
|
5
|
+
@xvfb = mock("Xvfb")
|
6
|
+
@xvfb.should_receive(:start).and_return(true)
|
7
|
+
@xvfb.stub!(:running?).and_return(true)
|
8
|
+
@xvfb.stub!(:stop).and_return(true)
|
9
|
+
Kopflos::Xvfb.should_receive(:new).once.and_return(@xvfb)
|
10
|
+
Kopflos.stub(:disabled_by_env_variable?).and_return(false)
|
11
|
+
Kopflos.start
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should do nothing when stopping without having started" do
|
15
|
+
lambda {
|
16
|
+
Kopflos.stop
|
17
|
+
}.should_not raise_error
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should not start if disabled by environment variable" do
|
21
|
+
Kopflos.stub(:disabled_by_env_variable?).and_return(true)
|
22
|
+
Kopflos::Xvfb.should_not_receive(:new)
|
23
|
+
Kopflos.start
|
24
|
+
end
|
25
|
+
|
26
|
+
context "environment variable" do
|
27
|
+
before do
|
28
|
+
@old_env = ENV['KOPFLOS']
|
29
|
+
end
|
30
|
+
after do
|
31
|
+
ENV['KOPFLOS'] = @old_env
|
32
|
+
end
|
33
|
+
|
34
|
+
%w(disabled disable 0 false no).each do |off_switch|
|
35
|
+
it "disables kopflos if set to '#{off_switch}'" do
|
36
|
+
ENV['KOPFLOS'] = off_switch
|
37
|
+
Kopflos.should be_disabled_by_env_variable
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
%w(enable enabled 1 true yes fnord).each do |off_switch|
|
42
|
+
it "does not disable kopflos if set to '#{off_switch}'" do
|
43
|
+
ENV['KOPFLOS'] = off_switch
|
44
|
+
Kopflos.should_not be_disabled_by_env_variable
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should not start if disabled by switch file" do
|
50
|
+
Kopflos.stub(:disabled_by_switch_file?).and_return(true)
|
51
|
+
Kopflos::Xvfb.should_not_receive(:new)
|
52
|
+
Kopflos.start
|
53
|
+
end
|
54
|
+
|
55
|
+
context "switch file in working dir" do
|
56
|
+
let(:switch_file) { Kopflos.switch_file_path }
|
57
|
+
after :each do
|
58
|
+
FileUtils.rm_f switch_file
|
59
|
+
end
|
60
|
+
|
61
|
+
it "is not checked in subdirs" do
|
62
|
+
Kopflos.switch_file_path.should_not include('/')
|
63
|
+
end
|
64
|
+
|
65
|
+
context "not existing" do
|
66
|
+
it "should not disable Kopflos" do
|
67
|
+
Kopflos.should_not be_disabled_by_switch_file
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "existing" do
|
72
|
+
it "should disable kopflos" do
|
73
|
+
FileUtils.touch switch_file
|
74
|
+
Kopflos.should be_disabled_by_switch_file
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "started" do
|
80
|
+
before :each do
|
81
|
+
@server = mock("Kopflos::Server")
|
82
|
+
@server.stub!(:start).and_return(true)
|
83
|
+
@server.stub!(:stop).and_return(true)
|
84
|
+
@server.stub!(:running?).and_return(true)
|
85
|
+
Kopflos::Xvfb.stub!(:new).and_return(@server)
|
86
|
+
Kopflos.stub(:disabled_by_env_variable?).and_return(false)
|
87
|
+
Kopflos.start
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should stop server with shortcut" do
|
91
|
+
@server.should_receive(:stop)
|
92
|
+
Kopflos.stop
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should not allow to run another server simultanously" do
|
96
|
+
lambda {
|
97
|
+
Kopflos.start
|
98
|
+
}.should raise_error(Kopflos::AlreadyRunning)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should allow to reuse a server" do
|
102
|
+
lambda {
|
103
|
+
Kopflos.start :reuse => true
|
104
|
+
}.should_not raise_error(Kopflos::AlreadyRunning)
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
after :each do
|
110
|
+
Kopflos.reset!
|
111
|
+
end
|
112
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'kopflos'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.mock_framework = :rspec
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kopflos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Niklas Hofer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Starts a virtual framebuffer XServer (Xvfb) and redirects all X clients
|
42
|
+
there
|
43
|
+
email: niklas+dev@lanpartei.de
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files:
|
47
|
+
- LICENSE.txt
|
48
|
+
- README.rdoc
|
49
|
+
files:
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.rdoc
|
54
|
+
- Rakefile
|
55
|
+
- kopflos.gemspec
|
56
|
+
- lib/kopflos.rb
|
57
|
+
- lib/kopflos/cucumber.rb
|
58
|
+
- lib/kopflos/rspec.rb
|
59
|
+
- lib/kopflos/xvfb.rb
|
60
|
+
- spec/kopflos/xvfb_spec.rb
|
61
|
+
- spec/kopflos_spec.rb
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
homepage: http://github.com/niklas/kopflos
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.5.1
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: hides all your spawning X applications
|
87
|
+
test_files: []
|