Feature: Output nginx configuration file In order to run my application as an nginx virtualhost As a user of the library I want to output a nginx virtualhost configuration. Scenario: using command-line options When I run `bundle exec vhost-generator -g nginx -o upstream=myupstream -f html -l 80,81 -s localhost,my.server -p 5000,5001,5002 -r /myapp` Then the output should match /FILE GENERATED BY.*EDIT AT YOUR OWN RISK/ And the output should contain: """ upstream myupstream { server localhost:5000 fail_timeout=0; server localhost:5001 fail_timeout=0; server localhost:5002 fail_timeout=0; } """ And the output should contain: """ server { listen 80; listen 81; """ And the output should contain: """ server_name localhost, my.server; """ And the output should match /root.*html;/ And the output should contain: """ try_files $uri/index.html $uri @upstream; location @upstream { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://myupstream; } """ And the output should contain: """ location /myapp/assets { gzip_static on; # to serve pre-gzipped version expires 60d; add_header Cache-Control public; } """ And the output should contain: """ error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; } """ Scenario: using environment variables When I set env variable "GENERATOR" to "nginx" And I set env variable "GENERATOR_OPTIONS" to "upstream=myupstream" And I set env variable "STATIC_FOLDER" to "html" And I set env variable "SERVER_PORTS" to "80,81" And I set env variable "SERVER_NAMES" to "localhost,my.server" And I set env variable "INSTANCE_PORTS" to "5000,5001,5002" And I set env variable "RAILS_RELATIVE_URL_ROOT" to "/myapp" And I run `bundle exec vhost-generator` Then the output should match /FILE GENERATED BY.*EDIT AT YOUR OWN RISK/ And the output should contain: """ upstream myupstream { server localhost:5000 fail_timeout=0; server localhost:5001 fail_timeout=0; server localhost:5002 fail_timeout=0; } """ And the output should contain: """ server { listen 80; listen 81; """ And the output should contain: """ server_name localhost, my.server; """ And the output should match /root.*html;/ And the output should contain: """ try_files $uri/index.html $uri @upstream; location @upstream { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://myupstream; } """ And the output should contain: """ location /myapp/assets { gzip_static on; # to serve pre-gzipped version expires 60d; add_header Cache-Control public; } """ And the output should contain: """ error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; } """