-
Notifications
You must be signed in to change notification settings - Fork 244
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
passing --filter="...." correctly escapes the spaces into "%20" and not "+" #595
base: master
Are you sure you want to change the base?
Conversation
…ot "+" Running teaspoon as bundle exec teaspoon -s default --filter="ScenePointers are attached" When using CGI.escape the string "ScenePointers are attached" becomes "ScenePointesr+are+attached" This is then passed as a "grep=ScenePointers+are+attached" into the url In the JS that is running the specs in the browser the value of the grep is used to filter. We move through all the specs and encode their full name with encodeURIComponent The result is encodeURIComponent("ScenePointers are added") 'ScenePointers%20are%20added' This means that on the ruby side we were escaping the space " " in the urls as '+' and on the JS side we were escaping them as "%20". One of these had to change and it seems changing it on the ruby side is the right one. There is no right way to escape. We can use 'addressable' and URI and CGI and ERB. ERB seems to be the most straighforward for this case, it also does not bring a lot of dependencies. Just one - 'cgi'. In the same time there seems to be no method in URI or CGI or 'addressable' gem that would address this
Did you check why the CI isn't happy ? |
I did. It was too much and I could not directly see the connection between the change and the fails. Let me know what you think about the PR. If you think it is in the right direction I could invest some time to understand why the specs fail. |
teaspoon.gemspec
Outdated
s.required_ruby_version = ">= 2.5" | ||
s.add_dependency "railties", ">= 4.2.11" | ||
s.required_ruby_version = ">= 2.4" | ||
s.add_dependency "railties", ">= 3.2.5" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why allowing ruby 2.4 and rails 3.2 ?
# Using ERB::Util.url_encode instead of CGI.escape as CGI.escape will convert | ||
# the space ' ' into a '+' and not into "%20". The JS on the front end expects | ||
# %20 | ||
parts << "grep=#{ERB::Util.url_encode(options[:filter])}" if options[:filter].present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that seems to make sense
you're right failures, seems quite unrelated please have a look at #597 and please rebase once merged adding a test to reproduce the problem you are fixing would be great |
Thanks for the feedback. Now as this makes sense I will think of a spec, rebase and clean up the teaspoon.gemspec |
please update your branch with latest master |
Getting version 1.4.0. of teaspoon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why, but existing test fails.
and I thought you had added a new test for this fix. but I am not seeing it.
Thanks for your contribution.
hopefully it helps keeping Teaspoon alive for Rails 7.x and 8.x future.
PR created against 1.2.2
Running teaspoon as
When using CGI.escape the string "ScenePointers are attached" becomes "ScenePointesr+are+attached" This is then passed as a "grep=ScenePointers+are+attached" into the url
In the JS that is running the specs in the browser the value of the grep is used to filter. We move through all the specs and encode their full name with encodeURIComponent
The result is
This means that on the ruby side we were escaping the space " " in the urls as '+' and on the JS side we were escaping them as "%20". One of these had to change and it seems changing it on the ruby side is the right one.
There is no right way to escape. We can use 'addressable' and URI and CGI and ERB. ERB seems to be the most straightforward for this case, it also does not bring a lot of dependencies. Just one - 'cgi'.
In the same time there seems to be no method in URI or CGI or 'addressable' gem that would address this