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

add minitest framework #846

Merged
merged 5 commits into from
Aug 26, 2024
Merged

add minitest framework #846

merged 5 commits into from
Aug 26, 2024

Conversation

johrstrom
Copy link
Contributor

add minitest framework to begin refactoring from rspec.

Fixes #845

@johrstrom johrstrom closed this Jul 15, 2024
@johrstrom johrstrom reopened this Jul 15, 2024
ashton22305
ashton22305 previously approved these changes Jul 15, 2024
@johrstrom johrstrom mentioned this pull request Jul 15, 2024
1 task
Comment on lines +13 to +15
assert(slurm.respond_to?(:submit))
veryify_keywords(slurm, :submit, [:after, :afterok, :afternotok, :afterany])
verify_args(slurm, :submit, 1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This replaces this line from rspec. Minitest doesn't have the same facility, but I've added some helper methods to do the same.

it { is_expected.to respond_to(:submit).with(1).argument.and_keywords(:after, :afterok, :afternotok, :afterany) }

Comment on lines +18 to +23
def test_submitting_with_hold
slurm = slurm_instance
stub_submit
OodCore::Job::Adapters::Slurm::Batch.any_instance.expects(:submit_string).with(script_content, args: ["-H", "--export", "NONE"], env: {})
slurm.submit(build_script(submit_as_hold: true))
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test replaces this rspec test below, and just reinforces my issue with rspec. Here in mintest we see what I have to stub Open3 because at some point calling submit on an adapter will result in an Open3.capture3 call.

I guess I just like the explicit nature of Minitest. How is rspec stubbing Open3? I guess it doesn't need to? Like somehow calling submit will stop execution once slurm.submit_string is called? There's just a bit too much magic happening, to the point where I'm not really even sure what code is being executed during this test.

context "with :submit_as_hold" do
context "as true" do
before { adapter.submit(build_script(submit_as_hold: true)) }
it { expect(slurm).to have_received(:submit_string).with(content, args: ["-H", "--export", "NONE"], env: {}) }
end

Copy link
Contributor

@Oglopf Oglopf left a comment

Choose a reason for hiding this comment

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

Awesome to see this. I much prefer minitest tests, both reading and writing them.

@johrstrom johrstrom merged commit d8ecfb0 into master Aug 26, 2024
2 checks passed
@johrstrom johrstrom deleted the bootstrap-minitest branch August 26, 2024 17:03
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.

bootstrap minitest
3 participants