Ah if you want to build something programmatic, you can use the configuration object.
See: http://rspec.info/documentation/3.9/rspec-core/RSpec/Core/Configuration.html#files_to_run-instance_method You could use that to configure rspec to run a certain files contents e.g: ``` RSpec.configure do |config| filename = File.expand_path('../files.txt', __dir__) if File.exist?(filename) specs = File.read(filename).split("\n") puts "Loading #{specs.size} spec files from files.txt" config.files_to_run = specs end end ``` Cheers Jon Rowe --------------------------- [email protected] jonrowe.co.uk On 9 April 2020 at 11:02, Eric Kessler wrote: > On Thursday, April 9, 2020 at 2:44:17 AM UTC-7, Jon Rowe wrote: > > RSpec does not have this built in, but you don’t need it to be in order to > > achieve this, here is how to do that from a linux command line. > > > > `rspec $(cat your_file.txt)` > > > That is a straightforward way of building a command line, yes, and I could > certainly build such a command in pure Ruby (which would be my preference > because I need cross-platform compatibility) before handing it off to > whatever child process I need to execute it. However, I am cautious of that > kind of approach because surely there is some practical limitation to how > long a command can be. Yes, the internal test runner can easily iterate over > an array that has a million or so entries but won't the Linux/Windows/OSX > terminal that I have to feed the initial rspec command into complain about > the command length at some point? > > I'm looking for a general and reliable solution so that I don't have to worry > about losing tests if the command gets cut short or have to come up with a > new approach if the terminal errors out on the input or something. Currently, > my alternative idea would be to build a string containing Ruby code that > sucks in the file as an array and then hands that array to the RSpec test > runner to execute. It isn't as elegant but I'm at least pretty certain that > it will consistently work. > > > Eric K > -- You received this message because you are subscribed to the Google Groups "rspec" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/dejalu-217-d5ea0337-67d4-4273-bbae-e6d7cb023f09%40jonrowe.co.uk.
