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
MyModel.find_by_index('$key', '20121001'..'20130117') |
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 links = value.values[0].metadata.Links; | |
links.filter(function(element, index, array){ return element[0] == 'tag'}).length; |
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
RSpec::Matchers.define :be_a_ripple_document do | |
match do |doc| | |
doc.class.included_modules.include?(Ripple::Document) || | |
doc.class.included_modules.include?(Ripple::EmbeddedDocument) | |
end | |
failure_message_for_should do | |
"#{actual.class.to_s} should be a Ripple::Document" | |
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
def phone_number | |
o = [(0..9)].map{|i| i.to_a}.flatten; | |
(0..9).map{ o[rand(o.length)] }.join | |
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
describe RomanNumeralCalculator do | |
describe "with simple conversions" do | |
Then { RomanNumeralCalculator.convert(1).should == 'I' } | |
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
RSpec::Matchers.define :be_converted_to do |expected| | |
match do |actual| | |
@result = Calculator.convert(actual) | |
@result == expected | |
end | |
failure_message_for_should do | |
"Expected #{actual} to be converted to #{expected}, but got #{@result}" | |
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
describe "Converting integers to roman numerals" do | |
describe "with simple conversions" do | |
Then { 1.should be_converted_to 'I' } | |
Then { 5.should be_converted_to 'V' } | |
Then { 10.should be_converted_to 'X' } | |
end | |
describe "with additive conversions" do | |
Then { 3.should be_converted_to 'III' } |
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 "Converting integers to roman numerals" do | |
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
def Prefer(value) | |
if value.present? then | |
value | |
else | |
block_given? ? yield : NullObject.new | |
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 AuthenticationHelpers | |
# Example usage: login mock_user(Editor) | |
def login(user) | |
request.env['warden'] = mock(Warden, | |
:authenticate => user, | |
:authenticate! => user) | |
end | |
def mock_user(type, stubs={}) | |
mock_model(type, stubs).as_null_object |