0

TL;TR

We have two projects (minitest project, and a page objects project). The Minitest project uses the page object project. When Jenkins runs the tests, we use a remote git path to the page objects project. When we run it locally we change the gem file in the minitest project to use a local path\or local git repo. This results in us needing to continuously change the gem file. We don't wan't to have to do this. How can we set this up so that we don't need to keep changing the gem file?

The long version

I have two Ruby projects, which are tightly coupled. Both projects are used to support testing with Capybara. One project contains Minitest tests. The other project contains page objects. The minitest project uses the page object project. The page object project is published as a gem so that other teams can use it. Quite often we need to edit both projects at once.

I am using Bundler to manage the gems. These projects used to be in two different git repos.

The tests run in Jenkins, and when we work on them we run them locally. When the tests run in Jenkins the minitest project can reference the page objects project either as a published gem or as a remote git repo.

The problem we had with this is that we kept needing to change the gem file of the minitest project. We would change it from pointing to a remote git repo, to a checked out (local) path. Or we would point to a local git repo. In this case we would still need to update the minitest project's gem file with the local branch name. We needed to edit the gem file with either approach, then we had to remember to change this back before checking in and merging.

We then moved both projects into a single repo. Now the gem file in the minitest project only uses the relative path e.g. path => .... This means that we don't need to constantly update the gem file in the minitest project. However, now when we run bundle install or bundle update, only the gem file from the minitest project is used (at least this is what I assume is happening).

How do I use a different gem path\git repo on my dev machine to what is used in Jenkins, without continuously changing the gem file?

I would like to know what approach should I be using in this case? Can avoid making changes to the minitest project's gem file?

Daryn
  • 3,394
  • 5
  • 30
  • 41

1 Answers1

0

Consider using bundler's groups (in Gemfile):

group :project1 do
  gem 'rspec'
end

group :project2 do
  gem 'minitest'
end

Then specify which group to use in application.rb, for example

Bundler.require(:project1) # or :project2 depending on the project

More info here: http://bundler.io/groups.html

Piotr Kruczek
  • 2,384
  • 11
  • 18
  • I don't really understand this. We are not using 'rspec' at all. We are also not using rails, so at this stage we don't have an application.rb. The minitest project uses the page objects project. I will update the question to reflect this. Which gem file are you suggesting we change, the minitest project or the page object project? Are you suggesting that both projects share one gem file? – Daryn May 07 '15 at 10:59
  • If your framework uses `Gemfile` the above should work. Try searching your entire project for a phrase `Bundler.require`. It should be placed in some kind of configuration file. That's the way `bundler` recognises e.g. the environment you're in. Using groups you can establish which project should use which gems. – Piotr Kruczek May 07 '15 at 11:07
  • I don't have `Bundler.require` anywhere in the projects. Even if I did have that, I don't see how this solves the problem. – Daryn May 07 '15 at 12:45
  • I will edit the question again to try to clarify the problem. – Daryn May 07 '15 at 12:51
  • I could add `Bundler.require` but this does not help. How do I use a different gem path\git repo on my dev machine to what is used in Jenkins, without continuously changing the gem file? – Daryn May 07 '15 at 13:02