Skip to content

Commit

Permalink
Do less RSpec overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
sikachu committed Sep 19, 2013
1 parent a56237d commit 7349a7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 37 deletions.
12 changes: 6 additions & 6 deletions spec/acceptance/cli_spec.rb
Expand Up @@ -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

Expand All @@ -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"
Expand All @@ -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
36 changes: 5 additions & 31 deletions spec/support/acceptance_test_helpers.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 7349a7b

Please sign in to comment.