Skip to content
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

Introduce suspenders:prerequisites generator #1171

Merged
merged 1 commit into from
Mar 22, 2024
Merged
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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Unreleased
* Introduce `suspenders:db:migrate` task
* Introduce `suspenders:email` generator
* Introduce `suspenders:testing` generator
* Introduce `suspenders:prerequisites` generator

20230113.0 (January, 13, 2023)

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ Set up the project for an in-depth test-driven development workflow via

[rspec-rails]: https://github.com/rspec/rspec-rails

#### Prerequisites

Configures prerequisites. Currently Node.

```
bin/rails g suspenders:prerequisites
```

## Contributing

See the [CONTRIBUTING] document.
Expand Down
13 changes: 13 additions & 0 deletions lib/generators/suspenders/prerequisites_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Suspenders
module Generators
class PrerequisitesGenerator < Rails::Generators::Base
source_root File.expand_path("../../templates/prerequisites", __FILE__)

desc "Configures prerequisites. Currently Node."

def node_version
template "node-version", ".node-version"
end
end
end
end
1 change: 1 addition & 0 deletions lib/generators/templates/prerequisites/node-version.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= Suspenders::NODE_LTS_VERSION %>
1 change: 1 addition & 0 deletions lib/suspenders/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ module Suspenders
VERSION = "3.0.0".freeze
RAILS_VERSION = "~> 7.0".freeze
MINIMUM_RUBY_VERSION = ">= 3.1".freeze
NODE_LTS_VERSION = "20.11.1".freeze
end
32 changes: 32 additions & 0 deletions test/generators/suspenders/prerequisites_generator_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require "test_helper"
require "generators/suspenders/prerequisites_generator"

module Suspenders
module Generators
class PrerequisitesGeneratorTest < Rails::Generators::TestCase
include Suspenders::TestHelpers

tests Suspenders::Generators::PrerequisitesGenerator
destination Rails.root
teardown :restore_destination

test "generates .node-version file" do
run_generator

assert_file app_root(".node-version") do |file|
assert_match(/20\.11\.1/, file)
end
end

test "has custom description" do
assert_no_match(/Description/, generator.class.desc)
end

private

def restore_destination
remove_file_if_exists ".node-version"
end
end
end
end
4 changes: 4 additions & 0 deletions test/suspenders_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ class SuspendersTest < ActiveSupport::TestCase
test "it has a Minimum Ruby version number" do
assert Suspenders::MINIMUM_RUBY_VERSION
end

test "it has a Node LTS version number" do
assert Suspenders::NODE_LTS_VERSION
end
end