diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index c060c93..cd5b98d 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -12,15 +12,13 @@ jobs: fail-fast: false matrix: ruby: - - '3.0' - - '2.7' - - '2.6' - - '2.5' + - '3.3' + - '3.2' steps: - uses: actions/checkout@v2 - name: Set up Ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: "${{matrix.ruby}}" - name: Install dependencies and run RSpec @@ -35,15 +33,13 @@ jobs: fail-fast: false matrix: ruby: - - '3.0' - - '2.7' - - '2.6' - - '2.5' + - '3.3' + - '3.2' steps: - uses: actions/checkout@v2 - name: Set up Ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: "${{matrix.ruby}}" - name: Install dependencies and run rubocop" diff --git a/.gitignore b/.gitignore index b04a8c8..a4be4c3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ /pkg/ /spec/reports/ /tmp/ +Gemfile.lock # rspec failure tracking .rspec_status diff --git a/Gemfile b/Gemfile index d13ebdf..279ea71 100644 --- a/Gemfile +++ b/Gemfile @@ -5,4 +5,19 @@ source "https://rubygems.org" # Specify your gem's dependencies in rubytoolbox-api.gemspec gemspec +gem "rubocop" +gem "rubocop-performance" +gem "rubocop-rake" +gem "rubocop-rspec" + +gem "guard-bundler" +gem "guard-rspec" +gem "guard-rubocop" + +gem "rspec", ">= 3.9" +gem "simplecov", ">= 0.18.5" + +gem "vcr", ">= 5.1.0" +gem "webmock", ">= 3.8.3" + gem "rake", "~> 12.0" diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 0f8f792..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,130 +0,0 @@ -PATH - remote: . - specs: - rubytoolbox-api (0.2.0) - -GEM - remote: https://rubygems.org/ - specs: - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) - ast (2.4.2) - coderay (1.1.3) - crack (0.4.5) - rexml - diff-lcs (1.4.4) - docile (1.4.0) - ffi (1.15.3) - formatador (0.3.0) - guard (2.18.0) - formatador (>= 0.2.4) - listen (>= 2.7, < 4.0) - lumberjack (>= 1.0.12, < 2.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.13.0) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-bundler (3.0.0) - bundler (>= 2.1, < 3) - guard (~> 2.2) - guard-compat (~> 1.1) - guard-compat (1.2.1) - guard-rspec (4.7.3) - guard (~> 2.1) - guard-compat (~> 1.1) - rspec (>= 2.99.0, < 4.0) - guard-rubocop (1.5.0) - guard (~> 2.0) - rubocop (< 2.0) - hashdiff (1.0.1) - listen (3.7.0) - rb-fsevent (~> 0.10, >= 0.10.3) - rb-inotify (~> 0.9, >= 0.9.10) - lumberjack (1.2.8) - method_source (1.0.0) - nenv (0.3.0) - notiffany (0.1.3) - nenv (~> 0.1) - shellany (~> 0.0) - parallel (1.21.0) - parser (3.0.2.0) - ast (~> 2.4.1) - pry (0.14.1) - coderay (~> 1.1) - method_source (~> 1.0) - public_suffix (4.0.6) - rainbow (3.0.0) - rake (12.3.3) - rb-fsevent (0.11.0) - rb-inotify (0.10.1) - ffi (~> 1.0) - regexp_parser (2.1.1) - rexml (3.2.5) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-core (3.10.1) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-support (3.10.2) - rubocop (1.21.0) - parallel (~> 1.10) - parser (>= 3.0.0.0) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.9.1, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.11.0) - parser (>= 3.0.1.1) - rubocop-performance (1.11.5) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rake (0.6.0) - rubocop (~> 1.0) - rubocop-rspec (2.5.0) - rubocop (~> 1.19) - ruby-progressbar (1.11.0) - shellany (0.0.1) - simplecov (0.21.2) - docile (~> 1.1) - simplecov-html (~> 0.11) - simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) - simplecov_json_formatter (0.1.3) - thor (1.1.0) - unicode-display_width (2.1.0) - vcr (6.0.0) - webmock (3.14.0) - addressable (>= 2.8.0) - crack (>= 0.3.2) - hashdiff (>= 0.4.0, < 2.0.0) - -PLATFORMS - ruby - -DEPENDENCIES - guard-bundler - guard-rspec - guard-rubocop - rake (~> 12.0) - rspec (>= 3.9) - rubocop - rubocop-performance - rubocop-rake - rubocop-rspec - rubytoolbox-api! - simplecov (>= 0.18.5) - vcr (>= 5.1.0) - webmock (>= 3.8.3) - -BUNDLED WITH - 2.2.25 diff --git a/lib/rubytoolbox/api/response_wrapper.rb b/lib/rubytoolbox/api/response_wrapper.rb index d8b8cbb..67ab115 100644 --- a/lib/rubytoolbox/api/response_wrapper.rb +++ b/lib/rubytoolbox/api/response_wrapper.rb @@ -23,12 +23,12 @@ def field(name, &block) block ||= ->(value) { value } - define_method "#{name}=" do |value| - instance_variable_set "@#{name}", block.call(value) + define_method :"#{name}=" do |value| + instance_variable_set :"@#{name}", block.call(value) end attr_reader name - private "#{name}=" + private :"#{name}=" end def fields @@ -40,7 +40,7 @@ def initialize(data) self.class.fields.each do |name| value = data.key?(name.to_s) ? data[name.to_s] : data[name.to_sym] - send "#{name}=", value unless value.nil? + send :"#{name}=", value unless value.nil? end end diff --git a/rubytoolbox-api.gemspec b/rubytoolbox-api.gemspec index 07fee75..7049bf7 100644 --- a/rubytoolbox-api.gemspec +++ b/rubytoolbox-api.gemspec @@ -2,7 +2,6 @@ require_relative "lib/rubytoolbox/api/version" -# rubocop:disable Metrics/BlockLength Gem::Specification.new do |spec| spec.name = "rubytoolbox-api" spec.version = Rubytoolbox::Api::VERSION @@ -27,19 +26,5 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_development_dependency "rubocop" - spec.add_development_dependency "rubocop-performance" - spec.add_development_dependency "rubocop-rake" - spec.add_development_dependency "rubocop-rspec" - - spec.add_development_dependency "guard-bundler" - spec.add_development_dependency "guard-rspec" - spec.add_development_dependency "guard-rubocop" - - spec.add_development_dependency "rspec", ">= 3.9" - spec.add_development_dependency "simplecov", ">= 0.18.5" - - spec.add_development_dependency "vcr", ">= 5.1.0" - spec.add_development_dependency "webmock", ">= 3.8.3" + spec.metadata["rubygems_mfa_required"] = "true" end -# rubocop:enable Metrics/BlockLength diff --git a/spec/rubytoolbox/api/response_wrapper_spec.rb b/spec/rubytoolbox/api/response_wrapper_spec.rb index 6a01b25..375d637 100644 --- a/spec/rubytoolbox/api/response_wrapper_spec.rb +++ b/spec/rubytoolbox/api/response_wrapper_spec.rb @@ -30,7 +30,7 @@ end it "correctly handles false value when given as string key" do - expect(sample.new("foo" => false, bar: "123").foo).to be == false + expect(sample.new("foo" => false, bar: "123").foo).to be false end it "can be converted back to a hash" do # rubocop:disable RSpec/ExampleLength @@ -41,7 +41,7 @@ subcollection: [{ key: "value" }] ) - expect(object.to_h).to be == { + expect(object.to_h).to eq( "foo" => "foo", "bar" => "rab", "sub" => { @@ -49,7 +49,7 @@ }, "subcollection" => [ { "key" => "value" }, - ], - } + ] + ) end end diff --git a/spec/rubytoolbox/api_spec.rb b/spec/rubytoolbox/api_spec.rb index 0d88ee1..7d3c1fa 100644 --- a/spec/rubytoolbox/api_spec.rb +++ b/spec/rubytoolbox/api_spec.rb @@ -4,16 +4,16 @@ let(:client) { described_class.new } it "has a version number" do - expect(Rubytoolbox::Api::VERSION).not_to be nil + expect(Rubytoolbox::Api::VERSION).not_to be_nil end describe "initializer" do it "defaults endpoint_url to https://www.ruby-toolbox.com/api/" do - expect(described_class.new.endpoint_url).to be == "https://www.ruby-toolbox.com/api/" + expect(described_class.new.endpoint_url).to eq "https://www.ruby-toolbox.com/api/" end it "accepts a custom endpoint_url" do - expect(described_class.new(url: "http://localhost:5000/api/").endpoint_url).to be == "http://localhost:5000/api/" + expect(described_class.new(url: "http://localhost:5000/api/").endpoint_url).to eq "http://localhost:5000/api/" end end