mbj / mutant

Automated code reviews via mutation testing - semantic code coverage.
Other
1.95k stars 153 forks source link

Using it on a Rails app #21

Closed radanskoric closed 10 years ago

radanskoric commented 11 years ago

Is anyone using this on a Rails app?

I'm sure it's possible but I can not find an example or documentation for the mutant command line parameters to figure out what is the correct way to use it on a rails app.

Any help or pointers appreciated.

mockdeep commented 11 years ago

I also had to add a :type => :controller to the specs as well so that I would still have the controller behavior when it's in the unit folder.

dkubb commented 11 years ago

@mockdeep I wonder if there'd be any benefit to build a rails project and check it into git, add a simple model and controller, and then integrate mutant into it?

We could work out any of the rails specific issues first and get a baseline before working on project specific tweaks.

mbj commented 11 years ago

@mockdeep I agree to @dkubb's idea. We need to have something executable. Can you do me the favor and create that sample rails app?

mockdeep commented 11 years ago

Sure, I'll do that. Being that I had it working before I was trying to use the same version of the gem that I was using before, just to reduce differences but was still unable to get it working. I'll make up a new project for us to poke around with.

On Sun, Apr 21, 2013 at 3:24 AM, Markus Schirp notifications@github.comwrote:

@mockdeep https://github.com/mockdeep I agree to @dkubbhttps://github.com/dkubb's idea. We need to have something executable. Can you do me the favor and create that sample rails app?

— Reply to this email directly or view it on GitHubhttps://github.com/mbj/mutant/issues/21#issuecomment-16719420 .

mockdeep commented 11 years ago

Okay, basic rails app here: https://github.com/mockdeep/mutant_rails

Let me know if you want me to add you as collaborators. Right now it's just got a user model. Still getting that PG Error:

  1) User.authenticate when given invalid password returns false
     Failure/Error: Unable to find matching line from backtrace
     PG::Error:
       result has been cleared

The command I'm running is:

be mutant -I lib -d -r ./config/environment.rb -r ./app/models/user.rb --rspec-dm2 ::User

Same result with the latest version of mutant.

mbj commented 11 years ago

@mockdeep thx! I finally made the master branch green again, (only rbx specific issues causing some problems). I think 0.3.0 will have support for rails.

mockdeep commented 11 years ago

Cool, thanks!

On Mon, Apr 22, 2013 at 1:03 AM, Markus Schirp notifications@github.comwrote:

@mockdep thx! I finally made the master branch green again, (only rbx specific issues causing some problems). I think 0.3.0 will have support for rails.

— Reply to this email directly or view it on GitHubhttps://github.com/mbj/mutant/issues/21#issuecomment-16762772 .

mockdeep commented 11 years ago

I pushed a branch with database_cleaner set up and I get a bunch of noop fails on it.

dkubb commented 11 years ago

@mockdeep I need to take a closer look at your rails fork, but just off the top of my head that pg error result has been cleared probably has something to do with how mutant forks off to run the mutation. The pooled database connections probably need to be closed in the forked child, and reopened.

If there's a way to turn off pooling so that connections are opened and closed as needed that might work-around the issue. Alternatively, if this is what the problem is, we may need to update mutant so it provides before_fork and after_fork type hooks to handle things like this.

dkubb commented 11 years ago

@mockdeep ok, I got it working! I used two packages:

It took a bit of messing around with the Gemfile, and Rakefile, then generating a VERSION.yml, and gemspec (for each). Then I updated mutant_rails' Gemfile to use the :path option to refer to them. When I ran the tests everything worked as expected.

Obviously this is not a real solution, but it does highlight that we need to do some cleanup after forking. I've already mentioned my results to @mbj and that we need before_fork and after_fork hooks to do this properly. Ideally we'd configure these things in spec_helper.rb or somewhere mutant specific. I'll leave that to @mbj to decide, but it's encouraging that we actually have an idea what the problem is and ideas for a fix.

mockdeep commented 11 years ago

Wow, that's intense. Hope you don't mind, I just added both of you as contributors on the project. Do you mind pushing up your changes so I can see what you did?

mbj commented 11 years ago

@dkubb I think we'll have a mutant-rails gem that provides some rails specific code out of the box. I'll add infrastructure such as before_fork and after_fork. That can be used for such a gem.

mbj commented 11 years ago

@mockdeep I'd love to NOT maintiain mutant-rails so +1 for your repo. Just because I'm not a "rails" guy at all.

mbj commented 11 years ago

@mockdeep Sorry I just thought: "mockdeep/mutantrails" is the actual "mutant-rails" gem. I should have spotted - vs ``.

mockdeep commented 11 years ago

Ha, well I can't say I put any forethought into the naming, but yeah, it's just an example project. Not sure if I'm very qualified to handle writing the gem myself, but I guess I'd be happy to give it a try, since I really want it to exist.

mbj commented 11 years ago

@mockdeep Just give it a try. And the feedback you'll receive will improve your skills. BTW - is for plugins and _ for connecting two names. So that gem should be named mutant-rails.

mbj commented 11 years ago

@mockdeep Feel free to catch me in #datamapper for any question regarding that gem.

dkubb commented 11 years ago

@mockdeep don't be afraid to ask questions if you get stuck. It only feels daunting when you haven't broken it down yet. Start small. My first commit to datamapper was fixing the file require paths in dm-core ;)

mockdeep commented 11 years ago

Alright, some success! I made gems of ruby_is_forked and rails_is_forked and adding them to the gemfile gets me a successful run! I tried creating a mutant-rails gem that just requires both those and mutant but it appears the require order matters and they get mangled in the process. I'll have to look into it some more. If anybody has any suggestions in the meantime, I'd be glad to hear them.

https://github.com/mockdeep/ruby_is_forked https://github.com/mockdeep/rails_is_forked https://github.com/mockdeep/mutant-rails

mbj commented 11 years ago

@mockdeep IMHO there is no need to fork ruby_is_forked nor rails_is_forked. Both are released gems already. See http://rubygems.org/gems/ruby_is_forked and http://rubygems.org/gems/rails_is_forked .

Apart from your gemfile you should ship a pice of code users can call in their spec/spec_helper.rb that configures the fork callbacks in the correct way.

mockdeep commented 11 years ago

Those are actually the gems I deployed. They weren't on rubygems already, otherwise I would have definitely used them. Turns out it's enough just to include the gems in your gemfile for it to work. Require order is important, though, so the _forked gems need to come before mutant in the gemfile. I'll definitely do some more documentation and make it more robust over time.

mockdeep commented 11 years ago

I'll document a lot of this stuff in the gem, but it appears that it doesn't place nice when transactional fixtures is disabled, so there'll probably need to be an environmental variable set to cope with database_cleaner.

dkubb commented 11 years ago

Another approach could be to use :github => 'mockdeep/rails_is_forked' etc in your Gemfile, rather than releasing the gems.

Do you think we'll need those two gems to properly fork rails inside mutant? Or can we get away with specifying a few things in mutant provided before_fork/after_fork hooks?

mockdeep commented 11 years ago

Is there a reason not to release the gems? I'm happy to do whatever, though right now my priority is to get it working so that I can make use of it.

dkubb commented 11 years ago

@mockdeep nah, I just wondered if the original author would've wanted to release them or not, but I guess it doesn't matter so much.. it's like he got 95% of the way to releasing a gem and then stopped for some reason.

mockdeep commented 11 years ago

Good point. I sent him a message just to check in.

mockdeep commented 11 years ago

Also doesn't seem to play nice with VCR or BeValidAsset.

mockdeep commented 11 years ago

Added some documentation for getting things up and running: https://github.com/mockdeep/mutant-rails

mockdeep commented 11 years ago

So I'm trying to work with the rake script from @dkubb here: https://gist.github.com/dkubb/6ae4bacedb5b7c11615a

I've modified it somewhat and I've been shifting around my code to get things working, but now when I run `rake metrics:mutant I get the stack trace below. As near as I can tell, it seems to be using plain rspec and not rspec-rails. Any ideas?

Mutant configuration:
Matcher:        #<Mutant::Matcher::Scope cache=#<Mutant::Cache> scope=DataRow>
Subject Filter: Mutant::Predicate::CONTRADICTION
Strategy:       #<Mutant::Strategy::Rspec level=0>
You are using WebMock 1.13.0. VCR is known to work with WebMock >= 1.8.0, < 1.12. It may not work with this version.
rake aborted!
undefined local variable or method `render_views' for #<Class:0x00000006ca9508>
/home/fletch/Dropbox/projects/synchroform/spec/unit/controllers/docs_controller_spec.rb:4:in `block in <top (required)>'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/example_group.rb:246:in `module_eval'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/example_group.rb:246:in `subclass'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/example_group.rb:232:in `describe'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/dsl.rb:18:in `describe'
/home/fletch/Dropbox/projects/synchroform/spec/unit/controllers/docs_controller_spec.rb:3:in `<top (required)>'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:245:in `load'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:245:in `block in load'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:245:in `load'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `each'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `load_spec_files'
/home/fletch/mutant/lib/mutant/strategy/rspec.rb:22:in `setup'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/adamantium-0.1.0/lib/adamantium/module_methods.rb:157:in `call'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/adamantium-0.1.0/lib/adamantium/module_methods.rb:157:in `block (2 levels) in define_memoize_method'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/adamantium-0.1.0/lib/adamantium/module_methods.rb:156:in `fetch'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/adamantium-0.1.0/lib/adamantium/module_methods.rb:156:in `block in define_memoize_method'
/home/fletch/mutant/lib/mutant/runner/config.rb:78:in `run_subjects'
/home/fletch/mutant/lib/mutant/runner/config.rb:91:in `run'
/home/fletch/mutant/lib/mutant/runner.rb:76:in `initialize'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/abstract_type-0.0.6/lib/abstract_type.rb:38:in `new'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/abstract_type-0.0.6/lib/abstract_type.rb:38:in `new'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/gems/adamantium-0.1.0/lib/adamantium/class_methods.rb:17:in `new'
/home/fletch/mutant/lib/mutant/runner/config.rb:21:in `run'
/home/fletch/mutant/lib/mutant/cli.rb:28:in `run'
/home/fletch/Dropbox/projects/synchroform/lib/tasks/mutant.rake:29:in `block (2 levels) in <top (required)>'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in `eval'
/home/fletch/.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => metrics:mutant
(See full trace by running task with --trace)
mockdeep commented 11 years ago

I wrote a crappy little script to help convert specs over to the dm2 style: https://gist.github.com/mockdeep/7051285

Not very robust at the moment.

mbj commented 11 years ago

@mockdeep You dont need to use "dm2-style" anymore. Latest mutant selects tests via rspec description and not file location.

mockdeep commented 11 years ago

I know, but I've found it to be a simpler way of structuring the specs for clarity. It makes it much easier to see at a glance which methods are tested.

c-lliope commented 10 years ago

@mbj I'm getting an error trying to run this on my Rails app. Can you offer advice?

Command:

mutant -r ./config/environment.rb --use rspec '::User'

Result:

WARN: Unresolved specs during Gem::Specification.reset:
      slop (>= 3.4.5, ~> 3.4)
      atomic (< 2, >= 1.1.7)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
Mutant configuration:
Matcher:         #<Mutant::Matcher::Scope cache=#<Mutant::Cache> scope=User (call 'User.connection' to establish a connection)>
Strategy:        #<Mutant::Rspec::Strategy>
Expect Coverage: 100.000000%
Cannot find definition of: User._create_callbacks in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:87
Cannot find definition of: User._save_callbacks in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:87
Cannot find definition of: User._update_callbacks in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:87
Cannot find definition of: User._validate_callbacks in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:87
Cannot find definition of: User._validators in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:87
Cannot find definition of: User.after_add_for_purchases in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:87
Cannot find definition of: User.after_add_for_purchases= in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:84
Cannot find definition of: User.after_add_for_purchases? in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:80
Cannot find definition of: User.after_add_for_rewards in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:87
Cannot find definition of: User.after_add_for_rewards= in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:84
Cannot find definition of: User.after_add_for_rewards? in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:80
Cannot find definition of: User.after_remove_for_purchases in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:87
Cannot find definition of: User.after_remove_for_purchases= in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:84
Cannot find definition of: User.after_remove_for_purchases? in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:80
Cannot find definition of: User.after_remove_for_rewards in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:87
Cannot find definition of: User.after_remove_for_rewards= in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:84
Cannot find definition of: User.after_remove_for_rewards? in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:80
Cannot find definition of: User.before_add_for_purchases in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:87
Cannot find definition of: User.before_add_for_purchases= in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:84
Cannot find definition of: User.before_add_for_purchases? in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:80
Cannot find definition of: User.before_add_for_rewards in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:87
Cannot find definition of: User.before_add_for_rewards= in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:84
Cannot find definition of: User.before_add_for_rewards? in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:80
Cannot find definition of: User.before_remove_for_purchases in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:87
Cannot find definition of: User.before_remove_for_purchases= in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:84
Cannot find definition of: User.before_remove_for_purchases? in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:80
Cannot find definition of: User.before_remove_for_rewards in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:87
Cannot find definition of: User.before_remove_for_rewards= in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:84
Cannot find definition of: User.before_remove_for_rewards? in /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/core_ext/class/attribute.rb:80
Cannot find definition of: User.confirmed in /Users/grayson/.gem/ruby/2.1.0/gems/activerecord-4.0.4/lib/active_record/scoping/named.rb:161
User.find_by_identifier:/Users/grayson/dev/carbon/app/models/user.rb:104
/Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:223:in `load': cannot load such file -- /Users/grayson/dev/carbon/::User (LoadError)
    from /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:223:in `block in load'
    from /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /Users/grayson/.gem/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:223:in `load'
    from /Users/grayson/.gem/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
    from /Users/grayson/.gem/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `each'
    from /Users/grayson/.gem/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `load_spec_files'
    from /Users/grayson/.gem/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/grayson/.gem/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:80:in `run'
    from /Users/grayson/.gem/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:17:in `block in autorun'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/killer/forked.rb:35:in `fork'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/killer/forked.rb:35:in `run'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/killer.rb:36:in `initialize'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/killer/forked.rb:19:in `initialize'
    from /Users/grayson/.gem/ruby/2.1.0/gems/adamantium-0.2.0/lib/adamantium/class_methods.rb:17:in `new'
    from /Users/grayson/.gem/ruby/2.1.0/gems/adamantium-0.2.0/lib/adamantium/class_methods.rb:17:in `new'
    from /Users/grayson/.gem/ruby/2.1.0/gems/abstract_type-0.0.7/lib/abstract_type.rb:37:in `block in create_new_method'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/killer/forking.rb:41:in `new'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/strategy.rb:66:in `kill'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner/mutation.rb:64:in `run'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner.rb:76:in `initialize'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner/mutation.rb:38:in `initialize'
    from /Users/grayson/.gem/ruby/2.1.0/gems/adamantium-0.2.0/lib/adamantium/class_methods.rb:17:in `new'
    from /Users/grayson/.gem/ruby/2.1.0/gems/adamantium-0.2.0/lib/adamantium/class_methods.rb:17:in `new'
    from /Users/grayson/.gem/ruby/2.1.0/gems/abstract_type-0.0.7/lib/abstract_type.rb:37:in `block in create_new_method'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner.rb:53:in `run'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner.rb:174:in `visit'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner.rb:157:in `block in dispatch'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner.rb:156:in `each'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner.rb:156:in `dispatch'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner/subject.rb:77:in `run'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner.rb:76:in `initialize'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner/subject.rb:30:in `initialize'
    from /Users/grayson/.gem/ruby/2.1.0/gems/adamantium-0.2.0/lib/adamantium/class_methods.rb:17:in `new'
    from /Users/grayson/.gem/ruby/2.1.0/gems/adamantium-0.2.0/lib/adamantium/class_methods.rb:17:in `new'
    from /Users/grayson/.gem/ruby/2.1.0/gems/abstract_type-0.0.7/lib/abstract_type.rb:37:in `block in create_new_method'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner.rb:53:in `run'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner.rb:174:in `visit'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner.rb:157:in `block in dispatch'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/matcher/methods.rb:65:in `block in emit_matches'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/matcher/method.rb:29:in `each'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/matcher/methods.rb:64:in `emit_matches'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/matcher/methods.rb:23:in `block in each'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/matcher/methods.rb:22:in `each'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/matcher/methods.rb:22:in `each'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/matcher.rb:23:in `each'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/matcher/scope.rb:28:in `block in each'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/matcher/scope.rb:27:in `each'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/matcher/scope.rb:27:in `each'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/config.rb:31:in `subjects'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner.rb:156:in `each'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner.rb:156:in `dispatch'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner/config.rb:125:in `run_subjects'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner/config.rb:137:in `run'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner.rb:76:in `initialize'
    from /Users/grayson/.gem/ruby/2.1.0/gems/adamantium-0.2.0/lib/adamantium/class_methods.rb:17:in `new'
    from /Users/grayson/.gem/ruby/2.1.0/gems/adamantium-0.2.0/lib/adamantium/class_methods.rb:17:in `new'
    from /Users/grayson/.gem/ruby/2.1.0/gems/abstract_type-0.0.7/lib/abstract_type.rb:37:in `block in create_new_method'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/runner/config.rb:21:in `run'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/lib/mutant/cli.rb:28:in `run'
    from /Users/grayson/.gem/ruby/2.1.0/gems/mutant-0.5.11/bin/mutant:19:in `<top (required)>'
    from /Users/grayson/.gem/ruby/2.1.0/bin/mutant:23:in `load'
    from /Users/grayson/.gem/ruby/2.1.0/bin/mutant:23:in `<main>'
F^C
Exiting... Interrupt again to exit immediately.

Thanks for your help!

mbj commented 10 years ago

@graysonwright Looks like an indeterministic automatic context loading thing from rails. I have no idea how to debug it currently.

mbj commented 10 years ago

@graysonwright Can you come up with an example public minimal rails app we can use for integration testing. I'd love to ship with official rails support in future. And having a minimal reproduction will allow me to track it down.

c-lliope commented 10 years ago

Sure thing, I'll work on it and let you know.

mbj commented 10 years ago

@graysonwright Thx. My OSS time budget is very limited these days. I appreciate any help.

mbj commented 10 years ago

The general answer on how to run mutant against a rails project is now covered in a README section. I'm gonna close this issue as the global "how to run against rails" is now documented.

Feel free to open separate issues for issues with your projects.

mbj commented 1 year ago

Mutant now has worker process start hooks that can be used to setup a per worker process test DB isolating tests run in concurrency from each other: https://github.com/mbj/mutant/pull/1379

mbj commented 11 months ago

This will get you far, but there are more considerations about DB concurrency etc.

RAILS_ENV=test bundle exec mutant --require ./config/application --jobs 1 -- descendants:ApplicationController descendants:ActiveRecord::Base