Forum: RSpec Matcher for testing file content.

Posted by Jarl Friis (Guest)
on 2011-12-20 12:28
(Received via mailing list)
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
Posted by Michael Guterl (mguterl)
on 2011-12-20 13:49
(Received via mailing list)
On Tue, Dec 20, 2011 at 5:51 AM, Jarl Friis <jarl@softace.dk> wrote:
> 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
Posted by Jarl Friis (Guest)
on 2011-12-20 15:10
(Received via mailing list)
Yes, that certainly did the trick...
I use

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

Thanks.


2011/12/20 Michael Guterl <mguterl@gmail.com>:
>>
> 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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.