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
#my_target_page.rb | |
def add_and_save_notes notes | |
fill_in("my_target_text_box", :with => notes) | |
click_button "Save" # This makes an AJAX request and adds new row to the table upon successfully saving | |
sleep(3) #<-- This is BAD code. You should have the line below in place of this one. | |
#wait_until { has_text?(notes) } #<-- This is GOOD practice that enables test stability and hence faith in test results | |
end | |
def has_note? notes |
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
Capybara.register_driver :selenium do |app| | |
profile = Selenium::WebDriver::Firefox::Profile.new | |
profile['browser.download.dir'] = "#{Rails.root}/tmp/webdriver-downloads" | |
profile['browser.download.folderList'] = 2 # implies custom location | |
profile['browser.helperApps.neverAsk.saveToDisk'] = "text/csv,application/pdf" | |
Capybara::Selenium::Driver.new(app, :browser => :firefox ,:profile => profile) | |
#... | |
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
#my_target_page.rb | |
def add_and_save_notes notes | |
fill_in("my_target_text_box", :with => notes) | |
click_button "Save" # This makes an AJAX request and adds new row to the table upon successfully saving | |
wait_until { has_link?("Edit note") } #<-- This is BAD, esp. when the note to be added is yet another row in a table having "Edit note" link for every corresponding row in that table | |
#wait_until { has_text?(notes) } #<-- This is GOOD practice that enables test stability and hence faith in test results | |
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
#my_target_page.rb | |
def verify_edit_link_presence | |
has_link?("Edit").should be_true | |
end | |
#my_target_spec | |
it "blah blah blah" | |
@my_target_page.do_some_action |
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
#my_target_page.rb | |
def has_edit_link? | |
has_link?("Edit") | |
end | |
#my_target_spec | |
it "blah blah blah" | |
@my_target_page.do_some_action |
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
"-------------------------------------------------------------------[Vundle]---- | |
set nocompatible | |
filetype off | |
set rtp+=~/.vim/bundle/vundle/ | |
call vundle#rc() | |
Bundle 'gmarik/vundle' | |
Bundle 'kien/ctrlp.vim' | |
Bundle 'mileszs/ack.vim' |
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
[mergetool "kdiff3"] | |
path = /usr/local/bin/kdiff3 | |
keepBackup = false | |
trustExitCode = false | |
[mergetool "diffmerge"] | |
cmd = /Applications/DiffMerge.app/Contents/MacOS/diffmerge --merge --result=$MERGED $LOCAL $BASE $REMOTE | |
keepBackup = false | |
trustExitCode = false | |
[merge] | |
tool = diffmerge |
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
function f() { | |
return 123; | |
} | |
f(); //returns 123 |
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
function f() { | |
// No return statement | |
} | |
f(); //returns "undefined" |
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
/* | |
The Pattern: | |
function name(param1, param2, .., paramN) { | |
//statements | |
} | |
*/ | |
//Example function declaration | |
function add(x, y) { | |
return x + y; |