Skip to content

Update testing framework #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
source "https://rubygems.org"

gem "rails", ENV["RAILS_VERSION"] || raise(<<~ERR)

>>>>> ATTENTION <<<<<

You are attempting something outside of 'bin/test'. If you are wanting to
run tests, utilize 'bin/test'. Otherwise, set the RAILS_VERSION variable prior to
your current action.

ERR

gem "sqlite3"
gem "test-unit"

# Specify your gem's dependencies in pry-rails.gemspec
gemspec
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ require "rubygems"
require "bundler/setup"
require "bundler/gem_tasks"
require "rake/testtask"
require "appraisal"

Rake::TestTask.new do |t|
t.libs.concat %w(pry-rails spec)
Expand Down
22 changes: 2 additions & 20 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,9 @@ Note that you may need to run `spring stop` first.

# Developing and Testing

This repo uses [Roadshow] to generate a [Docker Compose] file for each
supported version of Rails (with a compatible version of Ruby for each one).
Requirements: docker or podman with docker compatibility layer.

To run specs across all versions, you can either [get the Roadshow tool] and
run `roadshow run`, or use Docker Compose directly:

```
$ for fn in scenarios/*.docker-compose.yml; do docker-compose -f $fn run --rm scenario; done
```

You can also manually run the Rails console and server on each version with
`roadshow run rake console` and `roadshow run rake server`, or run them on a
specific version with, e.g., `roadshow run -s rails40 rake console`.

To update the set of scenarios, edit `scenarios.yml` and run `roadshow
generate`, although the Gemfiles in the `scenarios` directory need to be
maintained manually.

[Roadshow]: https://github.com/rf-/roadshow
[Docker Compose]: https://docs.docker.com/compose/
[get the Roadshow tool]: https://github.com/rf-/roadshow/releases
To run the test suite against supported Ruby and Rails versions, run `bin/test`.

# Alternative

Expand Down
48 changes: 48 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#! /usr/bin/env ruby
# frozen_string_literals: true

require 'optparse'
require 'open3'

skip_build = false

OptionParser.new {|opt|
opt.banner = "Usage: bin/test [options]"
opt.on("-B", "--skip-build") { skip_build = true }
}.parse!

ruby_versions = ['3.2', '3.3', '3.4']
rails_versions = ['~>7', '~>8']

ruby_versions.product(rails_versions).reject { |ruby_v, rails_v|
container_file = <<~CF
FROM docker.io/ruby:#{ruby_v}-slim
RUN apt-get update \
&& apt-get install -y build-essential git pkg-config libyaml-dev \
&& mkdir -p /pry-rails
WORKDIR /pry-rails
ENV RAILS_VERSION="#{rails_v}" LANG=C.UTF-8
COPY Gemfile *.gemspec .
COPY lib/pry-rails/version.rb lib/pry-rails/version.rb
RUN bundle install
CMD bundle exec rake
CF

puts "# ruby:#{ruby_v} rails:#{rails_v}\n"

Open3.popen3("/usr/bin/env docker build -qf - -t pry-rails-#{ruby_v}-#{rails_v[-1]} .") { |i,o,e,wt|
i.puts container_file
i.close
o.each { STDOUT.puts _1 }
e.each { STDERR.puts _1 }
exitstatus = wt.value.exitstatus
exit exitstatus unless exitstatus == 0
} unless skip_build

system("/usr/bin/env docker run -v .:/pry-rails pry-rails-#{ruby_v}-#{rails_v[-1]}")
}
.tap {|failures| puts (failures.any? ? "FAILURES:" : "ALL CLEAR!") }
.each {|ruby_v, rails_v|
puts "# ruby:#{ruby_v} rails:#{rails_v}"
}
.then {|failures| exit(failures.any? ? 1 : 0 ) }
3 changes: 2 additions & 1 deletion lib/pry-rails/commands/find_route.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class PryRails::FindRoute < Pry::ClassCommand
match 'find-route'
group 'Rails'
Expand Down Expand Up @@ -51,7 +52,7 @@ def show_routes(&block)
all_routes = routes.select(&block)
if all_routes.any?
grouped_routes = all_routes.group_by { |route| route.defaults[:controller] }
result = grouped_routes.each_with_object("") do |(controller, routes), res|
result = grouped_routes.each_with_object(String.new) do |(controller, routes), res|
res << "Routes for " + bold(controller.to_s.camelize + "Controller") + "\n"
res << "--\n"
routes.each do |route|
Expand Down
1 change: 0 additions & 1 deletion lib/pry-rails/commands/show_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def options(opt)
end

def process
Rails.application.reload_routes!
all_routes = Rails.application.routes.routes

formatted =
Expand Down
5 changes: 0 additions & 5 deletions lib/pry-rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class Railtie < Rails::Railtie
require "rails/commands/console/irb_console"

Module.new do
def reload!
puts "Reloading..."
Rails.application.reloader.reload!
end

::IRB::HelperMethod.helper_methods.each do |name, helper_method_class|
define_method name do |*args, **opts, &block|
helper_method_class.instance.execute(*args, **opts, &block)
Expand Down
2 changes: 1 addition & 1 deletion lib/pry-rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# encoding: UTF-8

module PryRails
VERSION = "0.3.11"
VERSION = '0.3.11'
end
7 changes: 2 additions & 5 deletions pry-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ Gem::Specification.new do |s|

# s.rubyforge_project = "pry-rails"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.files = Dir['lib/**/*']
s.test_files = Dir['spec/**/*']

s.add_dependency "pry", ">= 0.13.0"
s.add_development_dependency "appraisal"
s.add_development_dependency "minitest"
end
30 changes: 0 additions & 30 deletions scenarios.yml

This file was deleted.

15 changes: 0 additions & 15 deletions scenarios/rails30.docker-compose.yml

This file was deleted.

5 changes: 0 additions & 5 deletions scenarios/rails30.dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions scenarios/rails30.gemfile

This file was deleted.

15 changes: 0 additions & 15 deletions scenarios/rails31.docker-compose.yml

This file was deleted.

5 changes: 0 additions & 5 deletions scenarios/rails31.dockerfile

This file was deleted.

8 changes: 0 additions & 8 deletions scenarios/rails31.gemfile

This file was deleted.

15 changes: 0 additions & 15 deletions scenarios/rails32.docker-compose.yml

This file was deleted.

5 changes: 0 additions & 5 deletions scenarios/rails32.dockerfile

This file was deleted.

8 changes: 0 additions & 8 deletions scenarios/rails32.gemfile

This file was deleted.

15 changes: 0 additions & 15 deletions scenarios/rails40.docker-compose.yml

This file was deleted.

5 changes: 0 additions & 5 deletions scenarios/rails40.dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions scenarios/rails40.gemfile

This file was deleted.

15 changes: 0 additions & 15 deletions scenarios/rails41.docker-compose.yml

This file was deleted.

5 changes: 0 additions & 5 deletions scenarios/rails41.dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions scenarios/rails41.gemfile

This file was deleted.

15 changes: 0 additions & 15 deletions scenarios/rails42.docker-compose.yml

This file was deleted.

5 changes: 0 additions & 5 deletions scenarios/rails42.dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions scenarios/rails42.gemfile

This file was deleted.

15 changes: 0 additions & 15 deletions scenarios/rails50.docker-compose.yml

This file was deleted.

5 changes: 0 additions & 5 deletions scenarios/rails50.dockerfile

This file was deleted.

Loading