Problem running tests of helpers

I’m in the process of upgrading from ruby 1.8.7 to ruby-1.9.2-p18 and
from
rails 2.3.8 to rails 2.3.9 and my tests of helpers have stopped working,
for
example script/spec spec/helpers/application_helper_spec.rb (Full
sample
shown below.)

The output is below. The problem occurs in helper_example_group.rb when
trying
@controller.request = @request

I have not been able to figure out why @controller is nil.

A minimal rails project that reproduces the problem is available at
https://github.com/whenceforth/Helper-Test-Fail-Project

I’m using bundler.

script/spec --version
rspec 1.3.1

which ruby
/Users/art/.rvm/rubies/ruby-1.9.2-p180/bin/ruby

Thanks in advance for any pointers.

Art

begin Gemfile

source :rubygems

gem ‘mysql’, ‘2.8.1’

gem ‘rails’, ‘2.3.11’

gem ‘rspec’, ‘1.3.1’
gem ‘rspec-rails’, ‘1.3.3’
gem ‘test-unit’, ‘1.2.3’

end Gemfile

art-imac-3:Helper-Test-Fail-Project art$ script/spec --backtrace
spec/helpers/application_helper_spec.rb
F

NoMethodError in ‘ApplicationHelper#app_echo should echo’
undefined method request=' for nil:NilClass /Users/art/.rvm/gems/[email protected]/gems/activesupport-2.3.11/lib/active_support/whiny_nil.rb:52:inmethod_missing’
/Users/art/.rvm/gems/[email protected]/gems/rspec-rails-1.3.3/lib/spec/rails/example/helper_example_group.rb:113:in
block in <class:HelperExampleGroup>' /Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/example/example_methods.rb:74:ininstance_eval’
/Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/example/example_methods.rb:74:in
block in eval_each_fail_fast' /Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/example/example_methods.rb:74:ineach’
/Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/example/example_methods.rb:74:in
eval_each_fail_fast' /Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/example/example_group_hierarchy.rb:17:inrun_before_each’
/Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/example/example_methods.rb:107:in
run_before_each' /Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/example/example_methods.rb:128:inbefore_each_example’
/Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/example/example_methods.rb:39:in
block in execute' /Users/art/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:44:intimeout’
/Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/example/example_methods.rb:37:in
execute' /Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/example/example_group_methods.rb:219:inblock in run_examples’
/Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/example/example_group_methods.rb:217:in
each' /Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/example/example_group_methods.rb:217:inrun_examples’
/Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/example/example_group_methods.rb:103:in
run' /Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/runner/example_group_runner.rb:23:inblock in run’
/Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/runner/example_group_runner.rb:22:in
each' /Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/runner/example_group_runner.rb:22:inrun’
/Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/runner/options.rb:153:in
run_examples' /Users/art/.rvm/gems/[email protected]/gems/rspec-1.3.1/lib/spec/runner/command_line.rb:9:inrun’
script/spec:5:in `’

Finished in 0.02259 seconds

1 example, 1 failure

Did you ever find a work-around? My Helper Specs are broken in Ruby
1.9.2, Rails 2.3.14, but fine in Ruby 1.8.7.

I get

undefined method `response=’ for nil:NilClass

The nil class is @controller.

Been pulling my hair out on this. I’ve been searching the 'net for this
problem, but finding almost nothing. (Makes me wonder if people are
testing their helper methods :wink:

Jamie

On Dec 13, 2011, at 6:39 PM, Jamie Orchard-hays wrote:

problem, but finding almost nothing. (Makes me wonder if people are
testing their helper methods :wink:

Jamie

Jamie,

Many people interact with this list by way of email and it’s much easier
on them if you quote the message when responding. If you don’t, we don’t
have the context and have no idea what you might be asking. I had to go
to the web forum to see what it was you were inquiring about.

I emailed Art directly a few months ago to ask if he found a solution,
and this was his reply:

On 2011-09-07 12:49 AM, Art Peel wrote:

Hi Phillip,

Yes, I did. The problem turned out to be related to bundler. The easiest
solution is to run “bundle exec spec” instead of just “spec”.

Another solution is to install the bundler binstubs as described at
http://gembundler.com/ and then run “bin/spec” instead of just “spec”

Hope this helps.

– Art

This was what worked for Art, but it was unrelated to my experience with
the problem (I wasn’t using bundler at the time). Unfortunately, I don’t
recall how I resolved it. So this may work for you, and it may not.

Peace.

Hey Phillip, thanks for the information and sorry about not quoting.
I’ll have a go at this.

Much appreciated,

Jamie

Phillip K. wrote in post #1036638:

On Dec 13, 2011, at 6:39 PM, Jamie Orchard-hays wrote:

problem, but finding almost nothing. (Makes me wonder if people are
testing their helper methods :wink:

Jamie

Jamie,

Many people interact with this list by way of email and it’s much easier
on them if you quote the message when responding. If you don’t, we don’t
have the context and have no idea what you might be asking. I had to go
to the web forum to see what it was you were inquiring about.

I emailed Art directly a few months ago to ask if he found a solution,
and this was his reply:

On 2011-09-07 12:49 AM, Art Peel wrote:

Hi Phillip,

Yes, I did. The problem turned out to be related to bundler. The easiest
solution is to run “bundle exec spec” instead of just “spec”.

Another solution is to install the bundler binstubs as described at
http://gembundler.com/ and then run “bin/spec” instead of just “spec”

Hope this helps.

– Art

This was what worked for Art, but it was unrelated to my experience with
the problem (I wasn’t using bundler at the time). Unfortunately, I don’t
recall how I resolved it. So this may work for you, and it may not.

Peace.

I’m not using bundler either. If you happen to recall your solution, I’d
love to read about it.

Rather vexing, to say the least.

I emailed Art directly a few months ago to ask if he found a solution,
and this was his reply:

On 2011-09-07 12:49 AM, Art Peel wrote:

Hi Phillip,

Yes, I did. The problem turned out to be related to bundler. The easiest
solution is to run “bundle exec spec” instead of just “spec”.

Another solution is to install the bundler binstubs as described at
http://gembundler.com/ and then run “bin/spec” instead of just “spec”

Hope this helps.

– Art

This was what worked for Art, but it was unrelated to my experience with
the problem (I wasn’t using bundler at the time). Unfortunately, I don’t
recall how I resolved it. So this may work for you, and it may not.

Peace.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs