From a3bc76ca40be53a47e530ed91819e9b8483de7bb Mon Sep 17 00:00:00 2001 From: Chris Schlaeger Date: Sun, 12 Apr 2015 20:22:01 +0200 Subject: New: Adding a personal record view including yearly records. --- spec/View_spec.rb | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 spec/View_spec.rb (limited to 'spec') diff --git a/spec/View_spec.rb b/spec/View_spec.rb new file mode 100644 index 0000000..7a90a01 --- /dev/null +++ b/spec/View_spec.rb @@ -0,0 +1,61 @@ +#!/usr/bin/env ruby -w +# encoding: UTF-8 +# +# = View_spec.rb -- PostRunner - Manage the data from your Garmin sport devices. +# +# Copyright (c) 2015 by Chris Schlaeger +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# + +require 'postrunner/View' +require 'postrunner/ViewButtons' +require 'postrunner/PagingButtons' + +module PostRunner + + describe PostRunner::View do + + before(:all) do + @view_names = %w( activities record ) + delete_files + end + + after(:all) do + delete_files + end + + def delete_files + @view_names.each do |vn| + page_files(vn).each do |pf| + File.delete(pf) if File.exists?(pf) + end + end + end + + def page_files(vn) + 1.upto(vn == 'record' ? 5 : 3).map { |i| "#{vn}-page#{i}.html" } + end + + it 'should generate view files with multiple pages' do + views = ViewButtons.new( + @view_names.map{ |vn| NavButtonDef. + new("#{vn}.png", "#{vn}-page1.html") } + ) + @view_names.each do |vn| + views.current_page = vn + '-page1.html' + pages = PagingButtons.new(page_files(vn)) + page_files(vn).each do |file| + pages.current_page = file + PostRunner::View.new("Test File: #{file}", views, pages).body. + write(file) + File.exists?(file).should be true + end + end + end + + end + +end -- cgit v1.2.3