Last active
August 29, 2015 14:10
-
-
Save JacobKorn/7ab4e42681930dbbd64d to your computer and use it in GitHub Desktop.
Anthony's Gist
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 do | |
before do | |
Account.destroy_all | |
end | |
context "#associations" do | |
it { should have_many :bids } | |
it { should have_many :asks } | |
it { should have_many :trades } | |
it "converts josh decimals to integers without loss" do | |
acc = Account.new | |
acc.josh_coins = 23.39 | |
expect(acc.raw_josh_coins).to eq(2339) | |
end | |
it "returns correct josh decimal places" do | |
acc = Account.new | |
acc.josh_coins = 23.39 | |
expect(acc.josh_coins).to eq(23.39) | |
end | |
it "converts dollar decimals to integers without loss" do | |
acc = Account.new | |
acc.dollars = 23.39 | |
expect(acc.raw_dollars).to eq(2339) | |
end | |
it "returns correct dollar decimal places" do | |
acc = Account.new | |
acc.dollars = 23.39 | |
expect(acc.dollars).to eq(23.39) | |
end | |
it "gnerates an API Key when saved" do | |
a = Account.new | |
a.dollars = 32.45 | |
a.josh_coins = 43.78 | |
a.email = "Bob@bob.charlie" | |
a.user_id = 4 | |
expect(a.valid?).to eq(true) | |
end | |
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
require 'spec_helper' | |
describe Ask do | |
context "#associations" do | |
it { should belong_to :account } | |
it { should have_many :trades } | |
it { should validate_presence_of :raw_price } | |
it { should validate_presence_of :volume } | |
it { should validate_presence_of :account } | |
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
require 'spec_helper' | |
describe Bid do | |
context "#associations" do | |
it { should belong_to :account } | |
it { should have_many :trades } | |
it { should validate_presence_of :raw_price } | |
it { should validate_presence_of :volume } | |
it { should validate_presence_of :account } | |
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
require "spec_helper" | |
describe TradingEngine do | |
describe ".process" do | |
after do | |
TradingEngine.process | |
end | |
it "creates a new instance" do | |
expect(TradingEngine).to receive(:new).and_call_original | |
end | |
it "and calls run on the new instance" do | |
engine = double("engine") | |
allow(TradingEngine).to receive(:new).and_return(engine) | |
expect(engine).to receive(:run) | |
end | |
end | |
describe "#run" do | |
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
require 'spec_helper' | |
describe Trade do | |
context "#associations" do | |
it { should belong_to :ask } | |
it { should belong_to :bid } | |
it { should belong_to :account } | |
it { should validate_presence_of :ask } | |
it { should validate_presence_of :bid } | |
it { should validate_presence_of :account } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment