spec/support/spec_utils.rb in messages_dictionary-1.0.0 vs spec/support/spec_utils.rb in messages_dictionary-2.0.0
- old
+ new
@@ -1,23 +1,19 @@
+# frozen_string_literal: true
+
module SpecUtils
- def capture_stderr(&block)
- original_stderr = $stderr
- $stderr = fake = StringIO.new
- begin
- yield
- ensure
- $stderr = original_stderr
- end
- fake.string
- end
+ def in_dir(file, path = '')
+ return unless block_given?
- def capture_stdout(&block)
- original_stdout = $stdout
- $stdout = fake = StringIO.new
- begin
- yield
- ensure
- $stdout = original_stdout
- end
- fake.string
+ setup_env!(path, file)
+
+ initial_path = Dir.getwd
+
+ Dir.chdir "#{RSPEC_ROOT}/dummy"
+
+ yield
+
+ Dir.chdir initial_path
+
+ clear_env!(path)
end
-end
\ No newline at end of file
+end