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
| # Replace Inheritance with Delegation | |
| # http://refactoring.com/catalog/replaceInheritanceWithDelegation.html | |
| # class Roster < Array | |
| # attr_accessor :title | |
| # def to_s | |
| # out = "#{title}\n" | |
| # each do |item| | |
| # out += "#{item}\n" |
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
| class PrivacyFilter | |
| class << self | |
| def filter(controller) | |
| @controller = controller | |
| first_article? or administrator? or user? | |
| end | |
| def first_article? | |
| @controller.params[:id] == 1 |
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
| ['a','b','c'].each do |char| | |
| it "returns xxx for #{char}" do | |
| process(char).should == 'xxx' | |
| end | |
| 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
| var x = function(userid) { | |
| return function(resp) { | |
| var user_name = JSON.parse(resp)["full_name"]; | |
| console.log(userid); | |
| build += "<li><a class='user' id='user-" + userid + "' href='#show-" + userid + "'>" + user_name + "</a></li>"; | |
| remaining -= 1; | |
| if (remaining == 0) { | |
| make_users_list(obj, build); | |
| hide_spinner(); | |
| $("#login").hide(); |
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 'spec_helper' | |
| describe Api::V1_2::TokensController do | |
| def parsed_response(response) | |
| JSON.parse(response.body) | |
| end | |
| describe "POST create" do | |
| let(:params) { {} } |
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
| describe 'conversations/base' do | |
| subject do | |
| Timecop.freeze(10.minutes.ago) do | |
| FactoryGirl.create(:conversation) | |
| end | |
| end | |
| before :each do | |
| assign(:object, subject) |
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
| class AnagramTest < MiniTest::Unit::TestCase | |
| class Anagram | |
| def initialize(word) | |
| @word = word | |
| # If you create the array here, then the results will be | |
| # collected over multiple calls to `match`. Not sure if that is | |
| # intended or not, so I'll assume it's ok to change. | |
| 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
| class AnagramTest < MiniTest::Unit::TestCase | |
| class Anagram | |
| def initialize(word) | |
| @word = word | |
| @anagram = Array.new | |
| end | |
| def match(candidates) | |
| candidates.each do |candidate| | |
| if candidate.turning_into_letters == @word.turning_into_letters |
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
| class DNATest < MiniTest::Unit::TestCase | |
| # You don't have to put your classes inside of the test case, but it | |
| # doesn't hurt for these examples | |
| class DNA | |
| def initialize(string) | |
| @string = string | |
| # You can provide a default value for hashes. This also avoids | |
| # hardcoding the letters here. | |
| @counts = Hash.new(0) |
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 new | |
| @transaction_fee = current_company.transaction_fee | |
| @transaction_cost = current_company.transaction_cost | |
| @withdrawal = current_company.withdrawals.new | |
| @available_amount = Withdrawal.available_amount(current_company.id) | |
| @transactions = current_company.transactions.where("payment_status = 'ready_to_pay'") | |
| end |
OlderNewer