Hi,
Many moons ago I wrote this blog entry...
http://blog.wolfman.com/articles/2007/07/14/using-rspec-to-test-haml-helpers
I just upgraded that rails project to use rspec 1.1.4 and associated
rspec_rails.
It seems that my helper when called from the helper specs no longer are able to access flash,
controller etc as they did before.
I already prepended all helper calls with helper. so I fixed those changes, but I have been unable
to figure out how to access flash etc...
Here is a simplified example...
in ApplicationHelper.rb
def test_flash
for name in [:notice, :warning, :error]
if flash[name]
return "#{flash[name]}"
end
end
nil
end
In my rails/spec/helpers/application_helper_spec.rb
require File.dirname(__FILE__) + '/../spec_helper'
describe ApplicationHelper do
it "should test flash" do
for name in [:notice, :warning, :error]
flash[name]= "flash #{name.to_s} message"
helper.test_flash.should match(/.*#{name}.*/)
flash[name]= nil
end
end
end
I get this error trace...
1)
NoMethodError in 'ApplicationHelper should test flash'
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
/.../app/helpers/application_helper.rb:23:in `test_flash'
...
flash is nil, this used to work, so what is the new magic incantation to get
this to work again?
Thanks
--
Jim Morris, http://blog.wolfman.com
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users