diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-04-28 23:20:09 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-04-28 23:20:09 +0200 |
commit | 994833085ae06afbe94d30ab183d80e0234fbe14 (patch) | |
tree | 4778d79395b0bfa7cccbec584e5755b3c5e97e66 /spec/mspec/lib/mspec | |
parent | bbb93608a385242da93bc5256a90a6376981d86f (diff) |
Update to ruby/mspec@c25d63d
Diffstat (limited to 'spec/mspec/lib/mspec')
-rw-r--r-- | spec/mspec/lib/mspec/helpers/io.rb | 32 | ||||
-rw-r--r-- | spec/mspec/lib/mspec/utils/options.rb | 2 |
2 files changed, 3 insertions, 31 deletions
diff --git a/spec/mspec/lib/mspec/helpers/io.rb b/spec/mspec/lib/mspec/helpers/io.rb index 5361fb9564..f2c799dcab 100644 --- a/spec/mspec/lib/mspec/helpers/io.rb +++ b/spec/mspec/lib/mspec/helpers/io.rb @@ -65,8 +65,6 @@ end # with any Ruby object). The file descriptor can safely be passed # to IO.new without creating a Ruby object alias to the fd. def new_fd(name, mode="w:utf-8") - mode = options_or_mode(mode) - if mode.kind_of? Hash if mode.key? :mode mode = mode[:mode] @@ -75,41 +73,15 @@ def new_fd(name, mode="w:utf-8") end end - IO.sysopen name, fmode(mode) + IO.sysopen name, mode end # Creates an IO instance for a temporary file name. The file # must be deleted. def new_io(name, mode="w:utf-8") - IO.new new_fd(name, options_or_mode(mode)), options_or_mode(mode) + IO.new new_fd(name, mode), mode end def find_unused_fd Dir.entries("/dev/fd").map(&:to_i).max + 1 end - -# This helper simplifies passing file access modes regardless of -# whether the :encoding feature is enabled. Only the access specifier -# itself will be returned if :encoding is not enabled. Otherwise, -# the full mode string will be returned (i.e. the helper is a no-op). -def fmode(mode) - if FeatureGuard.enabled? :encoding - mode - else - mode.split(':').first - end -end - -# This helper simplifies passing file access modes or options regardless of -# whether the :encoding feature is enabled. Only the access specifier itself -# will be returned if :encoding is not enabled. Otherwise, the full mode -# string or option will be returned (i.e. the helper is a no-op). -def options_or_mode(oom) - return fmode(oom) if oom.kind_of? String - - if FeatureGuard.enabled? :encoding - oom - else - fmode(oom[:mode] || "r:utf-8") - end -end diff --git a/spec/mspec/lib/mspec/utils/options.rb b/spec/mspec/lib/mspec/utils/options.rb index 9f8dd01dbf..bbe64238c5 100644 --- a/spec/mspec/lib/mspec/utils/options.rb +++ b/spec/mspec/lib/mspec/utils/options.rb @@ -384,7 +384,7 @@ class MSpecOptions def repeat on("-R", "--repeat", "NUMBER", "Repeatedly run an example NUMBER times") do |o| - MSpec.repeat = o.to_i + MSpec.repeat = Integer(o) end end |