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

Skip generating tests with --skip-tests flag given #22

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions lib/hanami/rspec/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class Action < Hanami::CLI::Commands::App::Command
# @api private
def call(options, **)
# FIXME: dry-cli kwargs aren't correctly forwarded in Ruby 3

return if options[:skip_tests]

slice = inflector.underscore(Shellwords.shellescape(options[:slice])) if options[:slice]
name = inflector.underscore(Shellwords.shellescape(options[:name]))
*controller, action = name.split(ACTION_SEPARATOR)
Expand All @@ -107,6 +110,9 @@ class Part < Hanami::CLI::Commands::App::Command
# @api private
def call(options, **)
# FIXME: dry-cli kwargs aren't correctly forwarded in Ruby 3

return if options[:skip_tests]

slice = inflector.underscore(Shellwords.shellescape(options[:slice])) if options[:slice]
name = inflector.underscore(Shellwords.shellescape(options[:name]))

Expand Down
20 changes: 20 additions & 0 deletions spec/unit/hanami/rspec/commands/generate/action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@
end
end
end

context "skip_tests given" do
it "does not generate a spec file" do
within_application_directory do
subject.call({name: action_name, skip_tests: true})

expect(fs.exist?("spec/actions/client/create_spec.rb")).to be false
end
end
end
end

context "slice" do
Expand All @@ -84,6 +94,16 @@
expect(fs.read("spec/slices/#{slice}/actions/client/create_spec.rb")).to eq(action_spec)
end
end

context "skip_tests given" do
it "does not generate a spec file" do
within_application_directory do
subject.call({slice: slice, name: action_name, skip_tests: true})

expect(fs.exist?("spec/slices/#{slice}/actions/client/create_spec.rb")).to be false
end
end
end
end
end

Expand Down
20 changes: 20 additions & 0 deletions spec/unit/hanami/rspec/commands/generate/part_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@
end
end
end

context "skip_tests given" do
it "does not generate spec file" do
within_application_directory do
subject.call({name: part_name, skip_tests: true})

expect(fs.exist?("spec/views/parts/client_spec.rb")).to be false
end
end
end
end

context "slice" do
Expand Down Expand Up @@ -263,6 +273,16 @@
end
end
end

context "skip_tests given" do
it "does not generate spec file" do
within_application_directory do
subject.call({slice: slice, name: part_name, skip_tests: true})

expect(fs.exist?("spec/slices/#{slice}/views/parts/client_spec.rb")).to be false
end
end
end
end
end

Expand Down