diff --git a/spec/acceptance/cli_spec.rb b/spec/acceptance/cli_spec.rb index 70d40687..705e76ca 100644 --- a/spec/acceptance/cli_spec.rb +++ b/spec/acceptance/cli_spec.rb @@ -11,7 +11,7 @@ run_simple 'appraisal' - expect_file('gemfiles/1.0.0.gemfile').to be_exists + expect(file 'gemfiles/1.0.0.gemfile').to be_exists end end @@ -29,9 +29,9 @@ run_simple 'appraisal generate' - expect_file('gemfiles/1.0.0.gemfile').to be_exists - expect_file('gemfiles/1.1.0.gemfile').to be_exists - expect_file('gemfiles/1.0.0.gemfile').to contains <<-gemfile.strip_heredoc + expect(file 'gemfiles/1.0.0.gemfile').to be_exists + expect(file 'gemfiles/1.1.0.gemfile').to be_exists + expect(content_of 'gemfiles/1.0.0.gemfile').to eq <<-gemfile.strip_heredoc # This file was generated by Appraisal source "https://rubygems.org" @@ -56,8 +56,8 @@ run_simple 'appraisal install' - expect_file('gemfiles/1.0.0.gemfile.lock').to be_exists - expect_file('gemfiles/1.1.0.gemfile.lock').to be_exists + expect(file 'gemfiles/1.0.0.gemfile.lock').to be_exists + expect(file 'gemfiles/1.1.0.gemfile.lock').to be_exists end end end diff --git a/spec/support/acceptance_test_helpers.rb b/spec/support/acceptance_test_helpers.rb index e0c58c16..75cd2825 100644 --- a/spec/support/acceptance_test_helpers.rb +++ b/spec/support/acceptance_test_helpers.rb @@ -36,16 +36,16 @@ def build_gemfile(content) write_file 'Gemfile', content.strip_heredoc end - def expect_file(filename) - expect(filename) + def content_of(path) + file(path).read end - def contains(expected) - FileContentMatcher.new(expected) + def file(path) + Pathname.new(current_dir) + path end def be_exists - FileExistsMatcher.new + be_exist end private @@ -80,30 +80,4 @@ def build_default_gemfile gem 'appraisal', :path => '#{PROJECT_ROOT}' Gemfile end - - class FileExistsMatcher - include Aruba::Api - - def matches?(expected) - @expected = expected - in_current_dir { File.exists?(@expected) } - end - - def failure_message_for_should - "file #{@expected.inspect} does not exist.\n" - end - - def failure_message_for_should_not - "file #{@expected.inspect} exists.\n" - end - end - - class FileContentMatcher < RSpec::Matchers::BuiltIn::Eq - include Aruba::Api - - def matches?(filename) - @actual = in_current_dir { File.read(filename) } - expected == actual - end - end end