Skip to content

Commit

Permalink
Merge pull request #36 from collectiveidea/updates!
Browse files Browse the repository at this point in the history
Updates for newer versions of Ruby and Rails
  • Loading branch information
gaffneyc authored Nov 18, 2024
2 parents 6504207 + edd50c6 commit 9a9ad59
Show file tree
Hide file tree
Showing 15 changed files with 224 additions and 175 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Run Tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
spec:
runs-on: ubuntu-latest

strategy:
matrix:
ruby_version:
- "3.1"
- "3.2"
- "3.3"
gemfile:
- "rails70"
- "rails71"
- "rails72"
- "rails80"
exclude:
- ruby_version: "3.1"
gemfile: "rails80"
include:
- ruby_version: "head"
gemfile: "rails-main"

env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile

steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true

- name: Run Tests
run: bundle exec rake
61 changes: 0 additions & 61 deletions .travis.yml

This file was deleted.

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 2.3.0 / TBD

* [ENHANCEMENT] Add support for test-unit
* [ENHANCEMENT] Add support for Ruby 3.1+ and Rails 7.0+
* [ENHANCEMENT] Drop support for EOL Ruby and Rails versions
* [ENHANCEMENT] Change depdency from all of Rails to just railties
* [ENHANCEMENT] Prefer spec/rails_helper.rb when available

## 2.2.0 / 2019-09-01

* [ENHANCEMENT] Add support for Ruby 2.6
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Interactor Rails

[![Gem](https://img.shields.io/gem/v/interactor-rails.svg?style=flat-square)](http://rubygems.org/gems/interactor-rails)
[![Build](https://img.shields.io/travis/collectiveidea/interactor-rails/master.svg?style=flat-square)](https://travis-ci.org/collectiveidea/interactor-rails)
[![Build](https://github.com/collectiveidea/interactor-rails/actions/workflows/tests.yml/badge.svg)](https://github.com/collectiveidea/interactor-rails/actions/workflows/tests.yml)
[![Coverage](https://img.shields.io/codeclimate/coverage-letter/collectiveidea/interactor-rails.svg?style=flat-square)](https://codeclimate.com/github/collectiveidea/interactor-rails)
[![Maintainability](https://img.shields.io/codeclimate/maintainability/collectiveidea/interactor-rails.svg?style=flat-square)](https://codeclimate.com/github/collectiveidea/interactor-rails)

Expand All @@ -16,8 +16,8 @@ Add this line to your application's Gemfile:
gem "interactor-rails", "~> 2.0"
```

Interactor Rails is compatible with Ruby 2.3, 2.4, or 2.5 on Rails 4.2, 5.0,
5.1, 5.2 or 6.0.
Interactor Rails is tested against Ruby 3.1 and newer on Rails 7.0 or newer.
For older versions of Ruby and Rails use version 2.2.1.

## Usage

Expand Down
File renamed without changes.
11 changes: 0 additions & 11 deletions gemfiles/rails60.gemfile

This file was deleted.

2 changes: 1 addition & 1 deletion gemfiles/rails52.gemfile → gemfiles/rails70.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"

gemspec path: ".."

gem "rails", "~> 5.2.0"
gem "rails", "~> 7.0.0"

group :test do
gem "aruba"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails42.gemfile → gemfiles/rails71.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"

gemspec path: ".."

gem "rails", "~> 4.2.0"
gem "rails", "~> 7.1.0"

group :test do
gem "aruba"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails50.gemfile → gemfiles/rails72.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"

gemspec path: ".."

gem "rails", "~> 5.0.0"
gem "rails", "~> 7.2.0"

group :test do
gem "aruba"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails51.gemfile → gemfiles/rails80.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"

gemspec path: ".."

gem "rails", "~> 5.1.0"
gem "rails", "~> 8.0.0"

group :test do
gem "aruba"
Expand Down
4 changes: 2 additions & 2 deletions interactor-rails.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

Gem::Specification.new do |spec|
spec.name = "interactor-rails"
Expand All @@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(/^spec/)

spec.add_dependency "interactor", "~> 3.0"
spec.add_dependency "rails", ">= 4.2"
spec.add_dependency "railties", ">= 7.0"

spec.add_development_dependency "bundler"
spec.add_development_dependency "rake"
Expand Down
21 changes: 19 additions & 2 deletions lib/generators/interactor.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
module Interactor
class Generator < ::Rails::Generators::NamedBase
def self.source_root
File.expand_path("../templates", __FILE__)
File.expand_path("templates", __dir__)
end

def generate
template "#{self.class.generator_name}.erb", File.join("app/interactors", class_path, "#{file_name}.rb")
template "spec.erb", File.join("spec/interactors", class_path, "#{file_name}_spec.rb")

if use_test_unit?
template "test.erb", File.join("test/interactors", class_path, "#{file_name}_test.rb")
else
template "spec.erb", File.join("spec/interactors", class_path, "#{file_name}_spec.rb")
end
end

def use_test_unit?
::Rails.application.config.generators.options[:rails][:test_framework] == :test_unit
end

def rspec_helper_file
if File.exist?("spec/rails_helper.rb")
"rails_helper"
else
"spec_helper"
end
end
end
end
2 changes: 1 addition & 1 deletion lib/generators/templates/spec.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require "<%= rspec_helper_file %>"

RSpec.describe <%= class_name %>, type: :interactor do
describe '.call' do
Expand Down
7 changes: 7 additions & 0 deletions lib/generators/templates/test.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class <%= class_name %>Test < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
Loading

0 comments on commit 9a9ad59

Please sign in to comment.