From c9e6d1807b9c54c4bf9e2eddafc88e24b3e132e7 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Fri, 10 Apr 2015 10:16:30 +0000 Subject: [PATCH] Fix X display handling in rspec test suite * Hide any available X display from test suite context; * Ensure the manager never connect or block. --- spec/spec_helper.rb | 5 +++++ spec/uh/wm/cli_spec.rb | 3 +-- spec/uh/wm/manager_spec.rb | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9ff4219..59a3eee 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,4 +10,9 @@ RSpec.configure do |config| end config.disable_monkey_patching! + + config.before :all do + # Ensure current X display is not available from rspec test suite. + ENV.delete 'DISPLAY' + end end diff --git a/spec/uh/wm/cli_spec.rb b/spec/uh/wm/cli_spec.rb index 3f2f3f0..86b4d2e 100644 --- a/spec/uh/wm/cli_spec.rb +++ b/spec/uh/wm/cli_spec.rb @@ -15,8 +15,7 @@ module Uh described_class.run arguments, stdout: stdout, stderr: stderr end - # FIXME: remove this hack we currently need to prevent the Runner from - # blocking. + # Prevent Runner from connecting a Manager and blocking. before { allow(Runner).to receive :run } it 'builds a new CLI with given arguments' do diff --git a/spec/uh/wm/manager_spec.rb b/spec/uh/wm/manager_spec.rb index 8c08c42..bd3ae71 100644 --- a/spec/uh/wm/manager_spec.rb +++ b/spec/uh/wm/manager_spec.rb @@ -14,6 +14,9 @@ module Uh describe '#connect' do let(:block) { proc { } } + # Prevent Manager to open a real display. + before { allow(display).to receive :open } + it 'opens the display' do expect(manager.display).to receive :open manager.connect