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

Improve ignore_patterns behavior for method removals #1398

Closed
dgollahon opened this issue Aug 3, 2023 · 1 comment
Closed

Improve ignore_patterns behavior for method removals #1398

dgollahon opened this issue Aug 3, 2023 · 1 comment

Comments

@dgollahon
Copy link
Collaborator

dgollahon commented Aug 3, 2023

Motivating example: there are some cases where I pass an object to an API I don't control. In those cases I sometimes freeze the object first and generally am happy to do "unnecessary" freezing of objects. In some cases it's easy to write a test where the result of something is frozen but in cases where the object is passed into a different method and the result is a new object it's not possible to assert that something received #freeze or is frozen.

It might be reasonable to generally not try to delete #freeze (although you lose the ability to detect redundant freezes if you care about that) or (what I want with this issue) make the ignore pattern system support ignoring these. I tried adding:

mutation:
  ignore_patterns:
    - send{selector=freeze}

to my .mutant.yml but it did not prevent the removal mutation from applying.

Here is a trivial/contrived example but it shows the problem:

class MutantExample
  def demo
    {}.freeze
  end
end
RSpec.describe MutantExample do
  it 'is a hash' do
    expect(described_class.new.demo).to be_a(Hash)
  end
end

Result of running mutant is one alive mutation:

 def demo
-  {}.freeze
+  {}
 end
mostlyobvious added a commit to RailsEventStore/aggregates that referenced this issue Nov 7, 2023
Would love to have this working, but it is not:

  mutation:
    ignore_patterns:
    - send { selector = fail }
    - send { selector = clone }

mbj/mutant#1398
@mbj
Copy link
Owner

mbj commented Dec 2, 2023

@dgollahon I think this was fixed via #1409.

@mbj mbj closed this as completed Dec 2, 2023
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

2 participants