Page MenuHomePhabricator

Document RSpec workflow on MediaWiki-Vagrant
Closed, ResolvedPublic

Description

Vagrant patches must pass RSpec tests to pass CI, but there does not seem to be any documentation on how to run those tests locally, and it is not obvious (at least I couldn't figure it out during ten minutes of trying). Would be nice to have an mw.org page or paragraph about it.

Event Timeline

Tgr raised the priority of this task from to Needs Triage.
Tgr updated the task description. (Show Details)
Tgr subscribed.

@dduvall would you mind adding a testing section in MWV README.md file? A step by step tutorial for dummies about how to run rspec tests.

I guess it is all about:

bundle install
bundle exec rspec

Didn't work for me:

vagrant@mediawiki-vagrant:/vagrant$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "bundler":
  In Gemfile:
    vagrant (>= 0) ruby depends on
      bundler (< 1.8.0, >= 1.5.2) ruby

  Current Bundler version:
    bundler (1.9.4)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (< 1.8.0, >= 1.5.2) ruby', which is required by gem 'vagrant (>= 0) ruby', in any of the sources.

I could install rspec by hand (sudo gem install rspec) but presumably other libraries were still missing:

vagrant@mediawiki-vagrant:/vagrant/spec$ rspec  mediawiki_vagrant/setting_spec.rb 
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- spec_helper (LoadError)
	from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
	from /vagrant/spec/mediawiki_vagrant/setting_spec.rb:1:in `<top (required)>'
	from /var/lib/gems/1.9.1/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `load'
	from /var/lib/gems/1.9.1/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `block in load_spec_files'
	from /var/lib/gems/1.9.1/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `each'
	from /var/lib/gems/1.9.1/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `load_spec_files'
	from /var/lib/gems/1.9.1/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:97:in `setup'
	from /var/lib/gems/1.9.1/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:85:in `run'
	from /var/lib/gems/1.9.1/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:70:in `run'
	from /var/lib/gems/1.9.1/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:38:in `invoke'
	from /var/lib/gems/1.9.1/gems/rspec-core-3.2.3/exe/rspec:4:in `<top (required)>'
	from /usr/local/bin/rspec:23:in `load'
	from /usr/local/bin/rspec:23:in `<main>'

Ah yeah. the Vagrant gem requires bundler 1.7 for now so there is an egg and chicken trouble here.

There was an issue at https://github.com/mitchellh/vagrant/issues/5581 which have some workaround. Apparently you can install a gem locally with:

gem install --user-install bundler -v '~> 1.7.0'

Then use ~/.gem/bin/bundle . There might be something more robust though.

I proposed patch to bump the version requirement at https://github.com/mitchellh/vagrant/pull/5363 but it hasn't been reviewed/tested/merged yet.

A slightly easier way would be to invoke the specific gem version using _<version>_ following the bin name.

/Users/.../vagrant $ gem install bundler -v '~> 1.7.0'
Fetching: bundler-1.7.14.gem (100%)
Successfully installed bundler-1.7.14
1 gem installed
/Users/.../vagrant $ bundle _1.7.14_ -v
Bundler version 1.7.14
/Users/.../vagrant $

I'll add a section to README.md.

Seems @dduvall is going to take care of the documentation.

hashar triaged this task as Medium priority.May 5 2015, 7:40 PM
zeljkofilipin lowered the priority of this task from Medium to Low.May 20 2017, 3:40 PM

Change 360857 had a related patch set uploaded (by Zfilipin; owner: Zfilipin):
[mediawiki/vagrant@master] Update testing documentation

https://gerrit.wikimedia.org/r/360857

I have updated the docs in the above patch. It is no longer needed to use bundler < 1.8 I have tested it with the latest release 1.15.1.

Change 360857 merged by jenkins-bot:
[mediawiki/vagrant@master] Update testing documentation

https://gerrit.wikimedia.org/r/360857