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 grape controller module with test application #16

Merged
merged 2 commits into from
Dec 21, 2022

Conversation

yogeshjain999
Copy link
Member

  • Added Trailblazer::Endpoint::Grape::Controller to make .endpoint, .directive & #endpoint available in Grape classes
  • Added sample grape app via appraisal
  • TODO: Make inheritance between Grape::API classes work. They're not copying @normalizers settings.


def endpoint_for(name, config_source: self.class)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason for removing this config_source arg? 🌷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, self.class needs to be different in case grape instance. So I defined a method for config_source .

See default method for rails and grape

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't you override the entire method instead, for grape.rb and change the defaulting there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, do you mean override endpoint_for itself ?

We actually need config_source in other methods too (API.endpoint and compile_options_for_controller).

@@ -145,4 +145,5 @@ def self.advance_from_controller(endpoint, success_block:, failure_block:, proto
require "trailblazer/endpoint/adapter"
require "trailblazer/endpoint/dsl"
require "trailblazer/endpoint/controller"
require "trailblazer/endpoint/grape/controller"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we require that for grape environments, only?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I've removed it.

@yogeshjain999 yogeshjain999 merged commit e74d831 into trailblazer:master Dec 21, 2022
@yogeshjain999 yogeshjain999 deleted the grape-integration branch December 21, 2022 14:58
Copy link
Member

@apotonick apotonick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be an option to use the Rails app/concepts in the Grape tests? I am thinking of the far future, where we have lots of code to test in both frameworks.

@yogeshjain999
Copy link
Member Author

Would it be an option to use the Rails app/concepts in the Grape tests? I am thinking of the far future, where we have lots of code to test in both frameworks.

Good point, I'll look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants