Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 6 commits
  • 11 files changed
  • 0 comments
  • 1 contributor
4 .components
... ... @@ -1,7 +1,7 @@
1 1 ---
2 2 :orm: mongoid
3   -:test: none
4   -:mock: none
  3 +:test: minitest
  4 +:mock: mocha
5 5 :script: jquery
6 6 :renderer: haml
7 7 :stylesheet: scss
3  Gemfile
@@ -18,6 +18,9 @@ gem 'mongoid'
18 18 gem 'bson_ext', :require => "mongo"
19 19
20 20 # Test requirements
  21 +gem 'mocha', :group => "test"
  22 +gem 'minitest', "~>2.6.0", :require => "minitest/autorun", :group => "test"
  23 +gem 'rack-test', :require => "rack/test", :group => "test"
21 24
22 25 # Padrino Stable Gem
23 26 gem 'padrino', '0.10.5'
9 Gemfile.lock
@@ -31,8 +31,12 @@ GEM
31 31 i18n (>= 0.4.0)
32 32 mime-types (~> 1.16)
33 33 treetop (~> 1.4.8)
  34 + metaclass (0.0.1)
34 35 method_source (0.7.0)
35 36 mime-types (1.17.2)
  37 + minitest (2.6.2)
  38 + mocha (0.10.4)
  39 + metaclass (~> 0.0.1)
36 40 mongo (1.5.2)
37 41 bson (= 1.5.2)
38 42 mongoid (2.4.3)
@@ -80,6 +84,8 @@ GEM
80 84 rack
81 85 rack-protection (1.2.0)
82 86 rack
  87 + rack-test (0.6.1)
  88 + rack (>= 1.0)
83 89 rake (0.9.2.2)
84 90 sass (3.1.13)
85 91 sinatra (1.3.2)
@@ -105,10 +111,13 @@ DEPENDENCIES
105 111 bson_ext
106 112 coffee-script
107 113 haml
  114 + minitest (~> 2.6.0)
  115 + mocha
108 116 mongoid
109 117 padrino (= 0.10.5)
110 118 pry-padrino
111 119 rack-coffee
  120 + rack-test
112 121 rake
113 122 sass
114 123 sinatra-flash
2  app/controllers.rb
... ... @@ -1,7 +1,7 @@
1 1 Kakeibo.controllers do
2 2
3 3 get :index do
4   - @budget = Budget.all
  4 + @budget = Budget.all.desc(:yearmonth)
5 5 haml :list
6 6 end
7 7
7 app/stylesheets/style.scss
... ... @@ -1,5 +1,4 @@
1 1 body {
2   - padding-top: 40px;
3 2 h1 {
4 3 display: inline-block;
5 4 }
@@ -12,12 +11,6 @@ body {
12 11 .brand {
13 12 float: right;
14 13 }
15   - form {
16   - margin: 6px 0 0 0;
17   - * {
18   - margin: 0 !important;
19   - }
20   - }
21 14 }
22 15 .price {
23 16 text-align: right;
6 app/views/layouts/application.haml
@@ -4,15 +4,15 @@
4 4 = javascript_include_tag 'jquery', 'application'
5 5 %title かけいぼ!
6 6
7   -.navbar.navbar-fixed-top
  7 +.navbar
8 8 .navbar-inner
9 9 .container
10   - .brand かけいぼ!
11   - - form_tag '/', :method => 'post' do
  10 + - form_tag '/', :class => 'navbar-form pull-left', :method => 'post' do
12 11 = select_tag :genre, :options => CONFIG.to_a.map{|genre| genre.reverse}, :class => 'span2'
13 12 = text_field_tag :title, :value => params[:title], :placeholder => 'なにに', :required => '', :class => 'span3'
14 13 = text_field_tag :price, :value => params[:price], :placeholder => 'いくら', :type => 'number', :required => '', :step => '100', :min => '100'
15 14 = submit_tag 'つかった', :class => 'btn'
  15 + .brand かけいぼ!
16 16
17 17 .container
18 18 = yield
12 test/controller/controller_test.rb
... ... @@ -0,0 +1,12 @@
  1 +# -*- encoding: utf-8 -*-
  2 +require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
  3 +
  4 +def app() Sinatra::Application end
  5 +
  6 +describe 'root' do
  7 + it 'should display layout' do
  8 + get '/'
  9 + assert last_response.ok?
  10 + assert_send [last_response.body, :include?, "かけいぼ!"]
  11 + end
  12 +end
19 test/models/budget_test.rb
... ... @@ -0,0 +1,19 @@
  1 +require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
  2 +
  3 +describe "Budget Model" do
  4 + it 'can construct a new instance' do
  5 + @budget = Budget.new
  6 + refute_nil @budget
  7 + end
  8 +
  9 + it 'update_total return total' do
  10 + @budget = Budget.create(yearmonth: '201202')
  11 + @budget.payments.create(price: 100)
  12 + @budget.update_total
  13 + assert(100 == @budget.total)
  14 +
  15 + @budget.payments.create(price: 20)
  16 + @budget.update_total
  17 + assert(120 == @budget.total)
  18 + end
  19 +end
8 test/models/payment_test.rb
... ... @@ -0,0 +1,8 @@
  1 +require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
  2 +
  3 +describe "Payment Model" do
  4 + it 'can construct a new instance' do
  5 + @payment = Payment.new
  6 + refute_nil @payment
  7 + end
  8 +end
13 test/test.rake
... ... @@ -0,0 +1,13 @@
  1 +require 'rake/testtask'
  2 +
  3 +test_tasks = Dir['test/*/'].map { |d| File.basename(d) }
  4 +
  5 +test_tasks.each do |folder|
  6 + Rake::TestTask.new("test:#{folder}") do |test|
  7 + test.pattern = "test/#{folder}/**/*_test.rb"
  8 + test.verbose = true
  9 + end
  10 +end
  11 +
  12 +desc "Run application test suite"
  13 +task 'test' => test_tasks.map { |f| "test:#{f}" }
14 test/test_config.rb
... ... @@ -0,0 +1,14 @@
  1 +PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
  2 +require File.expand_path('../../config/boot', __FILE__)
  3 +
  4 +class MiniTest::Unit::TestCase
  5 + include Mocha::API
  6 + include Rack::Test::Methods
  7 +
  8 + def app
  9 + ##
  10 + # You can handle all padrino applications using instead:
  11 + # Padrino.application
  12 + Kakeibo.tap { |app| }
  13 + end
  14 +end

No commit comments for this range

Something went wrong with that request. Please try again.