##Drying up tests with it_behaves_like
:
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 Worm: | |
def __init__(self, pName): | |
self.name = pName | |
class Apple: | |
def __init__(self): | |
self.myWorm = None | |
self.myWorm = self.makeWorm() | |
print self.myWorm.name # works |
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 sign(number) | |
if number > 0 | |
return 1 | |
elsif number < 0 | |
return -1 | |
end | |
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
require 'rake' | |
require 'rspec/core/rake_task' | |
require ::File.expand_path('../config/environment', __FILE__) | |
# Include all of ActiveSupport's core class extensions, e.g., String#camelize | |
require 'active_support/core_ext' | |
namespace :generate do | |
desc "Create an empty model in app/models, e.g., rake generate:model NAME=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
$(document).ready(function () { | |
DiceController = { | |
dice: [], | |
$diceContainer: $('.dice'), | |
addDie: function () { | |
die = new Die (); | |
this.dice.push(die); | |
this.$diceContainer.append(die.rootNode()); |
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
# Add yourself some shortcuts to projects you often work on | |
# Example: | |
# | |
# brainstormr=/Users/robbyrussell/Projects/development/planetargon/brainstormr | |
# | |
spec () { | |
command touch "spec/$1_spec.rb" | |
} |
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
from unipath import Path | |
import re | |
MIGRATION_NAME_PATTERN = r"^\d+_(.*).rb$" | |
def get_migration_names(path): | |
return set(migration_name(migration_filename) | |
for migration_filename in | |
Path(path).listdir(names_only=True)) |
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
(bpython) ✘ ⚙ nick@localhost ~ | |
λ bpython-curtsies | |
>>> help() | |
Welcome to Python 2.7! This is the online help utility. | |
If this is your first time using Python, you should definitely check out | |
the tutorial on the Internet at http://docs.python.org/tutorial/. | |
Enter the name of any module, keyword, or topic to get help on writing |
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 python | |
""" | |
mkrb.py | |
Usage: | |
mkrb.py path_to_file | |
Example: | |
mkrb services/widget_extractor |
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 python | |
""" | |
mvrb | |
A simple utility to move and rename Rails app and spec code | |
Usage: | |
mvrb services/widget_extractor concepts/widget_concatenator | |
Would move app/services/widget_extractor.rb to app/concepts/widget_concatenator. |
OlderNewer