Skip to content

Instantly share code, notes, and snippets.

View cheezy's full-sized avatar

Jeff Morgan cheezy

  • Industrial Logic Canada
  • Toronto, ON Canada
  • X @chzy
View GitHub Profile
@cheezy
cheezy / gist:6768164
Created September 30, 2013 18:40
updated steps
Given(/^We wish to enter a new product$/) do
visit ProductPage
#click_link 'New Product'
end
When(/^The following product is entered$/) do |table|
data = table.rows_hash
on(ProductPage) do |page|
page.title = data['title']
page.description = data['description']
@cheezy
cheezy / gist:6408208
Created September 2, 2013 00:20
gem push error
gem push pkg/data_magic-0.16.1.gem -V
HEAD http://gems.rubyforge.org/latest_specs.4.8.gz
301 Moved Permanently
HEAD https://rubygems.org/latest_specs.4.8.gz
302 Moved Temporarily
HEAD https://s3.amazonaws.com/production.s3.rubygems.org/latest_specs.4.8.gz
304 Not Modified
HEAD http://gems.github.com/latest_specs.4.8.gz
304 Not Modified
Pushing gem to https://rubygems.org...
@cheezy
cheezy / gist:5974976
Created July 11, 2013 12:20
Stacktrace from PTeng
bundle update gives
Using rake (10.1.0)
Using ffi (1.9.0)
Using childprocess (0.3.9)
Using ADB (0.5.6)
Using brazenhead (0.4.7)
Using builder (3.2.2)
Using diff-lcs (1.2.4)
Using multi_json (1.7.7)
Using gherkin (2.12.0)
After do |scenario|
if scenario.failed?
filename = "error-#{scenario.__id__}.png"
@current_page.save_screenshot(filename)
embed(filename, 'image/png')
end
end
@cheezy
cheezy / gist:4990370
Created February 19, 2013 21:46
Verifying I am on a page using the title
class MyPage
include PageObject
expected_title('the title I need to look for')
def initialize_page
has_expected_title?
end
end
@cheezy
cheezy / gist:3849469
Created October 7, 2012 20:23
My ImageLoader class
package com.leandog.puppies.data;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import android.graphics.drawable.Drawable;
public class ImageLoader {
@cheezy
cheezy / gist:2415279
Created April 18, 2012 17:30
Using PageObject with RSpec
# spec_helper.rb
require 'rspec'
require 'watir-webdriver'
require 'page-object'
require 'page-object/page_factory'
require 'require_all'
require_all 'lib/pages'
RSpec.configure do |config|
RSpec::Matchers.define :have_element_named do |expected|
match do |page|
page.respond_to?("#{expected.to_s}_element") and page.send "#{expected.to_s}?"
end
failure_message_for_should do |page|
"Expected the page to have an element named '#{expected.to_s}'"
end
failure_message_for_should_not do |page|
After do |scenario|
if scenario.failed?
name = "error#{Time.now}.png"
@current_page.save_screenshot name
embed name, 'image/png'
end
# do your other stuff
end
@cheezy
cheezy / gist:1302241
Created October 20, 2011 20:21
Method from Mixology
protected static void clearCache(RubyModule klass, RubyModule module) {
List<String> methodNames = new ArrayList<String>(module.getMethods().keySet());
for (Iterator iter = methodNames.iterator(); iter.hasNext();) {
String methodName = (String) iter.next();
klass.getRuntime().getCacheMap().remove(klass.searchMethod(methodName));
}
}