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

null database strategy to disable @javascript handling #522

Merged
merged 1 commit into from
Nov 8, 2021

Conversation

akostadinov
Copy link
Contributor

@akostadinov akostadinov commented Oct 1, 2021

Summary

Presently there is no nice way to disable @javascript tag handling without writing a custom database strategy class. See #521

This PR adds a null database strategy to allow easily doing so by

Cucumber::Rails::Database.javascript_strategy = :none

I'm planning to add some other enhancements and documentation later to allow custom list of tags but having a null strategy is useful anyway and is a first step.

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@aurelien-reeves
Copy link
Contributor

What about naming it "none" instead of "null"?

@akostadinov
Copy link
Contributor Author

akostadinov commented Oct 1, 2021

@aurelien-reeves , I agree with whatever naming project wants. If the change is in general accepted, I'd go ahead to rename it.

@akostadinov
Copy link
Contributor Author

I renamed to none.

Copy link
Contributor

@aurelien-reeves aurelien-reeves left a comment

Choose a reason for hiding this comment

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

It looks good to me, well done 👌
But as I am not that much into this project, I prefer to let other contributors to review it :)

@akostadinov
Copy link
Contributor Author

@luke-hill @olleolleolle , could you look at this pull request? It is not big.

Or what are the rules to merge? Can I merge once another member has reviewed and there is some time passed without other comments?

@aurelien-reeves
Copy link
Contributor

@akostadinov could you add an entry in the changelog? And if you had the opportunity to add some documentation regarding those database strategies, that would be a good bonus to that PR :)

@olleolleolle @luke-hill if no further objection, I may merge this soon

Copy link
Contributor

@luke-hill luke-hill left a comment

Choose a reason for hiding this comment

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

This feels like it's not a None strategy i.e. one isn't there, but a null strategy. So perhaps we should name it NullStrategy to infer that the responses on the js checkers are nil

@aurelien-reeves
Copy link
Contributor

This feels like it's not a None strategy i.e. one isn't there, but a null strategy. So perhaps we should name it NullStrategy to infer that the responses on the js checkers are nil

Well, it was first named NullStrategy, I ask him to rename it to None weeks ago 😓

I keep feeling this is more "None" than "Null": the strategy is actually nothing, no code. It is like having no strategy at all.

But I may misunderstand it actually 😶

@@ -23,6 +23,9 @@ Feature: Choose javascript database strategy
The deletion strategy can be quicker for situations where truncation causes locks which
has been reported by some Oracle users.

The none strategy can be used when user doesn't want special handling of scenario
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: Perhaps it's not easy to see that the names none and deletion are symbols to be used, or rather, names of strategies. Would they be easier to read if they were quoted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a change here, it is clear now, not sure if there would be a nicer way.

Copy link
Contributor

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

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

Looks good to me.

(I would know what a NullStrategy was, but since the setting to be interacted with is a Ruby Symbol, I'd have to look it up anyway.)

@luke-hill
Copy link
Contributor

@aurelien-reeves so under the hood this sets a few methods. These methods do exist (So they're not none). If these methods didn't exist we'd get an NME.

The OP wanted these methods to deliberately return nil so this is a Blank or Nil Strategy. Because under the hood we change behaviour if people use javascript tags, so we want to amend the transaction methodology

@akostadinov
Copy link
Contributor Author

So what should name be after all? None, Nil, Null or Blank? I have no personal preference. Actually I chose Null initially because this was the suggestion in one stackoverflow post 😄

@luke-hill
Copy link
Contributor

My vote is for either Nil or Null because those correctly identify that the strategy is setting nil values.

@mattwynne
Copy link
Member

mattwynne commented Oct 20, 2021

The strategy is an instance of the Null Object pattern but we don't have to use that name if we don't want to.

IMO the right name for the symbol is :none as that reads nicely, but we could call the type DoesNothing if we wanted to. They don't have to match.

@akostadinov
Copy link
Contributor Author

Due to popular demand, I renamed class back to NullStrategy. And :none as strategy selection makes sense to me to indicate that we use none of the javascript testing strategies. :null also makes sense to be consistent with the class name though. Probably none reads a little better. I have arguments in favor of both options so I can change to whatever project owners want.

@luke-hill , added changelog and updated doc to clarify none and deletion are symbols. I have some other modifications ready that can make the feature useful for whatever tags a project decides to use. I think it's better to submit changes in steps and this is the first step. I want to add information to the readme once I have a review and some agreement about the other changes. Is this ok?

@aurelien-reeves
Copy link
Contributor

Once again, it looks good to me, once again, thanks a lot @akostadinov

And, once again, I prefer to wait for other review before merging 😅

@akostadinov
Copy link
Contributor Author

Guys, can we merge in case of no objections?

@luke-hill luke-hill merged commit 66434a2 into cucumber:main Nov 8, 2021
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.

None yet

5 participants