From 93f89190fc2f95743cd8399f2e3b3e487ff347de Mon Sep 17 00:00:00 2001 From: Lovisa Svallingson Date: Tue, 2 Mar 2021 08:27:59 -0800 Subject: [PATCH] Fix NameError when calling Patch::Sdgs --- CHANGELOG.md | 6 ++++++ Gemfile.lock | 2 +- lib/patch_ruby.rb | 1 + lib/patch_ruby/version.rb | 2 +- spec/patch_ruby_spec.rb | 18 ++++++++++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 spec/patch_ruby_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index a1bb1a1..faf644c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.5.1] - 2021-03-02 + +### Fixed + +- Fixed a `NameError` that was thrown when `Patch::Sdg` was called. Specs have been added to ensure this does not happen again. + ## [1.5.0] - 2021-03-01 ### Changed diff --git a/Gemfile.lock b/Gemfile.lock index bea9f62..c74991a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - patch_ruby (1.4.0) + patch_ruby (1.5.1) json (~> 2.1, >= 2.1.0) typhoeus (~> 1.0, >= 1.0.1) diff --git a/lib/patch_ruby.rb b/lib/patch_ruby.rb index 3e5a01f..036476f 100644 --- a/lib/patch_ruby.rb +++ b/lib/patch_ruby.rb @@ -36,6 +36,7 @@ require 'patch_ruby/models/project' require 'patch_ruby/models/project_list_response' require 'patch_ruby/models/project_response' +require 'patch_ruby/models/sdg' require 'patch_ruby/models/standard' # APIs diff --git a/lib/patch_ruby/version.rb b/lib/patch_ruby/version.rb index fef78f4..a9af706 100644 --- a/lib/patch_ruby/version.rb +++ b/lib/patch_ruby/version.rb @@ -11,5 +11,5 @@ =end module Patch - VERSION = '1.5.0' + VERSION = '1.5.1' end diff --git a/spec/patch_ruby_spec.rb b/spec/patch_ruby_spec.rb new file mode 100644 index 0000000..b6b543f --- /dev/null +++ b/spec/patch_ruby_spec.rb @@ -0,0 +1,18 @@ +describe Patch do + context 'Models' do + it 'defines all models' do + constants.each do |constant| + expect { Patch.const_get(constant) }.not_to raise_error + end + end + end + + def constants + # Given a file path return the constant of that path, for example: + # 'lib/patch_ruby/models/project_response.rb' -> ProjectResponse + Dir.glob("lib/patch_ruby/models/*.rb").map do |file| + parsed_filename = file.split('/').last.split('.').first + constant = parsed_filename.split('_').map(&:capitalize).join('') + end + end +end