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
factory :user do | |
email "[email protected]" | |
password "secret" | |
trait :with_comments do | |
after(:create) do |user, evaluator| | |
# FactoryGirl.create_list(factory, number_of_items, factory_attrs) | |
FactoryGirl.create_list(:comment, 1, user: user) | |
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
var powerRankings = [ | |
"49ers", | |
"Seahawks", | |
"Broncos" | |
]; | |
var index = powerRankings.indexOf("Seahawks", 1); | |
var rank = index + 1; |
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 powerRankings = [ | |
"49ers", | |
"Seahawks", | |
"Broncos" | |
]; | |
var index = powerRankings.indexOf("Seahawks"); | |
var rank = index + 1; |
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 MyApp::Interface::NavigationBar | |
include ActionView::Helpers::UrlHelper | |
delegate :url_helpers, to: 'Rails.application.routes' | |
def initialize(template, current_user) | |
@template = template | |
@current_user = current_user | |
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
class MyApp::Interface::NavigationBar | |
include ActionView::Helpers::UrlHelper | |
delegate :url_helpers, to: 'Rails.application.routes' | |
def initialize(template, current_user) | |
@template = template | |
@current_user = current_user | |
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
## | |
# Runs a single test with setup/teardown hooks. | |
def run | |
with_info_handler do | |
time_it do | |
capture_exceptions do | |
before_setup; setup; after_setup | |
self.send self.name |
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 ActionView | |
module Helpers | |
module FormHelper | |
def encrypted_text_field(object_name, method, options = {}) | |
InstanceTag.new(object_name, method, self, options.delete(:object)).to_encrypted_input_field_tag("text", options) | |
end | |
class InstanceTag | |
def to_encrypted_input_field_tag(field_type, options = {}) |
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
Board.prototype.isWinner = function () { | |
if (((this.state[0] == 1) && (this.state[1] == 1) && (this.state[2] == 1)) | |
|| ((this.state[3] == 1) && (this.state[4] == 1) && (this.state[5] == 1)) | |
|| ((this.state[6] == 1) && (this.state[7] == 1) && (this.state[8] == 1)) | |
|| ((this.state[0] == 1) && (this.state[3] == 1) && (this.state[6] == 1)) | |
|| ((this.state[1] == 1) && (this.state[4] == 1) && (this.state[7] == 1)) | |
|| ((this.state[2] == 1) && (this.state[5] == 1) && (this.state[8] == 1)) | |
|| ((this.state[0] == 1) && (this.state[4] == 1) && (this.state[8] == 1)) | |
|| ((this.state[2] == 1) && (this.state[4] == 1) && (this.state[6] == 1))) { | |
return 1; |
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
/* state === [2, 2, 2, -1, -1, -1, -1, 1, 1] */ | |
Board.prototype.isWinner = function () { | |
/* ... */ | |
else if ((this.state[0] == this.state[1] == this.state[2] == 2) | |
/** | |
* if (2 == 2) returns true | |
* if (true == 2) returns false | |
*/ |
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('isWinner', function () { | |
var COMPUTER = 1; | |
var HUMAN = 2; | |
it('should return COMPUTER if the computer has won', function () { | |
var state = [1, 1, 1, -1, -1, -1, -1, 2, 2]; | |
var board = new Board(state); | |
assert.equal(board.isWinner(), COMPUTER); /* assertion passes */ | |
}) |