diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..9255d48 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,10 @@ +--- +inherit_gem: + standard: config/base.yml + +AllCops: + NewCops: enable + +require: + - rubocop-rspec + - standard diff --git a/.standard.yml b/.standard.yml new file mode 100644 index 0000000..9ad641e --- /dev/null +++ b/.standard.yml @@ -0,0 +1,5 @@ +# For available configuration options, see: +# https://github.com/testdouble/standard +ignore: + - "spec/dummy/**/*" +ruby_version: 2.6 diff --git a/Gemfile b/Gemfile index 72f5e35..ad6b028 100644 --- a/Gemfile +++ b/Gemfile @@ -16,3 +16,5 @@ gem "sprockets-rails" gem "rspec-rails", "~> 6.1" gem "standard", "~> 1.32" + +gem "rubocop-rspec", "~> 2.25" diff --git a/Rakefile b/Rakefile index 416b023..19430bb 100644 --- a/Rakefile +++ b/Rakefile @@ -6,3 +6,10 @@ load "rails/tasks/engine.rake" load "rails/tasks/statistics.rake" require "bundler/gem_tasks" +require "rspec/core/rake_task" + +RSpec::Core::RakeTask.new(:spec) + +require "standard/rake" + +task default: %i[spec] diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000..4eb7d7b --- /dev/null +++ b/bin/rake @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rake' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rake", "rake") diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 0000000..369a05b --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rubocop' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rubocop", "rubocop") diff --git a/cognito_idp_rails.gemspec b/cognito_idp_rails.gemspec index df9d944..77d7271 100644 --- a/cognito_idp_rails.gemspec +++ b/cognito_idp_rails.gemspec @@ -9,6 +9,7 @@ Gem::Specification.new do |spec| spec.summary = "Simple Rails integration for Amazon Cognito IdP (User Pools)" spec.description = "Simple Rails integration for authentication through Amazon Cognito IdP (User Pools)" spec.license = "MIT" + spec.required_ruby_version = ">= 2.6.0" spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = spec.homepage diff --git a/spec/cognito_idp_rails/configuration_spec.rb b/spec/cognito_idp_rails/configuration_spec.rb index 66f3652..375321d 100644 --- a/spec/cognito_idp_rails/configuration_spec.rb +++ b/spec/cognito_idp_rails/configuration_spec.rb @@ -7,7 +7,7 @@ subject(:after_login_route) { configuration.after_login_route } it "defaults to /" do - is_expected.to eq("/") + expect(subject).to eq("/") end context "when specified" do @@ -25,7 +25,7 @@ subject(:after_logout_route) { configuration.after_logout_route } it "defaults to /" do - is_expected.to eq("/") + expect(subject).to eq("/") end context "when specified" do diff --git a/spec/routing/mapper_extensions_spec.rb b/spec/routing/mapper_extensions_spec.rb index e054050..83e6aca 100644 --- a/spec/routing/mapper_extensions_spec.rb +++ b/spec/routing/mapper_extensions_spec.rb @@ -1,10 +1,6 @@ require "rails_helper" RSpec.describe CognitoIdpRails::Routing::MapperExtensions, type: :routing do - it "defines cognito_idp method" do - expect(ActionDispatch::Routing::Mapper.new(ActionDispatch::Routing::RouteSet.new)).to respond_to(:cognito_idp) - end - before do Rails.application.routes.draw do cognito_idp @@ -12,6 +8,10 @@ Rails.application.reload_routes! end + it "defines cognito_idp method" do + expect(ActionDispatch::Routing::Mapper.new(ActionDispatch::Routing::RouteSet.new)).to respond_to(:cognito_idp) + end + it "adds login route" do expect(Rails.application.routes.recognize_path("/login")).to match(controller: "cognito_idp_rails/sessions", action: "login") end