Skip to content

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

Merged
merged 6 commits into from
Jul 6, 2014
Merged

Fix smoke task #1087

merged 6 commits into from
Jul 6, 2014

Conversation

cupakromer
Copy link
Member

This is the follow up to #1059, in response to #1058. Most of the work was done with @samphippen during Ruby Nation to flush out the root cause and devise a general solution.

This implements proper setup of the test rails application. Previously the rails app used this gem's Gemfile during it's execution. Despite using Bundler.with_clean_env in the Rake file, the Gemfile still automatically loads the other rspec gems since they are explicitly listed.

Running a rails app which only requires rspec-rails per the instructions: gem 'rspec-rails', '~> 3.0.0', groups: [:development, :test], will not automatically require the other gems. The other gems will only be loaded if/when rspec-rails requires them. Since this was not properly happening with the generator, the error reported in #1054 occurs.

Unfortunately, the only way to get the proper dependencies to work when running things locally is to actually list the other rspec gems in the Gemfile. By marking them with :require => false, we ensure they will not be automatically loaded.

Now that the gems are required in two places, 1) the main gem and 2) the test app, it is possible / likely that they will drift. To prevent this, the main rspec related gems have been moved to a shared Gemfile. This is properly loaded in the main Gemfiles. Thus allowing any changes to be properly picked up.

@cupakromer
Copy link
Member Author

:( I can't get the travis failure to reproduce locally. Travis reports the sanity check script to error with:

tmp/fail_sanity_check:2:in `<main>': uninitialized constant RSpec::Support (NameError)

However, locally, I always get:

tmp/fail_sanity_check:2:in `<main>': undefined method `require_rspec_core' for RSpec::Support:Module (NoMethodError)

@cupakromer
Copy link
Member Author

Fixing this today. I think it's just a few minor changes:

  • Remove --local from the example app bundle command as this breaks with HEAD branches
  • Add back the --skip-bundle from the app generation
  • Squash the last few commits for travis issues
  • Rebase against master

When the example app is created for running cukes we need to setup a
Gemfile. It needs to share the same dependencies as this repo. To
facilitate this, move the common dependencies into a custom Gemfile.

Switch to using the proper bundler `eval_gemfile`, which properly
handles path location differences, instead of reading a file then using
raw `eval`.
Without using a custom Gemfile, the main `rspec-rails` repo bundle is
used. Due to how various Rails autoload issues work with bundler, this
caused `RSpec::Support` to be automatically loaded by the rails
generator. The root cause of this is because `rspec-support` and
`rspec-core` are explicitly included in the Gemfile.

This differs in behavior from when a normal Rail's app only specifies
`rspec-rails` in the Gemfile. Setup an explicit Gemfile to resolve the
load difference issues.
@cupakromer
Copy link
Member Author

Waiting on rspec/rspec-support#87 to fix build failures.

Part of the reason for this not being caught earlier is due to the
gemfile being setup to not require the supporting gems by default. This
creates a few specs to help manage that.
When the example app is generated it puts a Rails version that is
defined by currently installed version. This works great in most
situtations, except `master` or other edge branches. The version listed
is the current version of Rails, so they diverge.

Move how we load rails into a custom Gemfile, which we eval ourselves.
We then remove the rails version put into the gemfile and share our
custom version. Due to when `rake` and other shell processes fork, the
RAILS_VERSION environment variable is properly passed through.
@cupakromer
Copy link
Member Author

Yay! Finally green. ping @JonRowe @myronmarston @samphippen

end
end
rspec_dependencies_gemfile = File.expand_path("../Gemfile-rspec-dependencies", __FILE__)
eval_gemfile rspec_dependencies_gemfile
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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 use eval.

Copy link
Member Author

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, which eval doesn't do.

Copy link
Member

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.

@cupakromer
Copy link
Member Author

Any other concerns with this one?

@myronmarston
Copy link
Member

Any other concerns with this one?

no.

cupakromer added a commit that referenced this pull request Jul 6, 2014
@cupakromer cupakromer merged commit d10d8e5 into master Jul 6, 2014
@cupakromer cupakromer deleted the fix-smoke-task branch July 6, 2014 21:55
cupakromer added a commit that referenced this pull request Jul 6, 2014
Backport smoke task from pull request #1087
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants