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

Shoulda context is incompatible with minitest-focus #52

Closed
oasisweng opened this issue Apr 29, 2016 · 3 comments
Closed

Shoulda context is incompatible with minitest-focus #52

oasisweng opened this issue Apr 29, 2016 · 3 comments

Comments

@oasisweng
Copy link

When I apply focus to a method that is encapsulated inside shoulda-context. It always only executes the first method within the context, despite me focusing on the second method.

require 'test_helper'

class StaffsControllerTest < ActionController::TestCase
  context "ab" do

    should "a" do
      flunk "a"
    end

    focus
    should "b" do
      flunk "b"
    end 
  end
end

I hope this can replicate the issue.

@ivantsepp
Copy link

I ran into the same issue and when I dove in, I realize it's because shoulda-context is defining these test methods in a weird order and dynamically. I have this patch that achieved what I needed to run a single test. Hope it can be useful to you!

https://gist.github.com/ivantsepp/bbf6cc4f1373295a79583fd45878f7d2

@mcmire
Copy link
Collaborator

mcmire commented Feb 23, 2019

Hey there, just revisiting old issues and seeing whether they are still relevant. As @ivantsepp mentioned, the way that Shoulda Context works is that when you use context, it will store all of the tests that need to be defined and then define them once it evaluates the block. Therefore, if you use focus it doesn't know which method to apply that to. If it defined methods immediately instead, then this might work, but unfortunately that would require going into the gem and rearchitecting how it works. I'm not sure how long that will take, but I'll keep this open in the meantime.

@mcmire
Copy link
Collaborator

mcmire commented Jan 16, 2020

I'm going to close this issue. If someone wants to take a crack at this and submit a PR then that's cool, but as mentioned this is not a trivial task and it doesn't seem to be a popular want.

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

No branches or pull requests

3 participants