Skip to content

Instantly share code, notes, and snippets.

# encoding: UTF-8
require "rubygems"
require "selenium-webdriver"
require "awesome_print"
# allow colour in RSpec results
RSpec.configure do |config| config.color_enabled = true end
describe "The Easyart website" do
before(:all) do
context "searching" do
before(:all) do
@driver.navigate.to "http://www.easyart.com"
# find <input name="searchquery">
@driver.find_element(name: "searchquery").send_keys("cheese")
# find <input id="search-button"> and click it
@driver.find_element(id: "search-button").click
# wait until the title starts with "cheese"
@wait.until { @driver.find_element(tag_name: "h1").text.downcase.start_with? "cheese" }
end
@wait.until { @driver.find_element(tag_name: "h1").text.downcase.include? "cart" }
{
"paging": {
"total": 95959,
"current_page": 1,
"total_pages": 9596,
"per_page": 10,
"previous_page_uri": null,
"next_page_uri": "/artworks.json?page=2&per_page=10"
},
"results": [
@nickboyce
nickboyce / gist:3137425
Created July 18, 2012 16:53
Dumped template variables
searchsession: The_Kiss1%2C2%2C3%2C4%2C7%2C8
num_results_per_page: 36
num_results_per_page_36: 1
params_as_hidden_form_fields:
current_page: 1
total_pages: 395
page_links: 12345678910Next
template_state_1: 1
total_results: 14191
COOKIES.hideBanner: true
@nickboyce
nickboyce / gist:5188171
Last active December 15, 2015 02:38
Initial discovery of Casper/PhantomJS
// brew install phantomjs
// brew install casperjs
var casper = require("casper").create();
casper.start("http://www.easyart.com/scripts/pod/pod.pl?pid=213288", function() {});
casper.then(function() {
this.test.assertEval(function() {
return document.querySelectorAll("#pod-size-options input[type=radio]").length == 4
require 'msgpack'
require 'json'
require 'benchmark'
o = {_id: 4086, created_at: "2002-12-01 00:00:00 UTC", updated_at: "2013-05-16 11:35:46 UTC", artist_id: "5165adb400e48fcc14000001", easyart_id: 4086, title: "The Tree of Life - Stoclet Frieze", tags: ["woman", "hug", "bedroom", "lounge"], available_media: ["paper", "canvas"], available_sizes: [], dominant_colour: [], original_medium: "Pencil / Ink / Pastel", artistic_movement: "Art Nouveau", shape: "landscape", supplier_id: "114", lead_time: 10, stock_level: 2, sales_per_day: 0.017771883289125, total_revenue: 285195, is_pod: false, category: [["figurative", "romance"], ["museum-art", "art-nouveau"]], category_slugs: [], edition_size: 0, price: 5499, original_price: nil, discount_percent: 0, status_id: nil, search_promotion: 0, copyright: nil, description: nil, height: nil, width: nil, easyart_ids: [], dominant_colours: ["gold"]}
a = []
100000.times do
a << o
end
module ActiveSupport
module Cache
class IronCache < ActiveSupport::Cache::Store
def escape_key(key)
ekey = ::Base64.encode64(key).gsub("\n",'').gsub("/",'')
if ekey.size > 250
ekey = "#{ekey[0, 213]}:md5:#{Digest::MD5.hexdigest(ekey)}"
end
describe "hasMailChimpParams", ->
it "should return true if MailChimp parameters are in the URL", ->
hasMailChimpParams = EA.MailchimpData.checkForMailChimpParams("http://www.easyart.com?mc_cid=true&mc_eid=true");
expect(hasMailChimpParams).toBeTruthy();
it "should not return true if MailChimp parameters are not in the URL", ->
hasMailChimpParams = EA.MailchimpData.checkForMailChimpParams("http://www.easyart.com");
expect(hasMailChimpParams).not.toBeTruthy();
order:
app_key: "en_easyart"
request_ip_address: "192.168.0.1"
status: "ok"
customer_name: "John Citizen"
customer_email: "[email protected]"
shipping_address:
name: "John Citizen"
street1: "Unit 123"
street2: "456 Fake Street"