ActiveRecord/Supporty-4.1, undefined method `assertions'

26 views
Skip to first unread message

byrnejb

unread,
Jul 29, 2014, 3:53:58 PM7/29/14
to rubyonra...@googlegroups.com
If there is a list devoted to ActiveRecord problems then I would appreciate a redirect.  In the absence of same I need some assistance with part of RoRs stack, namely ActiveRecord and the testing thereof.  I have a cli project which only uses AR-4.0 and whatever other stuff that gem pulls in. I am trialing the project witjh AR-4.1 and I am getting this error when I try to run my cucumber features:

     
undefined method `assertions' for #<String:0x00000003ba4688> (NoMethodError)
      /home/byrnejb/Projects/Software/theHeart/code/hll_th_cadex_xfer/libexec/bundler/ruby/2.1.0/gems/rspec-expectations-3.0.3/lib/rspec/matchers.rb:902:in `
method_missing'
      /home/byrnejb/Projects/Software/theHeart/code/hll_th_cadex_xfer/libexec/bundler/ruby/2.1.0/gems/minitest-5.4.0/lib/minitest/assertions.rb:126:in `assert'

     
/usr/lib64/ruby/2.1.0/test/unit/assertions.rb:36:in `assert'
      /home/byrnejb/Projects/Software/theHeart/code/hll_th_cadex_xfer/features/step_definitions/hll_dbms_steps.rb:15:in `
find_table_model_for'
      /home/byrnejb/Projects/Software/theHeart/code/hll_th_cadex_xfer/features/step_definitions/hll_dbms_steps.rb:30:in `block in <top (required)>'


I googled for this and found a couple of tangential references relating to a change in minitest. However, the fix appears to be somewhat dated and in any case this is not a full RoR stack so rspec-rails is not applicable.


https://stackoverflow.com/questions/16867707/rails-4-and-rspec-undefined-method-assertions-in-routing-spec

This problem is caused by a change in minitest 5.0 documented here:
# https://github.com/seattlerb/minitest/issues/286
is fixed by using: gem "rspec-rails", '~> 2.14.0.rc1'
in the gemfile.

Researching this further indicates that setting the version of minitest to ~> 4.0 would fix the problem but alas, AR-4.1 requires minitest-5.1 +

Bundler could not find compatible versions for gem "minitest":
 
In Gemfile:
    minitest
(~> 4.0) ruby

    hll_th_cadex_xfer
(>= 0) ruby depends on
      activerecord
(>= 0) ruby depends on
        activesupport
(= 4.1.4) ruby depends on
          minitest
(5.1.0)

Which raises the question as to why, exactly, using an ORM gem demands that one install a particular testing framework that one may have no other use for.   I do not use Rspec either but Aruba pulls that in and, as Aruba is a testing framework, I have to accept that.  But an ORM?

In any case, is there a way around this?

Matt Jones

unread,
Jul 30, 2014, 10:42:52 AM7/30/14
to rubyonra...@googlegroups.com


On Tuesday, 29 July 2014 15:53:58 UTC-4, byrnejb wrote:
If there is a list devoted to ActiveRecord problems then I would appreciate a redirect.  In the absence of same I need some assistance with part of RoRs stack, namely ActiveRecord and the testing thereof.  I have a cli project which only uses AR-4.0 and whatever other stuff that gem pulls in. I am trialing the project witjh AR-4.1 and I am getting this error when I try to run my cucumber features:

     
undefined method `assertions' for #<String:0x00000003ba4688> (NoMethodError)
      /home/byrnejb/Projects/Software/theHeart/code/hll_th_cadex_xfer/libexec/bundler/ruby/2.1.0/gems/rspec-expectations-3.0.3/lib/rspec/matchers.rb:902:in `
method_missing'
      /home/byrnejb/Projects/Software/theHeart/code/hll_th_cadex_xfer/libexec/bundler/ruby/2.1.0/gems/minitest-5.4.0/lib/minitest/assertions.rb:126:in `assert'

     
/usr/lib64/ruby/2.1.0/test/unit/assertions.rb:36:in `assert'
      /home/byrnejb/Projects/Software/theHeart/code/hll_th_cadex_xfer/features/step_definitions/hll_dbms_steps.rb:15:in `
find_table_model_for'
      /home/byrnejb/Projects/Software/theHeart/code/hll_th_cadex_xfer/features/step_definitions/hll_dbms_steps.rb:30:in `block in <top (required)>'


I googled for this and found a couple of tangential references relating to a change in minitest. However, the fix appears to be somewhat dated and in any case this is not a full RoR stack so rspec-rails is not applicable.


https://stackoverflow.com/questions/16867707/rails-4-and-rspec-undefined-method-assertions-in-routing-spec

This problem is caused by a change in minitest 5.0 documented here:
# https://github.com/seattlerb/minitest/issues/286
is fixed by using: gem "rspec-rails", '~> 2.14.0.rc1'
in the gemfile.



The underlying issue is mentioned here in Minitest:


Whatever is including the `assert` functions needs to also define the `assertions` accessor.

Hard to advise further without seeing the relevant code in hll_dbms_steps.rb.

--Matt Jones 

James B. Byrne

unread,
Jul 30, 2014, 12:57:52 PM7/30/14
to rubyonra...@googlegroups.com

On Wed, July 30, 2014 10:42, Matt Jones wrote:
> The underlying issue is mentioned here in Minitest:
>
> https://github.com/seattlerb/minitest/blob/master/lib/minitest/assertions.rb#L8-L12
>
> Whatever is including the `assert` functions needs to also define the
> `assertions` accessor.
>
> Hard to advise further without seeing the relevant code in
> hll_dbms_steps.rb.
>

The relevant code seems to be:

<pre>
# features/step_definitions/hll_dbms_steps.rb

def find_table_model_for( tname )
tname = tname.gsub(/ +/,"_").downcase.singularize.camelcase
expected = true
actual = defined?( tname )
message = "Expected #{tname} model class but it is not defined"
assert( ( expected == actual ), message )
end

When /should have (?:a|the) table (?:name|call)ed "?(\w+)"?/ do |tname|
find_table_model_for( tname )
end
</pre>

--
*** E-Mail is NOT a SECURE channel ***
James B. Byrne mailto:Byr...@Harte-Lyne.ca
Harte & Lyne Limited http://www.harte-lyne.ca
9 Brockley Drive vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada L8E 3C3

James B. Byrne

unread,
Jul 30, 2014, 4:43:58 PM7/30/14
to rubyonra...@googlegroups.com
For now we seem to worked around this problem by specifying the following code
in a cucumber support file:

require 'minitest/autorun'
require 'test/unit/assertions'

World( Test::Unit::Assertions )

require 'minitest'
module Minitest
attr_accessor :assertions
end


At least, things are no longer blowing up as soon as the feature run starts.
It is yet to be determined whether this is a real fix as we have run into some
other issues with AR-4.1 vis a vis code that runs fine with AR-4.0.
Reply all
Reply to author
Forward
0 new messages