wrong icon indicating copy to clipboard operation
wrong copied to clipboard

conflicts with minitest in Rails 4 and rspec_rails

Open jjb opened this issue 12 years ago • 6 comments

In Rails 4 with rspec_rails, my assert method is from minitest, not from wrong.

Here's an app demonstrating the problem: https://github.com/jjb/rails_4_rspec_rails_wrong

Here's the relevant commit: https://github.com/jjb/rails_4_rspec_rails_wrong/commit/c59d8f45388dd267f291151d51445770188a7a5a

I tried putting require 'wrong/adapters/minitest' above and below the rspec require in spec_helper, it made no difference.

rspec_rails does all these handy matcher delegations, maybe that contributes to the problem?

I didn't try a pure-rspec experiment. Let me know if you are at a loss and I will try that.

jjb avatar Oct 11 '13 18:10 jjb

@alexch ping

jjb avatar Oct 11 '13 19:10 jjb

Haven't taken the time to make Wrong work with Rails 4 yet... If you can submit a patch (in which all tests pass for all versions) I'd be much obliged. (Ask me if you need help understanding the test suite layout.)

Sent from my iPhone

On Oct 11, 2013, at 2:38 PM, John Bachir [email protected] wrote:

In Rails 4 with rspec_rails, my assert method is from minitest, not from wrong.

rspec_rails does (all these handy matcher delegations)[https://github.com/rspec/rspec-rails#matchers], maybe that contributes to the problem?

— Reply to this email directly or view it on GitHub.

alexch avatar Oct 11 '13 20:10 alexch

Okay, I'll work on a patch. Any ideas for what to explore first? Maybe rails or rspec-rails is somehow including minitest after wrong is included?

I've tried hacking rspec-rails and wrong to just observe the behavior changing and I've come up short. my goal is to make minitest be included in the class last (top of the stack below) so it has precedence, I haven't achieved this yet.

# [1] pry(#<RSpec::Core::ExampleGroup::Nested_1>)> self.class.ancestors
[RSpec::Core::ExampleGroup::Nested_1,
 RSpec::Core::ExampleGroup::Nested_1::LetDefinitions,
 RSpec::Core::ExampleGroup::Nested_1::NamedSubjectPreventSuper,
 FactoryGirl::Syntax::Methods,
 RSpec::Rails::Mocks,
 RSpec::Rails::FixtureSupport,
 ActiveRecord::TestFixtures,
 RSpec::Rails::TestUnitAssertionAdapter,
 RSpec::Rails::MiniTestLifecycleAdapter,
 RSpec::Rails::SetupAndTeardownAdapter,
 RSpec::Core::ExampleGroup,
 RSpec::Matchers,
 RSpec::Core::MockFrameworkAdapter,
 Wrong,
 Wrong::Helpers,
 Wrong::CloseTo,
 Wrong::Eventually,
 Wrong::Capturing,
 Wrong::Rescuing,
 Wrong::Assert,
 RSpec::Core::SharedExampleGroup,
 RSpec::Core::Pending,
 RSpec::Core::Extensions::InstanceEvalWithArgs,
 RSpec::Core::MemoizedHelpers,
 Object,
 Wrong::D,
 ActiveSupport::Dependencies::Loadable,
 JSON::Ext::Generator::GeneratorMethods::Object,
 PP::ObjectMixin,
 Kernel,
 BasicObject]

jjb avatar Oct 12 '13 06:10 jjb

If you can explain why this does not make Wrong overwrite minitests' assert, it would help me understand.

require "spec_helper"
require 'wrong/adapters/rspec'

describe User do
  include Wrong

  it "wrong test", :focus do
    assert{1==2}
  end

jjb avatar Oct 12 '13 06:10 jjb

I suspect this may be partly the cause... /lib/wrong/adapters/rspec.rb#L9-L18

JonRowe avatar Oct 12 '13 10:10 JonRowe

:facepalm: -- simply the number comparison. right under my nose.

i just changed it and wrong does now work in my environment.

i'll work on a pull request-- but it looks like i can't get the test suit to run in master. here's what happens: https://gist.github.com/jjb/6952117

jjb avatar Oct 12 '13 16:10 jjb