Kevin Olbrich
2009-Mar-31 12:06 UTC
[rspec-users] Getting the file a scenario is defined in (Cucumber)
In Cucumber... Is there a simple way to find out what file a scenario is defined in? I''d like to use this information to load a set of fixtures depending on which feature is being run. So if I''m running the ''login.feature'' file, I''d like to be able to load the set of fixtures under ''/fixtures/login/*.yml'' _Kevin -- Posted via http://www.ruby-forum.com/.
aslak hellesoy
2009-Mar-31 14:06 UTC
[rspec-users] Getting the file a scenario is defined in (Cucumber)
On Tue, Mar 31, 2009 at 2:06 PM, Kevin Olbrich <lists at ruby-forum.com> wrote:> In Cucumber... > Is there a simple way to find out what file a scenario is defined in? >No, but there is a dirty way: Before do |scenario| f = scenario.instance_variable_get(''@feature'') if f puts f.file end end The scenario variable will be a Scnario, ScenarioOutline or ExampleCells instance. In the latter case there is no @feature ivar. Please file a feature request (or better yet - a patch) if you want to see this improved. Also take a look at this ticket - maybe a cleaner way to achieve what you want. https://rspec.lighthouseapp.com/projects/16211/tickets/229-use-hooks-with-tags Aslak> > I''d like to use this information to load a set of fixtures depending on > which feature is being run. So if I''m running the ''login.feature'' file, > I''d like to be able to load the set of fixtures under > ''/fixtures/login/*.yml'' > > _Kevin > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090331/15ef11a8/attachment.html>