Skip to content

Commit

Permalink
fix: Define default Rake task
Browse files Browse the repository at this point in the history
The default Rake task is now set to run RSpec. RuboCop and StandardRB
have been configured but will not run as a part of the default task as a
few issues need cleaning up before enabling.
  • Loading branch information
rhatherall committed Dec 7, 2023
1 parent ee7a120 commit 4efe7a3
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 7 deletions.
10 changes: 10 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
inherit_gem:
standard: config/base.yml

AllCops:
NewCops: enable

require:
- rubocop-rspec
- standard
5 changes: 5 additions & 0 deletions .standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# For available configuration options, see:
# https://github.com/testdouble/standard
ignore:
- "spec/dummy/**/*"
ruby_version: 2.6
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ gem "sprockets-rails"
gem "rspec-rails", "~> 6.1"

gem "standard", "~> 1.32"

gem "rubocop-rspec", "~> 2.25"
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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]
27 changes: 27 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -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")
27 changes: 27 additions & 0 deletions bin/rubocop
Original file line number Diff line number Diff line change
@@ -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")
1 change: 1 addition & 0 deletions cognito_idp_rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/cognito_idp_rails/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/cognito_idp_rails/sessions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
get path

expect(client).to have_received(:get_token)
.with(grant_type: :authorization_code, code: code, redirect_uri:)
.with(grant_type: :authorization_code, code: code, redirect_uri: redirect_uri)
end

context "when a token is received" do
Expand Down
8 changes: 4 additions & 4 deletions spec/routing/mapper_extensions_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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
end
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
Expand Down

0 comments on commit 4efe7a3

Please sign in to comment.