Skip to content
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

Add Jest tests #2

Open
cody-dot-js opened this issue Dec 12, 2018 · 6 comments
Open

Add Jest tests #2

cody-dot-js opened this issue Dec 12, 2018 · 6 comments

Comments

@cody-dot-js
Copy link
Owner

Setup Jest and add test coverage for all methods.

@rarkins
Copy link

rarkins commented Dec 19, 2018

@dev-cprice how much have you battle-tested this on "real" Gemfiles? I'm adding Bundler support to Renovate and trying to decide whether to parse Gemfiles by calling out to ruby/bundler via child_process, or a Node.js parser like this.

@cody-dot-js
Copy link
Owner Author

@rarkins I've run it against gemfiles with multiple groups and 10-100 dependencies. It seems to work fine so far, but now that I have some free time I can better test it.

@cody-dot-js
Copy link
Owner Author

@rarkins unfortunately though, as it stands it only really works for non-nested groups, so something a little complicated like the rails Gemfile will not be parsed properly

@rarkins
Copy link

rarkins commented Dec 21, 2018

@dev-cprice thanks for the reply. Do you mean this type of nested group?

platforms :jruby do
  if ENV["AR_JDBC"]
    gem "activerecord-jdbcsqlite3-adapter", github: "jruby/activerecord-jdbc-adapter", branch: "master"
    group :db do
      gem "activerecord-jdbcmysql-adapter", github: "jruby/activerecord-jdbc-adapter", branch: "master"
      gem "activerecord-jdbcpostgresql-adapter", github: "jruby/activerecord-jdbc-adapter", branch: "master"
    end
  else
    gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0"
    group :db do
      gem "activerecord-jdbcmysql-adapter", ">= 1.3.0"
      gem "activerecord-jdbcpostgresql-adapter", ">= 1.3.0"
    end
  end
end

For Renovate we only care ultimately about (a) the gem lines, and (b) any group names that apply to it, and (c) sources.

A quick question for you, do you know if there are any "genuine" syntaxes for Gemfile where the gem name and version won't be on the same line? e.g. won't be like this:

gem "activerecord-jdbcpostgresql-adapter", ">= 1.3.0"

?

@rarkins
Copy link

rarkins commented Dec 21, 2018

Also, do you know if there’s any restrictions on the levels or order of nesting? Eg platforms first, then group names, etc? Or is there no practical limit if you wanted to create weird nesting for fun?

@cody-dot-js
Copy link
Owner Author

@rarkins I'm not aware of any gemfiles where the name and version aren't on the same line. According to the bundler docs,

A Gemfile is evaluated as Ruby code, in a context which makes available a number of methods used to describe the gem requirements.

So, each line is essentially a method call in Ruby.. they could be multi-line, but I haven't necessarily come across any in practice.

And yes, from your example, that's what I mean by nested groups. I guess it isn't really nested groups, but more like nested blocks. Groups within blocks, I suppose. For my use case so far, it's just been to find all gems and their versions/sources and assume that they're on the same line. I definitely plan on making it more robust to support more advanced features, like platform blocks, etc.

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

No branches or pull requests

2 participants