-
-
Save jumpcheng/8a80f03ae9b08e095597 to your computer and use it in GitHub Desktop.
Revisions
-
stujo created this gist
May 12, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ require_relative '../app' describe Cohort do before :each do Cohort.transaction end after :each do Cohort.rollback end describe "#initialize" do it "should take value from input attributes" do cohort = Cohort.new("name" => "FierySkippers!") expect(cohort[:name]).to eq "FierySkippers!" end it "should not take value from input attributes which not in the list" do expect{ cohort = Cohort.new("made_up_attribute" => "Hello Mum!") }.to raise_error(Database::InvalidAttributeError) end end describe "::all" do it "should return an array of Cohort objects" do expect(Cohort.all[0]).to be_a Cohort end it "should return an array of count(*) length" do count = Database::Model.execute("SELECT count(*) AS CNT FROM cohorts")[0]['CNT'] expect(Cohort.all.length).to eq count end end end