# Testing for a a new file using Rspec

**URL:** <https://www.ruby-forum.com/t/testing-for-a-a-new-file-using-rspec/161406>\
**Category:** Rails\
**Created:** [February 26, 2009, 9:33am UTC](https://www.ruby-forum.com/t/testing-for-a-a-new-file-using-rspec/161406 "2009-02-26T09:33:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beriahotep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e8cbc/32.png) [@Beriahotep](https://www.ruby-forum.com/u/Beriahotep)\
**Post date:** [February 26, 2009, 9:33am UTC](https://www.ruby-forum.com/t/testing-for-a-a-new-file-using-rspec/161406/1 "2009-02-26T09:33:00Z")

</div>

Hi,

I am new to Rspec so i am not sure if this can be done. I want to  
write a test that the outcome of a function is that a new file is  
successfully created in a directory. The test would be somthing like  
“it should save the xml to a file in /path/foo”.

Can this be done? If so how is it done? (I am guessing it would be a  
clause in the “after” method.

Regards,  
Beriahotep

---

<div class="post-metadata">

**Author:** ![Beriahotep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e8cbc/32.png) [@Beriahotep](https://www.ruby-forum.com/u/Beriahotep)\
**Post date:** [February 26, 2009, 1:38pm UTC](https://www.ruby-forum.com/t/testing-for-a-a-new-file-using-rspec/161406/2 "2009-02-26T13:38:30Z")

</div>

Beriahotep wrote:

> Hi,
> 
> I am new to Rspec so i am not sure if this can be done. I want to  
> write a test that the outcome of a function is that a new file is  
> successfully created in a directory. The test would be somthing like  
> “it should save the xml to a file in /path/foo”.
> 
> Can this be done? If so how is it done? (I am guessing it would be a  
> clause in the “after” method.

It’s not what you’re searching for, but can be a start line. 🙂

> **[How to test file uploads with Cucumber](https://cassiomarques.wordpress.com/2009/01/23/how-to-test-file-uploads-with-cucumber/)**
>
> In a previous article (in portuguese, but you can always use Google Translate to take a look at it) I showed how to use Cucumber to create functional tests for your web applications. Today I’…

Hth,

Davi V.
