Reputation: 5813
I'm testing a JSON API for a model with a Carrierwave Uploader, but I'm only allowing uploads via a remote_url, so I need some way to get an HTTP address for a file in my public assets, since I know those'll always be around.
To put it another way:
When the Rails server is running, I have a static asset at "http://localhost:3000/assets/logo.png"
. I need the address of that file while Cucumber is running - aka, I need to serve a static file while running Cucumber, so that a different part of the Rails app can "download" that file.
Edit: These test are not run with a browser, although (as of recently), they are run with a session. I may be using Cucumber, but I have written no code to use or start Capybara.
Upvotes: 1
Views: 413
Reputation: 33171
If I'm understanding your question correctly. You may want to look into something like Fakeweb or Webmock to serve back/mock external requests.
Upvotes: 2
Reputation: 36
I think you can get the root uri for the test server that cucumber starts by using these:
For capybara < 2.0:
Capybara.current_session.driver.rack_server.host
Capybara.current_session.driver.rack_server.port
Capybara 2.0:
Capybara.current_session.server.host
Capybara.current_session.server.port
Upvotes: 0