-
Notifications
You must be signed in to change notification settings - Fork 96
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
Adds support for the shoulda-context gem #37
Conversation
@@ -48,7 +48,7 @@ def set_test_helper_path(file_path) | |||
|
|||
def self.test_path(obj) | |||
# Pick the first public method in the class itself, that starts with "test_" | |||
test_method_name = obj.public_methods(false).select{|m| m =~ /^test_/ }.first |
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.
When you use the previous version of the code with /^test_/
then test for shoulda-context still passes. It should fail.
@alexpjohnson I had to revert this PR because it doesn't work and test is false positive. I have here a separate rails app. I added there shoulda-context and I tried to generate report to see if the test file path is detected correctly but it is not. Basically what we would like to achieave here is to have correct test file path in the variable def self.test_path(obj)
# Pick the first public method in the class itself, that starts with "test_"
test_method_name = obj.public_methods(false).select{|m| m =~ /^test(:|_)/ }.first
method_object = obj.method(test_method_name)
full_test_path = method_object.source_location.first
parent_of_test_dir_regexp = Regexp.new("^#{@@parent_of_test_dir}")
test_path = full_test_path.gsub(parent_of_test_dir_regexp, '.')
# test_path will look like ./test/dir/unit_test.rb
test_path
end |
Hey @ArturT, I've done a bit more investigating and it seems the root issue is that shoulda-context is breaking the API established by minitest. By dynamically generating methods, they are losing the original |
@alexpjohnson Thanks for the update. Hope shoulda-context team will have some tips how to determine the path of the test file. Maybe there is another way than using |
@alexpjohnson With your fix in shoulda-context there is no need to do changes in knapsack as all methods generated by shoulda-context have prefix |
Correct. It should all just happen auto-magically :) |
Just wanted to keep you up to date in case any of your other users mentioned it. |
From #32