Rails overwrite test_helper's configuration when running test

11 views
Skip to first unread message

Gastón Ba

unread,
Mar 7, 2017, 3:47:09 PM3/7/17
to guard-dev
Hi

I want to overwrite some configurations only when running test with guard. 

Example, lets say I run test manually, on server host_a, now suppose I want capybara to run on a different server when running test with guard, this is my current test_helper:

Capybara.configure do |config| 
    Capybara.server_host='host_a'
    Capybara.server_port = '4000'
end

How can I configure guard to overwrite this configurations? I still want host_a as my default on my manual tests.


Rémy Coutable

unread,
Mar 7, 2017, 4:32:57 PM3/7/17
to guar...@googlegroups.com
Hi,

You can probably set an environment variable in your `Guardfile` and use it in your `test_helper.rb`, e.g.: `Capybara.server_host = ENV['guard'] == 'true' ? 'host_b' : 'host_a'`

– Rémy

--
You received this message because you are subscribed to the Google Groups "guard-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guard-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gastón Ba

unread,
Mar 9, 2017, 6:17:56 PM3/9/17
to guard-dev
Hello,

I defined a callback,  callback(:start_begin) { ENV['guard'] = "host_a"} on my guardfile.

Is there a better way? I couldn't define an environmental variable only during guard execution

– Rémy

To unsubscribe from this group and stop receiving emails from it, send an email to guard-dev+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages