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

Add include Dry::Monads[:result] to Rspec blocks #23

Merged
merged 2 commits into from
Jul 16, 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
8 changes: 8 additions & 0 deletions lib/hanami/rspec/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def call(*, **)
copy_spec_helper
copy_support_rspec
copy_support_features
copy_support_operations
copy_support_requests

generate_request_spec
Expand Down Expand Up @@ -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__),
Expand Down
1 change: 1 addition & 0 deletions lib/hanami/rspec/generators/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

require_relative "support/rspec"
require_relative "support/features"
require_relative "support/operations"
require_relative "support/requests"
8 changes: 8 additions & 0 deletions lib/hanami/rspec/generators/support_operations.rb
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions spec/unit/hanami/rspec/commands/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down