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
#!/usr/bin/env ruby | |
failures = 1 | |
if failures.zero? | |
puts "0 failures!" | |
else | |
puts "Commit NOT COMMITTING! ABORT! ABORT!" | |
exit 1 | |
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
var list = new List<string> { "fish", "and", "chips" }; | |
for (int i = 0; i < list.Count; i++) | |
{ | |
list.Add(list[i].ToUpper()); | |
} |
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
private void RetrieveMessages() | |
{ | |
try | |
{ | |
if (serviceUrl.Text.Length == 0) | |
{ | |
if (alertHasBeenShown) { return; } | |
throw new DebuggingWFException("Exception occurred", | |
new NullReferenceException("Service URL")); | |
} |
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
using System; | |
using System.Runtime.InteropServices; | |
namespace SkypeHomeKiller | |
{ | |
class Program | |
{ | |
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)] | |
static extern IntPtr FindWindow(string lpClassName, string lpWindowName); |
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
describe "Processing XML file" do | |
it "opens the file correctly" do | |
file_path = "/some/path/to.xml" | |
xml = "<xml>bleh</xml>" | |
stub_file = stub(:read).and_return(xml) | |
File.stub(:open).and_return(stub_file) | |
Parse.should_receive(:process_xml).with(xml) | |
Parser.process(file_path) | |
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
//presented class (from http://www.peterprovost.org/blog/2012/04/25/visual-studio-11-fakes-part-2) | |
namespace ShimsDemo.SystemUnderTest | |
{ | |
public class CustomerViewModel : ViewModelBase | |
{ | |
private Customer customer; | |
private readonly ICustomerRepository repository; | |
public CustomerViewModel(Customer customer, ICustomerRepository repository) |
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
# This method is all over the place. | |
def default_url | |
if @attachment_options[:default_url].respond_to?(:call) | |
@attachment_options[:default_url].call(@attachment) | |
elsif @attachment_options[:default_url].is_a?(Symbol) | |
@attachment.instance.send(@attachment_options[:default_url]) | |
else | |
@attachment_options[:default_url] |
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
class ImportError < StandardError | |
attr_reader :row | |
def initialize(msg, row) | |
super(msg) | |
@row = row | |
end | |
def to_s | |
"#{self.message} (Found processing row: #{@row.inspect})" |
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
#non SRP | |
def map | |
user = User.find(params[:id]) | |
user.name = params[:name] | |
user.email = params[:email] | |
end | |
#SRP | |
#spec |
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
it "calls recursively" do | |
MyClass.class_eval do | |
class << self | |
alias_method :mymethod_normal, :mymethod | |
end | |
end | |
MyClass.should_receive(:mymethod) | |
MyClass.mymethod_normal | |
end |
OlderNewer