From 19e2bf1c21a853e45db0c18133e5f1b1234ad09f Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Mon, 22 Aug 2016 17:58:28 -0500 Subject: Fix failing specs and improve html --- spec/helpers/milestones_helper_spec.rb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'spec') diff --git a/spec/helpers/milestones_helper_spec.rb b/spec/helpers/milestones_helper_spec.rb index 8e23415bfe4..d65610723b0 100644 --- a/spec/helpers/milestones_helper_spec.rb +++ b/spec/helpers/milestones_helper_spec.rb @@ -1,33 +1,35 @@ require 'spec_helper' describe MilestonesHelper do - describe '#milestone_counts' do let(:project) { FactoryGirl.create(:project) } - let(:milestone_1) { FactoryGirl.create(:active_milestone, project: project) } - let(:milestone_2) { FactoryGirl.create(:active_milestone, project: project) } - let(:milestone_3) { FactoryGirl.create(:closed_milestone, project: project) } + let!(:milestone_1) { FactoryGirl.create(:active_milestone, project: project) } + let!(:milestone_2) { FactoryGirl.create(:active_milestone, project: project) } + let!(:milestone_3) { FactoryGirl.create(:closed_milestone, project: project) } let(:counts) { helper.milestone_counts(project.milestones) } it 'returns a hash containing three items' do expect(counts.length).to eq 3 end + it 'returns a hash containing "opened" key' do expect(counts.has_key?(:opened)).to eq true end + it 'returns a hash containing "closed" key' do expect(counts.has_key?(:closed)).to eq true end + it 'returns a hash containing "all" key' do expect(counts.has_key?(:all)).to eq true end - # This throws a "NoMethodError: undefined method `+' for nil:NilClass" error for line 27; can't figure out why it can't find the keys in the hash - # it 'shows "all" object is the sum of "opened" and "closed" objects' do - # total = counts[:opened] + counts[:closed] - # expect(counts[:all]).to eq total - # end + it 'shows "all" object is the sum of "opened" and "closed" objects' do + puts counts.as_json + total = counts[:opened] + counts[:closed] + expect(counts[:all]).to eq total + end end - end + \ No newline at end of file -- cgit v1.2.1