Am 19.02.2014 23:23, schrieb Benjamin Klotz:
> In the lib folder i got a cli class which handles all cli interaction
> (run, generate, etc). When i try to test my run method in
> command_line_interface_test.rb i had to add a "environment" parameter to
> the lib file, so it doesn't start the specified Rack::Server in the
> Test.
> 
> I think this isn't very clean to edit a Core file so tests can hook into
> it
> Is there a better way to achieve this?

Some vague thoughts (I had no time to look into the source):

I assume the purpose of the `run' method is to start the server,
so what do you want to test if not that a server is started?
Maybe your run method does more than it should (like setup).

- you could move those parts to a different method
  and only test the helper method

- or use a mock for Rack::Server that doesn't really start the server
  (MiniTest::Mock)

- or you might want to try monkey patching Rack::Server
  in your test file


Regards,
Marcus


-- 
GitHub: https://github.com/stomar/
PGP:    0x6B3A101A