def fake_code(*args)
return "hello, world"
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
| it "should be able to pass in blocks" do | |
| code = <<CODE | |
| def method(x, y, &block) | |
| z = x * y | |
| some_shit = SomeClass.new(x) | |
| if some_shit.good_to_go? | |
| puts some_shit.print(y) | |
| SomeShitProcessor.new(some_shit).process(&block) | |
| 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
| 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 |
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
| def sudo | |
| "" | |
| end | |
| def run(command) | |
| puts command | |
| end | |
| def set(opt,setting) | |
| if opt == :user |
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
| 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 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
| [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 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
| 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 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
| 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 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
| 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 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
| [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 + "}") |
OlderNewer