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

wrong causes assert_select to fail #28

Open
davidmiani opened this issue Feb 10, 2013 · 1 comment
Open

wrong causes assert_select to fail #28

davidmiani opened this issue Feb 10, 2013 · 1 comment

Comments

@davidmiani
Copy link

I am using rspec with wrong in a rails app. I have the followin in my spec_helper.rb file:

require "wrong/adapters/rspec"
Wrong.config.alias_assert :confirm

However, when I used assert_select, eg:

  assert_select 'tbody > tr', count: 4

I get the error:

RuntimeError: You must pass a block to Wrong's assert and deny methods

The exception is thrown from

~/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.9/lib/action_dispatch/testing/assertions/selector.rb

on line 297:

assert matches.size >= min, message if min

It seems wrong is taking over Test::Unit's assert function, causing the function to crash. The alias_assert also doesn't help, since it just aliases the method - the assert method is still there.

I am currently using the following as a workaround:

obj = Object.new
class << obj
  include Test::Unit::Assertions
end
Wrong::Assert.send(:define_method, :assert) do |*args, &block|
  obj.assert(*args, &block)
end

It works, but it would be nice if a better solution was available.

@alexch
Copy link
Collaborator

alexch commented Feb 10, 2013

assert_select is apparently using Test::Unit but you're only including the rspec adapter. Try requiring the test_unit adapter too and see if that works.

require 'wrong/adapters/test_unit'

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