Skip to content

Instantly share code, notes, and snippets.

@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
@natritmeyer
natritmeyer / integer_position_suffix.rb
Created January 6, 2012 14:59
Ruby monkeypatch: Integer#position_suffix
# 1.position_suffix => "st"
# 2.position_suffix => "nd"
# 3.position_suffix => "rd"
# 4.position_suffix => "th"
# 11.position_suffix => "th"
# 21.position_suffix => "st"
# 345678.position_suffix => "th"
class Integer
def position_suffix
@natritmeyer
natritmeyer / daily_readings_generator.rb
Last active September 29, 2015 02:38
Robert Roberts Daily Readings iCalendar file generator and output
=begin
Copyright (c) 2011, Nathaniel Ritmeyer
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.