Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running readline specs in isolation #791

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions spec/line_editor_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
require "helper"
require "readline"

describe Thor::LineEditor, "on a system with Readline support" do
before do
@original_readline = ::Readline if defined? ::Readline
silence_warnings { ::Readline = double("Readline") }
@original_readline = ::Readline
Object.send(:remove_const, :Readline)
::Readline = double("Readline")
end

after do
silence_warnings { ::Readline = @original_readline }
Object.send(:remove_const, :Readline)
::Readline = @original_readline
end

describe ".readline" do
Expand All @@ -22,14 +25,12 @@

describe Thor::LineEditor, "on a system without Readline support" do
before do
if defined? ::Readline
@original_readline = ::Readline
Object.send(:remove_const, :Readline)
end
@original_readline = ::Readline
Object.send(:remove_const, :Readline)
end

after do
silence_warnings { ::Readline = @original_readline }
::Readline = @original_readline
end

describe ".readline" do
Expand Down