diff options
| author | mo khan <mo@mokhan.ca> | 2016-06-28 13:28:47 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2016-06-28 13:28:47 -0600 |
| commit | e67c7c8e687c092218dffc7cd540dafab3a98d00 (patch) | |
| tree | 1a51199a5fcb271a2d68326cd599bf0794d345fc /spec/models/program_spec.rb | |
| parent | ce0a43259ccbe089499e8d09ed6794a9eaa0c53a (diff) | |
increment weight for squat.
Diffstat (limited to 'spec/models/program_spec.rb')
| -rw-r--r-- | spec/models/program_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/models/program_spec.rb b/spec/models/program_spec.rb index db63da0..192d5d2 100644 --- a/spec/models/program_spec.rb +++ b/spec/models/program_spec.rb @@ -13,4 +13,37 @@ describe Program do expect(Program.stronglifts).to eql(program) end end + + describe "#prepare_sets_for" do + include_context "stronglifts_program" + subject { Program.stronglifts } + + describe "squat" do + let(:user) { build(:user) } + + it 'returns 5 sets of 5 repetitions' do + sets = subject.prepare_sets_for(user, squat) + expect(sets.length).to eql(5) + expect(sets.map(&:target_repetitions)).to match_array([5, 5, 5, 5, 5]) + end + + it 'returns the correct exercise for each set' do + sets = subject.prepare_sets_for(user, squat) + expect(sets.map(&:exercise).uniq).to match_array([squat]) + end + + it 'returns 45 lbs for the first workout' do + sets = subject.prepare_sets_for(user, squat) + expect(sets.map(&:target_weight).uniq).to match_array([45.lbs]) + end + + it 'returns 50 lbs for the second workout' do + workout = create(:workout, user: user, routine: routine_a) + 5.times { workout.train(squat, 45, repetitions: 5) } + + sets = subject.prepare_sets_for(user, squat) + expect(sets.map(&:target_weight).uniq).to match_array([50.lbs]) + end + end + end end |
