Skip to content

Instantly share code, notes, and snippets.

View jm's full-sized avatar
💫
Livin' life. Or something.

Jeremy McAnally jm

💫
Livin' life. Or something.
View GitHub Profile
def create_from_string(klass, string = "")
# like calling String.new or something because
# klass is a variable representing the class you passed in
klass.new(string)
end
x = create_from_string(String, "dude")
y = create_from_string(Regexp, "wat")
def logging_features_deprecated
# Currently not deprecated; change to true when it is deprecated
proc { false }
end
deprecate "file logging", :when => logging_features_deprecated do
# whatever
end
tags = ["one", "two", "three", "one", "two", "one"]
counts = Hash.new(0)
tags.each {|t| counts[t] += 1}
puts counts.inspect
// Objects
[thing shouldEqual:thing];
// Primitive values
[expect(YES) shouldEqual:YES];
// Working on more matchers...
[expect([@"hello" isEqual:@"hello"]) shouldBeTrue];
// I think I might also add these methods so it reads better...
[expect([myArray count]) shouldEqual:3]
[expect([obj isActive]) shouldBeTrue]
// Rather than:
STAssertEquals(32, [centigradeFreezingPoint intValue],
@"Centigrade freezing point should be 32, but was %d instead!",
[centigradeFreezingPoint intValue]);
// It's now...
[[centigradeFreezingPoint intValue] shouldEqual:32];
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -Ilib:lib:test "/Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb" "test/dsl_test.rb" "test/foundry_test.rb"
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:442:in `load_missing_constant': uninitialized constant ActiveSupport::MessageVerifier (NameError)
from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:77:in `const_missing'
from /Users/jeremymcanally/code/plugin-dev/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:198:in `verifier_for'
from /Users/jeremymcanally/code/plugin-dev/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:82:in `initialize'
from /Users/jeremymcanally/code/plugin-dev/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb:68:in `new'
from /Users/jeremymcanally/code/plugin-dev/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb:68:in `build'
from /Users/j
model User
factory :valid, :name => "Jeremy", "login" => "jeremy", :admin => false
factory :admin, :admin => true
end
User.valid.create
User.valid.admin.create
6) Error:
test_should_show_page(PagesControllerTest::TestWithAnonymous19197610::TestViewing19197450):
ArgumentError: wrong number of arguments (0 for 1)
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_case.rb:134:in `initialize'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_case.rb:134:in `new'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_case.rb:134:in `setup_controller_request_and_response'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in `evaluate_method'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:166:in `call'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:90:in `run'
~/code/context(master) > sloccount lib/ test/
Creating filelist for lib
Creating filelist for test
Categorizing files.
Finding a working MD5 command....
Can't exec "md5sum": No such file or directory at /opt/local/bin/break_filelist line 688, <CODE_FILE> line 15.
Found a working MD5 command.
Computing results.
SLOC Directory SLOC-by-Language (Sorted)