forked from thoughtbot/appraisal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
136 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
require 'spec_helper' | ||
|
||
describe 'CLI', 'generate' do | ||
it 'generates the gemfiles' do | ||
build_gem 'dummy', '1.0.0' | ||
build_gem 'dummy', '1.1.0' | ||
build_appraisal_file <<-Appraisal.strip_heredoc | ||
appraise '1.0.0' do | ||
gem 'dummy', '1.1.0' | ||
end | ||
describe 'CLI' do | ||
context 'appraisal generate' do | ||
it 'generates the gemfiles' do | ||
build_appraisal_file <<-Appraisal | ||
appraise '1.0.0' do | ||
gem 'dummy', '1.0.0' | ||
end | ||
appraise '1.1.1' do | ||
gem 'dummy', '1.1.0' | ||
end | ||
Appraisal | ||
appraise '1.1.0' do | ||
gem 'dummy', '1.1.0' | ||
end | ||
Appraisal | ||
|
||
run_simple 'appraisal generate' | ||
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').content.to eq <<-gemfile.strip_heredoc | ||
source 'https://rubygems.org' | ||
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 | ||
# This file was generated by Appraisal | ||
gem 'dummy', '1.0.0' | ||
gemfile | ||
source "https://rubygems.org" | ||
gem "appraisal", :path=>"../../" | ||
gem "dummy", "1.0.0" | ||
gemfile | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
require 'rubygems' | ||
require 'bundler/setup' | ||
require 'aruba/api' | ||
require 'active_support/core_ext/string/strip' | ||
require './features/support/dependency_helpers' | ||
require './spec/support/acceptance_test_helpers' | ||
|
||
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze | ||
TMP_GEM_ROOT = File.join(PROJECT_ROOT, "tmp", "gems") | ||
|
||
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f } | ||
|
||
RSpec.configure do |config| | ||
config.include Aruba::Api | ||
config.include AppraisalHelpers | ||
config.include DependencyHelpers | ||
config.include AcceptanceTestHelpers, :type => :acceptance, :example_group => { | ||
:file_path => %r{spec\/acceptance\/} | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
require 'rspec/expectations/expectation_target' | ||
require 'active_support/core_ext/string/strip' | ||
require 'active_support/concern' | ||
require './features/support/dependency_helpers' | ||
|
||
module AcceptanceTestHelpers | ||
extend ActiveSupport::Concern | ||
include Aruba::Api | ||
include DependencyHelpers | ||
|
||
included do | ||
metadata[:type] = :acceptance | ||
|
||
before :all do | ||
initialize_aruba_instance_variables | ||
end | ||
|
||
before do | ||
cleanup_artifacts | ||
build_default_dummy_gems | ||
unset_bundler_env_vars | ||
ENV["GEM_PATH"] = [TMP_GEM_ROOT, ENV["GEM_PATH"]].join(":") | ||
end | ||
|
||
after do | ||
restore_env | ||
end | ||
end | ||
|
||
def build_appraisal_file(content) | ||
write_file 'Appraisals', content.strip_heredoc | ||
end | ||
|
||
def build_gemfile(content) | ||
write_file 'Gemfile', content.strip_heredoc | ||
end | ||
|
||
def expect_file(filename) | ||
expect(filename) | ||
end | ||
|
||
def contains(expected) | ||
FileContentMatcher.new(expected) | ||
end | ||
|
||
def be_exists | ||
FileExistsMatcher.new | ||
end | ||
|
||
private | ||
|
||
def cleanup_artifacts | ||
FileUtils.rm_rf(current_dir) | ||
end | ||
|
||
def initialize_aruba_instance_variables | ||
@announce_stdout = nil | ||
@announce_stderr = nil | ||
@announce_cmd = nil | ||
@announce_dir = nil | ||
@announce_env = nil | ||
@aruba_timeout_seconds = 60 | ||
@aruba_io_wait_seconds = nil | ||
end | ||
|
||
def build_default_dummy_gems | ||
FileUtils.rm_rf(TMP_GEM_ROOT) | ||
FileUtils.mkdir_p(TMP_GEM_ROOT) | ||
|
||
build_gem 'dummy', '1.0.0' | ||
build_gem 'dummy', '1.1.0' | ||
build_gemfile <<-Gemfile | ||
source 'https://rubygems.org' | ||
gem 'dummy' | ||
gem 'appraisal', :path => '../../' | ||
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 |
This file was deleted.
Oops, something went wrong.