On 18 Jul 2013, at 12:23, Ian Moss <[email protected]> wrote: > Given that the ActiveAdmin 'controller' method 'export' exports a csv > and it has been called in a http request, > And I'm using TestUnit > As A Developer, I want to assert that the file 'export.txt' is created > and sent as a http response > > I guess it must create a tmp file somewhere, but I've not found that to > be the case yet. > > For reference: http://www.activeadmin.info/docs/4-csv-format.html
It sounds like the way you're trying to test this is way outside the domain model of your app. I can think of two relatively sane ways to test this: A: Given I have these interesting entities [database rows]… When I export the CSV Then I get these rows… Given I have these interesting entities [database rows]… When I send the emails Then these emails are sent… B: Given I have this CSV… When I process it for email sending Then these emails are sent… Approach A is probably preferable, IMO, because I can't see a reason why your email distribution should depend on the CSV preparation in ActiveAdmin, *unless that is the point*. (If so, why?) Active Admin doesn't necessarily prepare a temp CSV file on disk, it might do it in memory and sent the content disposition to download for the browser. If so, and you want approach B, you'll need to save it yourself. My experience of testing Active Admin is that adds enough to the Rails boot time that you might as well restart your machine between tests. You'll probably be grateful for something faster if you can test this closer to the centre of your app than the Active Admin UI. I think you were trying to write a meta-test above, but it sounds like an XY problem[1] - fortunately we saw the previous email which gave a bit more context. It might help to stop, sit somewhere cool - if possible :) - and determine what behaviour you want from the app, rather than thinking in terms of the existing feature implementations / technical infrastructure. Who cares about getting what information, and why? HTH Ash [1] http://meta.stackoverflow.com/questions/66377/what-is-the-xy-problem -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashmoran -- You received this message because you are subscribed to the Google Groups "NWRUG" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nwrug-members. For more options, visit https://groups.google.com/groups/opt_out.
