First attempting to use Capybara directly, you will ran into issues when trying to set HTTP header. Using Basic HTTP Authentication requires that we needed to set the header. Also we need to set the Content-Type and Accept headers to ensure that Rails handles the input and output correctly. When using Rack, Capybara delegates request and response handling down to Rack::Test. So I used Rack::Test directly in my step definitions, and it works. Rack::Test has a module called Rack::Test::Methods that can be mixed into a class to provide it with methods for get, post, put, delete as well as last_request, last_response, header and more. I mixed Rack::Test::Methods into the Cucumber world at the top of our API steps file like so:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ALREADY_LOADED=admin_sample_database_already_loaded | |
DUMPFILE=/vagrant_support/admin_sample.sql | |
DATABASE=admin__default | |
if [[ ! -f $DUMPFILE ]]; then | |
print "You must supply the pg_dump file at $DUMPFILE first." | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
class Fib { | |
public static int plain(int index) { | |
if (index == 0) { | |
return 0; | |
} else if (index == 1) { | |
return 1; | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'sinatra' | |
gem 'sinatra-flash' | |
gem 'net-ldap' | |
gem 'passenger' | |
gem 'coffee-script' | |
gem 'slim' | |
gem 'sass' | |
gem 'data_mapper' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[program:znc] | |
command = /usr/bin/znc | |
user = force | |
directory = /home/force | |
redirect_stderr = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
notify_sshable() { | |
host=$1 | |
timeout=${2:-1} | |
sound=${3:-"$HOME/Dropbox/sounds/LOZ_Secret.wav"} | |
iteration=0 | |
while true; do | |
let iteration=$iteration+1 | |
echo "Attempt $iteration..." | |
ssh -oConnectTimeout=$timeout $host true | |
if [ $? = 0 ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Approach alpha is good if you know for certain that you're dealing with | |
# 1-dimensional arrays. | |
# | |
def alpha(parm) | |
parm = [parm].flatten | |
end | |
# Approach beta works if you need to support multi-dimensional arrays because it | |
# doesn't rely on #flatten. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cat /etc/supervisor/conf.d/znc.conf | |
[program:znc] | |
command = /usr/bin/znc | |
user = force | |
directory = /home/force | |
redirect_stderr = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT "message_images"."id" AS t0_r0, | |
"message_images"."name" AS t0_r1, | |
"message_images"."name_on_disk" AS t0_r2, | |
"message_images"."entity_id" AS t0_r3, | |
"message_images"."created_by" AS t0_r4, | |
"message_images"."create_method" AS t0_r5, | |
"message_images"."created_on" AS t0_r6, | |
"message_images"."modified_by" AS t0_r7, | |
"message_images"."updated_on" AS t0_r8, | |
"message_images"."activate_at" AS t0_r9, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dan@app05:/nutricate/production/app$ git status | |
# On branch deploy | |
# Changes not staged for commit: | |
# (use "git add <file>..." to update what will be committed) | |
# (use "git checkout -- <file>..." to discard changes in working directory) | |
# | |
# modified: admin/config/email.yml | |
# modified: admin/config/environments/admin.rb | |
# modified: admin/config/initializers/recaptcha.rb | |
# modified: instance/init_scripts/admin |