diff --git a/lib/hanami/rspec/commands.rb b/lib/hanami/rspec/commands.rb index 30ee50e..fb3b3e8 100644 --- a/lib/hanami/rspec/commands.rb +++ b/lib/hanami/rspec/commands.rb @@ -19,6 +19,7 @@ def call(*, **) copy_spec_helper copy_support_rspec copy_support_features + copy_support_operations copy_support_requests generate_request_spec @@ -68,6 +69,13 @@ def copy_support_features ) end + def copy_support_operations + fs.cp( + fs.expand_path(fs.join("generators", "support_operations.rb"), __dir__), + fs.expand_path(fs.join("spec", "support", "operations.rb")) + ) + end + def copy_support_requests fs.cp( fs.expand_path(fs.join("generators", "support_requests.rb"), __dir__), diff --git a/lib/hanami/rspec/generators/helper.rb b/lib/hanami/rspec/generators/helper.rb index ca3a4de..8f51be0 100644 --- a/lib/hanami/rspec/generators/helper.rb +++ b/lib/hanami/rspec/generators/helper.rb @@ -8,4 +8,5 @@ require_relative "support/rspec" require_relative "support/features" +require_relative "support/operations" require_relative "support/requests" diff --git a/lib/hanami/rspec/generators/support_operations.rb b/lib/hanami/rspec/generators/support_operations.rb new file mode 100644 index 0000000..7c0a009 --- /dev/null +++ b/lib/hanami/rspec/generators/support_operations.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +require "dry/monads" + +RSpec.configure do |config| + # Provide `Success` and `Failure` for testing operation results + config.include Dry::Monads[:result] +end diff --git a/spec/unit/hanami/rspec/commands/install_spec.rb b/spec/unit/hanami/rspec/commands/install_spec.rb index 03535db..33949fa 100644 --- a/spec/unit/hanami/rspec/commands/install_spec.rb +++ b/spec/unit/hanami/rspec/commands/install_spec.rb @@ -55,6 +55,7 @@ require_relative "support/rspec" require_relative "support/features" + require_relative "support/operations" require_relative "support/requests" EOF expect(fs.read("spec/spec_helper.rb")).to eq(spec_helper) @@ -135,6 +136,18 @@ EOF expect(fs.read("spec/support/features.rb")).to eq(support_features) + support_operations = <<~EOF + # frozen_string_literal: true + + require "dry/monads" + + RSpec.configure do |config| + # Provide `Success` and `Failure` for testing operation results + config.include Dry::Monads[:result] + end + EOF + expect(fs.read("spec/support/operations.rb")).to eq(support_operations) + # spec/support/requests.rb support_requests = <<~EOF # frozen_string_literal: true