Wrap the procedural stuff into a giant method call inside a class and have it return from that giant method call after the line that needs to be modified, then you can call the method directly instead of invoking the script, then to test the script all you have to prove is that the method that was unit tested was called.  An example of a loadable and runnable script would be https://github.com/rapid7/pro/blob/develop/ui/script/build/update/update-app.rb.  A summary of this idiom is

```ruby
# in script.rb
# !/usr/bin/env ruby
class Script
  def initialize(*args)
    # parse args
  end
  
  def run!
  end
end

if __FILE__ == $PROGRAM_NAME
  script = Script.new(*ARGV)
  script.run!
end
```

So, in rspec you require 'script' and then can instantiate `Script` with fake args, for each test case, then when normally running the scripts, the `if` at the end will be true and it will run the script normally.