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
@wait.until { @driver.find_element(tag_name: "h1").text.downcase.include? "cart" } |
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
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 |
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
# 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 |
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
s3cmd sync --exclude '.DS_Store' --exclude '.git/*' --exclude-from '.gitgnore' --add-header=Expires:max-age=604800 --acl-public ./ s3://the_bucket_name |
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
$(window).bind('popstate', function(event) { | |
var filename = location.pathname.substr(location.pathname.lastIndexOf("/")); | |
if (filename.indexOf("page1") > 0) { | |
// go back to the page1 context | |
} else { | |
// go to the page2 context | |
} | |
}); |
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
$("a").each(function(k,v) { | |
$(v).click(function() { | |
// do something here to load the content in dynamically | |
history.pushState(null, null, $(this).prop("href")); | |
return false; | |
}); | |
}); |
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
it "each artwork should have the correct structure" do | |
JSON.parse(response.body)["results"].each do |artwork| | |
artwork.keys.sort.should eq JSON.parse(FactoryGirl.create(:artwork).to_json).keys.sort | |
end | |
end |
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
context "#index (GET /artworks.json)" do | |
# create 30 Artwork documents using FactoryGirl, and do a HTTP GET request on "/artworks.json" | |
before(:each) do | |
30.times { FactoryGirl.create(:artwork) } | |
get "/artworks.json" | |
end | |
describe "should list all artworks" do | |
# the request returns a variable called "response", which we can then make sure comes back as expected | |
it { response.should be_ok } | |
it { JSON.parse(response.body)["results"].should be_a_kind_of(Array) } |
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
describe "as_json method" do | |
subject { artwork.to_json } | |
# test the root object structure | |
it { should have_json_type(String).at_path("artist_id") } | |
it { should have_json_type(Array).at_path("available_sizes") } | |
# test a nested object | |
it { should have_json_type(Object).at_path("artist") } | |
it { should have_json_type(String).at_path("artist/id") } | |
it { should have_json_type(String).at_path("artist/slug") } | |
end |
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
Which is totally awesome. |