summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAustin Ziegler <austin@zieglers.ca>2020-06-28 14:59:37 -0400
committerAustin Ziegler <austin@zieglers.ca>2020-06-28 15:10:04 -0400
commit2a9a662142d0e62337f4e8c92abca41ebf42cf59 (patch)
tree6997f89789c2cf340bf6a63c01ae7c479ab2db77 /spec
parent20ea8f2a77b544c4aa8af1522102475ceeb9fff2 (diff)
downloaddiff-lcs-2a9a662142d0e62337f4e8c92abca41ebf42cf59.tar.gz
Fix some issues with 1.4 on older Rubiesfix-ruby-1.8-support
- Required to fully support rspec. - Resolves #63.
Diffstat (limited to 'spec')
-rw-r--r--spec/ldiff_spec.rb18
-rw-r--r--spec/spec_helper.rb4
2 files changed, 15 insertions, 7 deletions
diff --git a/spec/ldiff_spec.rb b/spec/ldiff_spec.rb
index 74bb92d..2f4c235 100644
--- a/spec/ldiff_spec.rb
+++ b/spec/ldiff_spec.rb
@@ -10,10 +10,10 @@ RSpec.describe 'bin/ldiff' do
let(:output_diff_e) { read_fixture('-e') }
let(:output_diff_f) { read_fixture('-f') }
let(:output_diff_u) { read_fixture('-u') }
- let(:output_diff_chef) { read_fixture('-u', base: 'output.diff.chef') }
+ let(:output_diff_chef) { read_fixture('-u', :base => 'output.diff.chef') }
specify do
- expect(run_ldiff('-u', left: 'old-chef', right: 'new-chef')).to eq(output_diff_chef)
+ expect(run_ldiff('-u', :left => 'old-chef', :right => 'new-chef')).to eq(output_diff_chef)
end
specify do
@@ -36,8 +36,11 @@ RSpec.describe 'bin/ldiff' do
expect(run_ldiff('-u')).to eq(output_diff_u)
end
- def read_fixture(flag = nil, base: 'output.diff')
- clean_data(IO.binread("spec/fixtures/ldiff/#{base}#{flag}"), flag)
+ def read_fixture(flag = nil, options = {})
+ base = options.fetch(:base, 'output.diff')
+ name = "spec/fixtures/ldiff/#{base}#{flag}"
+ data = IO.__send__(IO.respond_to?(:binread) ? :binread : :read, name)
+ clean_data(data, flag)
end
def clean_data(data, flag)
@@ -69,11 +72,14 @@ RSpec.describe 'bin/ldiff' do
)
end
- def run_ldiff(flag = nil, left: 'aX', right: 'bXaX')
+ def run_ldiff(flag = nil, options = {})
+ left = options.fetch(:left, 'aX')
+ right = options.fetch(:right, 'bXaX')
stdout, stderr = capture_subprocess_io do
system("ruby -Ilib bin/ldiff #{flag} spec/fixtures/#{left} spec/fixtures/#{right}")
end
- expect(stderr).to be_empty
+
+ expect(stderr).to be_empty if RUBY_VERSION >= '1.9'
expect(stdout).not_to be_empty
clean_data(stdout, flag)
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 4286129..b1935d0 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -2,7 +2,9 @@
require 'rubygems'
require 'pathname'
-require 'psych'
+
+require 'psych' if RUBY_VERSION >= '1.9'
+
if ENV['COVERAGE']
require 'simplecov'