Capybara / Rspec, Development VS Production, looking for approach


Right now I have a full suite of tests that run on Test that go through points A…Z

I now need to mirror these A…Z tests against our Test-Production server.

A majority of the feature/scenario tests only differ in that my Test suite uses ‘login_facility’ to access the appropriate sections, while my Test-Production will run ‘production_login_faclity’ like the below.

def prodcution_login_facility
Capybara.app_host = 'https://website/authenticate
visit root_path
fill_in ‘password’, with: 'password123’
click_on 'Submit’

What kind of approach can I take so I don’t duplicate my features, soley to preface them with production_login_facility ?


Hey Andrew,

If the methods login_facility and production_login_facility are essentially the same barring the Capybara.app_host you could just use an env variable to define the app_host value. That will mean you can use the same method and just have the value of app_host be determined by whatever you’ve setup in your environment variable. You could even set it to default to the value in login_facility to make life easier.