This file contains 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
private static void setProxy(final HttpClient httpClient, final WebRequest webRequest) { | |
if (webRequest.getProxyHost() != null) { | |
final String proxyHost = webRequest.getProxyHost(); | |
final int proxyPort = webRequest.getProxyPort(); | |
final HttpHost proxy = new HttpHost(proxyHost, proxyPort); | |
if (webRequest.isSocksProxy()) { | |
final SocksSocketFactory factory = (SocksSocketFactory) | |
httpClient.getConnectionManager().getSchemeRegistry().getScheme("http").getSocketFactory(); | |
factory.setSocksProxy(proxy); | |
} |
This file contains 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
search and replace | |
------------------- | |
s/foo/bar/g changes each 'foo' to 'bar' in the current line. | |
:%s/foo/bar/g changes each 'foo' to 'bar' in all lines. | |
:5,12s/foo/bar/g changes each 'foo' to 'bar' for all lines between line 5 and line 12. | |
:'a,'bs/foo/bar/g changes each 'foo' to 'bar' for all lines between marks a and b. | |
:.,$s/foo/bar/g changes each 'foo' to 'bar' for all lines between the current line (.) and the last line ($). | |
:.,+2s/foo/bar/g changes each 'foo' to 'bar' for the current line (.) and the two next lines (+2). | |
:%s is equivalent to :1,$s |
This file contains 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
When /^I go to google$/ do | |
p page.driver.agent.request_headers = {'Accept-Language' => 'en-gb'} | |
visit('http://localhost:7001') | |
end | |
Then /^I should see the title google$/ do | |
find('title').text.should == 'RubyGems Documentation Index' | |
end |
This file contains 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
To use a local packaged gem file: | |
1. Manually create vendor/cache | |
2. Add your .gem file to this directory | |
3. ALWAYS run bundle install with --no-cache option....all other gems will then be obtained from remote source | |
Note: when using :path, this can only be to a directory containing a .gemspec file |
This file contains 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
# Add this to more_web_steps.rb | |
# Selenium docs: http://code.google.com/p/selenium/wiki/RubyBindings#Javascript_Alert/Confirm today! | |
When /^I (accept|dismiss) the "([^"]*)" alert$/ do |action, text| | |
alert = page.driver.browser.switch_to.alert | |
alert.text.should eq(text) | |
alert.send(action) | |
end |
This file contains 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
#Access Scenario Metadata | |
Before do |scenario| | |
p scenario.source_tag_names | |
end |
This file contains 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
To end the debugging session and return control to the app: | |
quit | |
To find out where you are: | |
where | |
Note, this will print out a stack trace only if you’ve added the Debugger.start as specified above. If you haven’t, where will only print out the line number and file name of where execution has reached. | |
To see where you are in context (current line with a few lines before and after): | |
list |
This file contains 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
[core] | |
editor = "mvim -f -c 'au VimLeave * !open -a Terminal'" | |
[merge] | |
tool = vimdiff | |
guitool = mvim | |
[diff] | |
tool = vimdiff | |
guitool = mvim | |
[mergetool "mvim"] | |
cmd = mvim -f -d "$LOCAL" "$MERGED" "$REMOTE" |
This file contains 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
require 'singleton' | |
class MySingleton | |
include Singleton | |
attr_accessor :myvar | |
def initialize | |
puts 'output from initialize in a singleton!' | |
end | |
end |
This file contains 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
require "net/https" | |
require "uri" | |
uri = URI.parse('https://repo.dev.bbc.co.uk') | |
pem = File.read("../../keys/combine.pem") | |
#http = Net::HTTP::Proxy('www-cache.reith.bbc.co.uk', 80).new(uri.host, uri.port) | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
http.cert = OpenSSL::X509::Certificate.new(pem) | |
http.key = OpenSSL::PKey::RSA.new(pem) |
OlderNewer