Skip to content

Instantly share code, notes, and snippets.

View natritmeyer's full-sized avatar
🧛‍♂️
Summoning code

Nat Ritmeyer natritmeyer

🧛‍♂️
Summoning code
View GitHub Profile
@natritmeyer
natritmeyer / Rakefile
Created December 6, 2012 10:04
Sinatra Stubs and Rake Tasks
require 'rspec/core/rake_task'
namespace :stubs do
namespace :schedule do
pid_file_path = "lib/stubs/schedule.pid"
desc "Start the schedule stub"
task :start do
`rackup -D lib/stubs/schedule.ru -P #{pid_file_path} -p 2000`
end
@natritmeyer
natritmeyer / time_zome_management.rb
Created August 29, 2012 21:18
Make your tests run in any timezone...
#in env.rb:
require 'active_support/time'
Time.zone = 'Europe/London'
#use in tests instead of `Time.now`:
Time.current #=> will output the time in London, regardless of the localhost's timezone
@natritmeyer
natritmeyer / instructions.txt
Created June 26, 2012 11:16
Cucumber formatter to list all tags
To list all tags scattered across your feature files...
1) add the following "list_tags.rb" file to your features/support directory
2) cucumber -d -f Cucumber::Formatter::ListTags
@natritmeyer
natritmeyer / block_suggestion.rb
Created May 31, 2012 18:32
Page Object Management blog post material
visit LoginPage do |page|
page.login_with('foo', 'badpass')
page.text.should include "Login error"
page.text.should include "Secure your account"
end
@natritmeyer
natritmeyer / Usage.txt
Last active January 16, 2017 01:56
JUnit formatter for RSpec
NOTE: I've created a gem based on this: https://github.com/natritmeyer/yarjuf
---------
rspec my_spec.rb -r ./junit.rb -f JUnit -o results.xml
@natritmeyer
natritmeyer / bring_browser_to_front.rb
Created April 20, 2012 10:16
Example ruby/applescript combo that brings browsers to the front - useful in browser test automation...
#you probably only need one of these, but here's the lot of them...
#prepare the commands that will bring the various browsers to the front
bring_chrome_to_front = %Q{ osascript -e "tell application \\\"Google Chrome\\\" to activate" }
bring_firefox_to_front = %Q{ osascript -e "tell application \\\"Firefox\\\" to activate" }
#execute the applescript commands to bring the browsers to the front
`#{bring_chrome_to_front}`
`#{bring_firefox_to_front}`
@natritmeyer
natritmeyer / tests.rb
Created March 15, 2012 00:44
(Possibly) The World's Smallest Ruby Unit Test Tool
require './tinytest'
class MyTests < TinyTest
def setup
@name = "Bob"
end
def teardown
@name = ""
end
@natritmeyer
natritmeyer / env.rb
Created February 24, 2012 11:04
Fix for ajax problems in tests
module AjaxWaiter
def wait_for_ajax
wait_until { page.evaluate_script("jQuery.active") == 0 }
end
end
World(AjaxWaiter)
@natritmeyer
natritmeyer / env.rb
Created February 20, 2012 20:02
Accessing cucumber scenario tags
Before do |scenario|
p scenario.source_tag_names #=> ["@complete", "@slow"]
end
@natritmeyer
natritmeyer / spotlight_cli.sh
Created January 18, 2012 09:28
An alias for your .bash_profile that allows you to search in the current folder using spotlight
function sl() {
/usr/bin/mdfind -onlyin \. $@
}
#usage:
# sl Search for this phrase