-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix smoke task #1087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix smoke task #1087
Changes from all commits
30220b0
0cbad4a
b8674a5
c37a5a7
ce4ceaf
eb4da76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version_file = File.expand_path("../.rails-version", __FILE__) | ||
case version = ENV['RAILS_VERSION'] || (File.exist?(version_file) && File.read(version_file).chomp) | ||
when /master/ | ||
gem "rails", :git => "git://github.com/rails/rails.git" | ||
gem "arel", :git => "git://github.com/rails/arel.git" | ||
gem "journey", :git => "git://github.com/rails/journey.git" | ||
gem "activerecord-deprecated_finders", :git => "git://github.com/rails/activerecord-deprecated_finders.git" | ||
gem "rails-observers", :git => "git://github.com/rails/rails-observers" | ||
gem 'sass-rails', :git => "git://github.com/rails/sass-rails.git" | ||
gem 'coffee-rails', :git => "git://github.com/rails/coffee-rails.git" | ||
when /stable$/ | ||
gem "rails", :git => "git://github.com/rails/rails.git", :branch => version | ||
when nil, false, "" | ||
if RUBY_VERSION < '1.9.3' | ||
# Rails 4+ requires 1.9.3+, so on earlier versions default to the last 3.x release. | ||
gem "rails", "~> 3.2.17" | ||
else | ||
gem "rails", "~> 4.0.4" | ||
end | ||
else | ||
gem "rails", version | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
branch = File.read(File.expand_path("../maintenance-branch", __FILE__)).chomp | ||
%w[rspec rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib| | ||
library_path = File.expand_path("../../#{lib}", __FILE__) | ||
if File.exist?(library_path) && !ENV['USE_GIT_REPOS'] | ||
gem lib, :path => library_path, :require => false | ||
else | ||
gem lib, :git => "git://github.com/rspec/#{lib}.git", :branch => branch, :require => false | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe "Verify required rspec dependencies" do | ||
|
||
tmp_root = RSpec::Core::RubyProject.root.join("tmp") | ||
|
||
before{ FileUtils.mkdir_p tmp_root } | ||
|
||
it "fails when libraries are not required" do | ||
script = tmp_root.join("fail_sanity_check") | ||
File.open(script, "w") do |f| | ||
f.write <<-EOF.gsub(/^\s+\|/, '') | ||
|#!/usr/bin/env ruby | ||
|RSpec::Support.require_rspec_core "project_initializer" | ||
EOF | ||
end | ||
FileUtils.chmod 0777, script | ||
|
||
Bundler.with_clean_env do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bundler also has There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly, I'm not that sure. Based on the code it looks like the def with_clean_env
with_original_env do
ENV['MANPATH'] = ENV['BUNDLE_ORIG_MANPATH']
ENV.delete_if { |k,_| k[0,7] == 'BUNDLE_' }
if ENV.has_key? 'RUBYOPT'
ENV['RUBYOPT'] = ENV['RUBYOPT'].sub '-rbundler/setup', ''
ENV['RUBYOPT'] = ENV['RUBYOPT'].sub "-I#{File.expand_path('..', __FILE__)}", ''
end
yield
end
end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to know! |
||
expect(`bundle exec #{script} 2>&1`). | ||
to match(/uninitialized constant RSpec::Support \(NameError\)/). | ||
or match(/undefined method `require_rspec_core' for RSpec::Support:Module/) | ||
|
||
expect($?.exitstatus).to eq(1) | ||
end | ||
end | ||
|
||
it "passes when libraries are required" do | ||
script = tmp_root.join("pass_sanity_check") | ||
File.open(script, "w") do |f| | ||
f.write <<-EOF.gsub(/^\s+\|/, '') | ||
|#!/usr/bin/env ruby | ||
|require 'rspec/core' | ||
|require 'rspec/support' | ||
|RSpec::Support.require_rspec_core "project_initializer" | ||
EOF | ||
end | ||
FileUtils.chmod 0777, script | ||
|
||
Bundler.with_clean_env do | ||
expect(`bundle exec #{script} 2>&1`).to be_empty | ||
expect($?.exitstatus).to eq(0) | ||
end | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
rspec_rails_repo_path = File.expand_path("../../", __FILE__) | ||
rspec_dependencies_gemfile = File.join(rspec_rails_repo_path, 'Gemfile-rspec-dependencies') | ||
rails_dependencies_gemfile = File.join(rspec_rails_repo_path, 'Gemfile-rails-dependencies') | ||
in_root do | ||
# Remove the existing rails version so we can properly use master or other | ||
# edge branches | ||
gsub_file 'Gemfile', /^.*\bgem 'rails.*$/, '' | ||
|
||
# Use our version of RSpec and Rails | ||
append_to_file 'Gemfile', <<-EOT.gsub(/^ +\|/, '') | ||
|gem 'rspec-rails', | ||
| :path => '#{rspec_rails_repo_path}', | ||
| :groups => [:development, :test] | ||
|eval_gemfile '#{rspec_dependencies_gemfile}' | ||
|eval_gemfile '#{rails_dependencies_gemfile}' | ||
EOT | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is
eval_gemfile
defined?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's defined by Bundler I believe: http://rubydoc.info/github/carlhuda/bundler/master/Bundler/Dsl#eval_gemfile-instance_method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, never knew about that. Elsewhere we've used
eval
:https://github.com/rspec/rspec-core/blob/b648cdbd7811b20aa6da0da8bbed8cffdcd1816a/Gemfile#L33
It's not clear to me from that context if the bundler team considers
eval_gemfile
to be a public API. @xaviershay, do you know? If they don't consider it public I'd prefer we useeval
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nice thing about
eval_gemfile
is it takes care of handling relative paths based on the evaluated Gemfile location, whicheval
doesn't do.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in the
DSL
class, pretty sure all though methods are public.