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 TEST### | |
describe "POST /account/orders/bids/create" do | |
let(:account) { Account.create(dollars: 100, josh_coins: 100, user_id: "1234", email: "[email protected]") } | |
describe "returns correct bid information" do | |
before do | |
@account = account |
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
###CART_CONTROLLER_SPEC | |
describe "method calls" do | |
before { @product = create(:product) } | |
it "new cart is passed current_user" do | |
expect(Cart).to receive(:new).with(@current_user).and_call_original | |
patch :remove_product, {id: @product.id} | |
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
{ | |
[ | |
{ | |
"user_id" : 2, | |
"tweets" : [ | |
{ | |
"content" : "blah blah blah blah", | |
"hashtags" : ["this", "that"] | |
}, | |
{ |
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
$cipher = { | |
"C" => 100, | |
"XC" => 90, | |
"L" => 50, | |
"XL" => 40, | |
"X" => 10, | |
"IX" => 9, | |
"V" => 5, | |
"IV" => 4, | |
"I" => 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
<!-- sinatra only support HTTP verbs GET and POST, so to implement PUT + DELETE HTTP verbs we need to hack a little bit--> | |
<form action='/tweets/<%=tweet.id%>' method='post'> | |
<input type='hidden' name='_method' value='delete' /> | |
<!-- here, we have a hidden input which magically turns this post request into a delete request. how nice. --> | |
<input type='submit' value='X' /> | |
</form> | |
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 CONTEXT | |
class Person | |
def self.example_class_method | |
puts "We're calling an example class method" | |
puts "'self' is always defined. What is 'self' here? Let's see." | |
p self | |
puts "That was self!" | |
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
# here's a simple example of driving your design using tests. | |
# by running this code and solving the failing tests one by one | |
# you should be able to finish this challenge easily. | |
# ask for help if you get stuck. | |
# consider all the questions (Q:) as you encounter them | |
# in this universe ... | |
# - people own pets | |
# - pets eat and walk |
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 SuperPowers | |
attr_accessor :magic_points | |
def initialize | |
super | |
@magic_points = 0 | |
end | |
def use_laser_vision | |
@magic_points += 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
require 'spec_helper' | |
describe "account_controller" do | |
describe "GET /accounts" do | |
let(:first_account) { Account.create(dollars: 100, josh_coins: 100, user_id: "1234", email: "[email protected]") } | |
let(:second_account) { Account.create(dollars: 200, josh_coins: 200, user_id: "3456", email: "[email protected]") } | |
let(:third_account) { Account.create(dollars: 300, josh_coins: 300, user_id: "3156", email: "[email protected]") } |
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
# This is how you define your own custom exception classes | |
class NoOrangesError < StandardError | |
end | |
class OrangeTree | |
attr_reader :height, :age | |
MAX_AGE = 13 | |
FRUIT_BEARING_AGE = 4 | |
# Ages the tree one year |
OlderNewer