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
# Enable Webrat's Selenium mode if one or more scenarios is tagged @selenium | |
Webrat.configure do |config| | |
config.mode = :rails | |
ObjectSpace.each_object(Cucumber::Ast::Features) do |features| | |
config.mode = :selenium if features.tag_count('selenium').nonzero? | |
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
When /^(.*) in the "([^\"]*)" section$/ do |action, title| | |
within "//*[(h1|h2|h3|h4|h5|h6|legend|caption)/descendant-or-self::*[contains(text(), '#{title}')]]" do | |
When action | |
end | |
end | |
When /^(.*) in the "([^\"]*)" row$/ do |action, title| | |
within "//*[(th|td)/descendant-or-self::*[contains(text(), '#{title}')]]" do | |
When 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
def mask _;_[6..-5]='*'.*_.size-10;_;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
def luhn?n;s=0;n.size.times{|i|x=n[-i-1,1].to_i*(i%2+1);s+=x>9?x+1:x};s%10==0;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
def fibsum _;_<3?_:1+fibsum(_-1)+fibsum(_-2)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
def ccexp?d;d[-2,2].to_i<=10&&d[0,2].to_i<7 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
def morse s;26.times{|i|s.gsub!(/#{(97+i).chr}/i,"$be5 J8G#T6P'&9Sl/,!-H0cfk".split('').map{|x|(x[0]-31).to_s(3).tr('12','.-')}[i])};s;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
def ccexp?d;d[-2,2].to_i<=10&&d[0,2].to_i<7 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
def ccexp?d;m=d[-2,2].to_i;m<10||m==10&&d[0,2].to_i<7;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
def morse s;s.upcase.gsub(/\S/){|x|("CF+(514M )DGL"[x[0]-65]).to_s(3).tr("12",".-")};end |