Skip to content

Commit

Permalink
Merge pull request #86 from TruemarkDev/generator-for-whenever
Browse files Browse the repository at this point in the history
Added boring generator for Whenever gem with its minitest
  • Loading branch information
abhaynikam authored Jul 1, 2023
2 parents a9097e7 + 898e41e commit b0369b9
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
.byebug_history

*.log
.idea
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## master (unreleased)
* Adds Letter Opener generator. ([@coolprobn][])
* Adds Whenever generator. ([@aadil][])

## 0.12.0 (May 8th, 2023)
* Adds Flipper generator. ([@abhaynikam][])
Expand Down Expand Up @@ -78,3 +79,4 @@
[@jamesglover]: https://github.com/JamesGlover
[@luathn]: https://github.com/luathn
[@coolprobn]: https://github.com/coolprobn
[@aadil]: https://github.com/AdilRT
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,4 @@ DEPENDENCIES

BUNDLED WITH
2.4.10

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ The boring generator introduces following generators:
- Install Faker: `rails generate boring:faker:install`
- Install Overcommit with RuboCop: `rails generate boring:overcommit:pre_commit:rubocop:install`
- Install Letter Opener: `rails generate boring:letter_opener:install`
- Install Whenever: `rails generate boring:whenever:install`

## Screencasts

Expand Down
25 changes: 25 additions & 0 deletions lib/generators/boring/whenever/install/install_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

module Boring
module Whenever
class InstallGenerator < Rails::Generators::Base
desc "Adds whenever gem to the application for managing cron jobs"

def add_whenever_gem
say "Adding whenever gem", :green

Bundler.with_unbundled_env do
run "bundle add whenever"
end
end

def add_schedule_file
say "Create schedule.rb file", :green

Bundler.with_unbundled_env do
run "bundle exec wheneverize ."
end
end
end
end
end
26 changes: 26 additions & 0 deletions test/generators/whenever_install_generator_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

require "test_helper"
require "generators/boring/whenever/install/install_generator"

class WheneverInstallGeneratorTest < Rails::Generators::TestCase
tests Boring::Whenever::InstallGenerator
setup :build_app
teardown :teardown_app

include GeneratorHelper
include ActiveSupport::Testing::Isolation

def destination_root
app_path
end

def test_should_configure_whenever_gem
Dir.chdir(app_path) do
quietly { run_generator }

assert_gem "whenever"
assert_file "config/schedule.rb"
end
end
end

0 comments on commit b0369b9

Please sign in to comment.