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
math_methods = Math.methods(false).each do |m| | |
self.class.send(:define_method, m, Proc.new do |x| Math.method(m).(x); end ) | |
end | |
math_methods.delete_if{|m| %I[atan2 hypot acos asin atan atanh frexp lgamma ldexp].include? m} | |
def sqrt x | |
Math.sqrt x | |
end | |
ops = [' + 4.0 ', ' - 4.0 ', ' * 4.0', ' / 4.0 ',] | |
mixer = %w[* - + /] |
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
#The following two examples are equivalent | |
#Example 1, explicit error classe declaration | |
class MyMainNamespace | |
module Errors | |
class Error1 < StandardError; end | |
class Error2 < StandardError; end | |
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 'thwait' | |
Then /^all links are valid$/ do | |
errors = [] | |
threads = [] | |
@links.each do |link| | |
threads << Thread.new do | |
last_response = get link.url | |
errors.push "#{link.url} LINK IS BROKEN" unless last_response.success? | |
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
########## CUCUMBER SAMPLE ########### | |
Given user "jon" goes to "google.com" | |
#turns into: | |
Given /^user "([^"]*)" goes to "([^"]*)"/ do |user_key, url| | |
@users[user_key].browse do |browser| | |
browser.goto url | |
end | |
end | |
######## HOOKS SAMPLE ############### |