Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Parr committed May 28, 2022
0 parents commit 4f1ab57
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Tests

on: [push]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'

- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '16.x'

- name: Install dependencies
run: |
npm install -g npm
sudo apt-get -yqq install libsqlite3-dev libpq-dev libmysqlclient-dev
gem install rails
# Clean up git repo so the new rails template doesn't conflict
- name: Remove git repo
run: |
rm -rf .git
- name: Run tests
run: |
rake
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.3
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
A Rails Application Template for use at Ministry of Velocity

Reference: [Rails Application Templates](https://guides.rubyonrails.org/rails_application_templates.html)


Thank you to the following open source projects for inspiration and setup:

[Jumpstart](https://github.com/excid3/jumpstart).
[https://github.com/mattbrictson/rails-template](https://github.com/mattbrictson/rails-template)
9 changes: 9 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "rake/testtask"

Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
end

task :default => :test
24 changes: 24 additions & 0 deletions template.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def rails_version
@rails_version ||= Gem::Version.new(Rails::VERSION::STRING)
end

def rails_7_or_newer?
Gem::Requirement.new(">= 7.0.0").satisfied_by? rails_version
end

def add_gems

end

unless rails_7_or_newer?
say_error "-----------------------------", :red
say_error "Please use Rails 7.0 or newer", :red
say_error "-----------------------------", :red
# raise 'hell'
end

add_gems

after_bundle do
say "App successfully created!", :green
end
19 changes: 19 additions & 0 deletions test/template_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require "minitest/autorun"

class TemplateTest < Minitest::Test
def setup
system("[ -d test_app ] && rm -rf test_app")
end

def teardown
setup
end

def test_generator_succeeds
output, error = capture_subprocess_io do
system("rails new test_app -m template.rb")
end
assert_includes output, "App successfully created!"
# puts error
end
end

0 comments on commit 4f1ab57

Please sign in to comment.