spec/advisory_spec.rb in mrjoy-bundler-audit-0.3.2 vs spec/advisory_spec.rb in mrjoy-bundler-audit-0.3.3
- old
+ new
@@ -6,16 +6,23 @@
let(:root) { Bundler::Audit::Database::VENDORED_PATH }
let(:gem) { 'actionpack' }
let(:id) { 'OSVDB-84243' }
let(:path) { File.join(root,'gems',gem,"#{id}.yml") }
let(:an_unaffected_version) do
- Advisory.load(path).
- unaffected_versions. # Only care about unaffected versions...
- first. # And even then, any will do.
- requirements. # This is where we find versions...
- first. # Again, any will do.
- last. # We don't care about the bound, just the version number.
- to_s # And we'd like it as a string.
+ Bundler::Audit::Advisory.load(path).unaffected_versions.map { |version_rule|
+ # For all the rules, get the individual constraints out and see if we
+ # can find a suitable one...
+ version_rule.requirements.select { |(constraint, gem_version)|
+ # We only want constraints where the version number specified is
+ # one of the unaffected version. I.E. we don't want ">", "<", or if
+ # such a thing exists, "!=" constraints.
+ ['~>', '>=', '=', '<='].include?(constraint)
+ }.map { |(constraint, gem_version)|
+ # Fetch just the version component, which is a Gem::Version,
+ # and extract the string representation of the version.
+ gem_version.version
+ }
+ }.flatten.first
end
describe "load" do
let(:data) { YAML.load_file(path) }