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 changes_scope(changes_before_num) | |
return @injected_versions_scope if @injected_versions_scope | |
if changes_before_num | |
Version.where('id > ?',changes_before_num).where(:item_type => 'UploadAttempt').order('id DESC') | |
else | |
Version.where(:item_type => 'UploadAttempt').order('id DESC') | |
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
module RSpec::Matchers | |
define :be_a_visitable_link_from do |page| | |
match do |page_link| | |
begin | |
page.visit(page_link[:href]) | |
rescue Exception => e | |
@e = e | |
end | |
if @e || [500,404].include?(page.status_code) |
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
[13] pry(main)> bad_long_code = " | |
[13] pry(main)* if var > 2 | |
[13] pry(main)* blahblah | |
[13] pry(main)* else | |
[13] pry(main)* var === | |
[13] pry(main)* end | |
[13] pry(main)* " | |
=> "\nif var > 2\n blahblah\nelse\n var ===\nend\n" | |
[14] pry(main)> begin | |
[14] pry(main)* eval("lambda {" + bad_long_code + "}") |
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
chain.add_rule do | |
if row['Col'].length > 7 and row['Col'].length < 10 | |
row_is_valid | |
end | |
end | |
chain.add_rule['Col2'].gt(2).and['Col2'].lt(9).row_is_valid | |
chain.add_rule['Col3'].matches(/somestring/).row_is_valid |
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
s = "blah blah blah" | |
ops = {:split => " ", :first => 2} | |
ops.to_a.reverse.inject(lambda {|x| x}) {|memo,(k,v)| lambda {|x| memo.call(x.send(k,v)) } }.call(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
108: conditions[dsa.column_name.to_sym] = [value] | |
109: end | |
110: | |
111: record_count = staging_table_active_record.count(:conditions => conditions) | |
112: | |
=> 113: binding.pry | |
114: record_count > 0 | |
115: end | |
116: | |
117: def staging_table_active_record |
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
[1] pry(main)> '2007-01-01'.to_time.at_beginning_of_day | |
=> Mon Jan 01 00:00:00 UTC 2007 | |
[2] pry(main)> '2007-01-01'.to_datetime.at_beginning_of_day | |
=> Mon, 01 Jan 2007 12:00:00 +0000 |
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 )select "([^"]*)" from "([^"]*)"$/ do |value, field| | |
combobox = find(:xpath, XPath::HTML.select(field)) | |
options = combobox.all(:xpath, 'option') | |
display_values = options.map(&:text).map(&:downcase) | |
sorted_values = display_values.sort | |
display_values.should == sorted_values | |
select(value, :from => field) |
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 sudo | |
"" | |
end | |
def run(command) | |
puts command | |
end | |
def set(opt,setting) | |
if opt == :user |
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 'ruby_refactorer' | |
describe RubyRefactorer do | |
it "should be able to extract methods" do | |
code = <<CODE | |
def outer_method | |
x, y = 2, 3 | |
x + y | |
end |