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

Use expect() instead of .should #45

Merged
merged 1 commit into from
Feb 21, 2023
Merged

Conversation

ekohl
Copy link
Member

@ekohl ekohl commented Feb 20, 2023

This removes deprecation warnings from the process output.

It also uses eq([]) instead of be_empty since it's easier to debug: the diff is more useful.

Copy link
Member

@smortex smortex left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@deric deric left a comment

Choose a reason for hiding this comment

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

be_false should be replaced by be_nil


# Check for transaction success after, as it's less informative
txn.any_failed?.should_not eq(true)
expect(txn.any_failed?).to be_false
Copy link

Choose a reason for hiding this comment

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

Suggested change
expect(txn.any_failed?).to be_false
expect(txn.any_failed?).to be_nil

againlogs.should eq([]), "expected no change on second run (idempotence check),\n got: #{againlogs.inspect}"
txn_idempotent.any_failed?.should_not eq(true), 'expected no change on second run (idempotence check), got a resource failure'
expect(againlogs).to eq([]), 'expected no change on second run (idempotence check)'
expect(txn_idempotent.any_failed?).to be_false, 'expected no change on second run (idempotence check), got a resource failure'
Copy link

Choose a reason for hiding this comment

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

The check should be comparing to be_nil

Suggested change
expect(txn_idempotent.any_failed?).to be_false, 'expected no change on second run (idempotence check), got a resource failure'
expect(txn_idempotent.any_failed?).to be_nil, 'expected no change on second run (idempotence check), got a resource failure'

@ekohl
Copy link
Member Author

ekohl commented Feb 21, 2023

Interesting. I looked at the implementation (https://github.com/puppetlabs/puppet/blob/aa05e8df814b8a6655b33ebf25c3fe0915c8f0d5/lib/puppet/transaction.rb#L213-L218) and that uses .detect instead of .any?, which really surprised me. Thanks for catching that!

This removes deprecation warnings from the process output.

It also uses eq([]) instead of be_empty since it's easier to debug: the
diff is more useful.
@ekohl ekohl merged commit d3fc567 into voxpupuli:master Feb 21, 2023
@ekohl ekohl deleted the remove-should-style branch February 21, 2023 11:02
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.

4 participants