Re: [rspec-users] Testing render :update

2010-07-06 Thread Jarl Friis
David Chelimsky wrote:
> 
> Looks like action_pack calls render twice (the 2nd time in 
> action_controller/metal/implicit_render.rb:10:in `default_render'), so 
> we've got to stub the :render call twice:
> 
> page = double('page')
> controller.stub(:render)
> controller.stub(:render).with(:update).and_yield(page)
> page.should_receive(:replace_html).with(...)
> 
> Bummer. It seems like this is a rails bug (render should only get called 
> once, and there is code that prevents it from being called twice, but 
> not _all_ of the time), but I'm not sure if I can make that case or not. 
> I'll try :)

Have this problem been reported to the rails project. I am not using 
rspec, but trying to stub away rendering and run into the same 
situation; have to call #expects twice using Mocha framework.

Could it be this ticket:
https://rails.lighthouseapp.com/projects/8994/tickets/2279-render-layout-with-block-and-multiple-yields
-- 
Posted via http://www.ruby-forum.com/.
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


[rspec-users] Matcher for testing file content.

2011-12-20 Thread Jarl Friis
Hi.

Is there any matcher for test file content, anything like

file("/path/to/file.txt").should contain("File content")
or
file("/path/to/file.txt").content.should == "File content"
or
file_content("/path/to/file.txt").should == "File content"

or something else?

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


Re: [rspec-users] Matcher for testing file content.

2011-12-20 Thread Jarl Friis
Yes, that certainly did the trick...
I use

File.read("/path/to/file").should == "content"

Thanks.


2011/12/20 Michael Guterl :
> On Tue, Dec 20, 2011 at 5:51 AM, Jarl Friis  wrote:
>> Hi.
>>
>> Is there any matcher for test file content, anything like
>>
>> file("/path/to/file.txt").should contain("File content")
>> or
>> file("/path/to/file.txt").content.should == "File content"
>> or
>> file_content("/path/to/file.txt").should == "File content"
>>
>> or something else?
>>
> File.read("/path/to/file") will give you a string of the entire
> contents of the file.
>
> File.read("/path/to/file").should match "content"
> File.read("/path/to/file").should include "content"
>
> etc.
>
> Does that help?
>
> Best,
> Michael Guterl
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



-- 
Jarl Friis
Softace ApS
RÄdhustorvet 7, 2.
3520 Farum
LinkedIn: http://dk.linkedin.com/in/jarlfriis
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users