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

Fix problem with tests declared with nonalphanumeric characters in their name #1684

Closed
wants to merge 1 commit into from

Conversation

derekcroft
Copy link

If I define my unit tests declaratively and use characters that are not alphanumeric, the Declarative module tries to generate a test method with an invalid name. For example:

test "method's return value" do

something

end

Generates a test method called "s_return_value". This sucks when the tests run (especially in an IDE) because the test name displayed doesn't make any sense. It also leads to some tricky bugs. If I have another test method in the same suite like this:

test "other method's return value" do

something

end

The Declarative module has now blown away the first test method without telling me. Gross.

This change MIME-encodes any nonprintable characters in the test method name, avoiding this issue.

…cters. Avoid the situation where a test method name drops everything before invalid Ruby method character.
@pixeltrix
Copy link
Contributor

Firstly I'm pretty sure that Declarative would raise on a duplicate test name and secondly why not use parameterize and underscore?

>> "method's return value".parameterize.underscore
=> "method_s_return_value"

Also you would need to write some tests.

@pixeltrix pixeltrix closed this Jun 14, 2011
jake3030 pushed a commit to jake3030/rails that referenced this pull request Jun 28, 2011
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

2 participants