[rspec-users] render_to_string in a controller test?

2008-02-18 Thread EAW
Hi all,

I know that in general, view and controller tests should be isolated,  
such that controller specs don't test views etc.  However, I think  
I've run into a situation that might be an exception.

My controller uses render_to_string to produce a chunk of HTML that it  
passes to a model to be processed.

The controller then redirects the user to a different page.  The  
results of the render_to_string are not seen by the user.

Since the controller is calling render_to_string, I've been trying to  
test that it is rendered correctly in my controller spec.  Because a  
controller spec normally doesn't render views, render_to_string just  
returns the path of the view, rather than the rendered output.  This  
prevents me from testing the output of render_to_string in the  
controller spec.

I can work around the issue by using integrate_views, and I guess  
that's fine, but shouldn't render_to_string really work in controllers?

Thanks for your input,

e.
--
[EMAIL PROTECTED]

"If the answer isn't violence, neither is your silence!"
 -- Pop Will Eat Itself, "Ich Bin Ein Auslander"


___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


[rspec-users] description method and test failures

2008-05-13 Thread EAW

Hi all,

Hoping you can help.  I have a project using rspec 1.1.3 and rails  
2.0.2.  I've run into a small problem.  Said project has a method in  
application_helper.rb named "description".  Whenever a spec test  
fails, I see a message like so:


*snip*/vendor/plugins/rspec/lib/spec/runner/reporter.rb:37:in  
`description': wrong number of arguments (0 for 2) (ArgumentError)


It just so happens that my description method takes 2 arguments.  It  
seems that this method is clashing with one of the methods in rspec.   
Is there a workaround for this situation?  It's a pain to have to  
rename my method everytime I want to see a proper failure message from  
rspec.


I'm attaching a full backtrace run with --trace.

Thanks,

e.
--
[EMAIL PROTECTED]

"If the answer isn't violence, neither is your silence!"
-- Pop Will Eat Itself, "Ich Bin Ein Auslander"

** Invoke default (first_time)
** Invoke test (first_time)
** Execute test
** Invoke test:units (first_time)
** Invoke db:test:prepare (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment 
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:clone (first_time)
** Invoke db:schema:dump (first_time)
** Invoke environment 
** Execute db:schema:dump
** Invoke db:test:purge (first_time)
** Invoke environment 
** Execute db:test:purge
** Execute db:test:clone
** Invoke db:schema:load (first_time)
** Invoke environment 
** Execute db:schema:load
** Execute test:units
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -Ilib:test 
"/Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader.rb"  
** Invoke test:functionals (first_time)
** Invoke db:test:prepare 
** Execute test:functionals
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -Ilib:test 
"/Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader.rb"  
** Invoke test:integration (first_time)
** Invoke db:test:prepare 
** Execute test:integration
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -Ilib:test 
"/Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader.rb"  
** Invoke spec (first_time)
** Invoke db:test:prepare 
** Execute spec
................................................................................................................

Finished in 1.104237 seconds

113 examples, 0 failures
*snip*vendor/plugins/rspec/lib/spec/runner/reporter.rb:37:in `description': 
wrong number of arguments (0 for 2) (ArgumentError)
from *snip*vendor/plugins/rspec/lib/spec/runner/reporter.rb:37:in 
`example_failed'
from *snip*vendor/plugins/rspec/lib/spec/runner/reporter.rb:31:in 
`example_finished'
from 
*snip*vendor/plugins/rspec/lib/spec/example/example_methods.rb:30:in `execute'
from 
*snip*vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:292:in 
`execute_examples'
from 
*snip*vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:291:in 
`each'
from 
*snip*vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:291:in 
`execute_examples'
from 
*snip*vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:121:in 
`run'
from 
*snip*vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:22:in `run'
from 
*snip*vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `each'
from 
*snip*vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `run'
from *snip*vendor/plugins/rspec/lib/spec/runner/options.rb:90:in 
`run_examples'
from *snip*vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in 
`run'
from *snip*vendor/plugins/rspec/bin/spec:4
rake aborted!
Command ruby -I"*snip*vendor/plugins/rspec/lib" 
"*snip*vendor/plugins/rspec/bin/spec" 
"spec/controllers/organizations_controller_spec.rb" 
"spec/controllers/people_co

Re: [rspec-users] description method and test failures

2008-05-14 Thread EAW
I followed your advice, with one slight addition.  Inside of my  
describe block I included the ApplicationHelper manually, so that I  
could call the methods in it.  Everything is working fine now.


Thanks for your help.

e.

On May 14, 2008, at 6:44 AM, David Chelimsky wrote:


On Wed, May 14, 2008 at 1:17 AM, EAW <[EMAIL PROTECTED]> wrote:

Hi all,

Hoping you can help.  I have a project using rspec 1.1.3 and rails  
2.0.2.

I've run into a small problem.  Said project has a method in
application_helper.rb named "description".  Whenever a spec test  
fails, I

see a message like so:

*snip*/vendor/plugins/rspec/lib/spec/runner/reporter.rb:37:in
`description': wrong number of arguments (0 for 2) (ArgumentError)

It just so happens that my description method takes 2 arguments.   
It seems
that this method is clashing with one of the methods in rspec.  Is  
there a
workaround for this situation?  It's a pain to have to rename my  
method

everytime I want to see a proper failure message from rspec.

I'm attaching a full backtrace run with --trace.


If the first argument to describe() is a module it gets included in
the resulting example group. To avoid this, just make it a String:

describe 'MyHelperModule' do
...
end

In the next release there is a helper object you can use in your
helper examples:

describe HelperModule do
it "should describe something by default" do
helper.description.should == "something"
end
end

In some future release, that is the only way it will work as we will
no longer include the module in the example group. That might be a way
off though.

Cheers,
David



Thanks,

e.
--
[EMAIL PROTECTED]

"If the answer isn't violence, neither is your silence!"
   -- Pop Will Eat Itself, "Ich Bin Ein Auslander"




___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


--
[EMAIL PROTECTED]

"If the answer isn't violence, neither is your silence!"
-- Pop Will Eat Itself, "Ich Bin Ein Auslander"


___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users