forked from tkbb/bop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add spec ApplicationHelper#days_of_a_month
- Loading branch information
1 parent
8f7d453
commit 8c97d4b
Showing
2 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
describe ApplicationHelper do | ||
describe '#days_of_a_month' do | ||
let(:now) { Time.now } | ||
subject { helper.days_of_a_month } | ||
This comment has been minimized.
Sorry, something went wrong. |
||
describe 'size' do | ||
it { subject.size.should == Time.days_in_month(now.month) } | ||
This comment has been minimized.
Sorry, something went wrong. |
||
end | ||
describe 'first' do | ||
it { subject.first.should == now.beginning_of_month.strftime("%Y/%m/%d(#{I18n.t('date.abbr_day_names')[now.beginning_of_month.wday]})") } | ||
end | ||
describe 'last' do | ||
it { subject.last.should == now.end_of_month.strftime("%Y/%m/%d(#{I18n.t('date.abbr_day_names')[now.end_of_month.wday]})") } | ||
end | ||
end | ||
end |
2 comments
on commit 8c97d4b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このテストがまったくわからないのでどういうテストなのか教えて欲しいー。
subject.size.shouldってどういうのが帰ってくるのかな?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参考
"RSpec の入門とその一歩先へ - t-wadaの日記" http://d.hatena.ne.jp/t-wada/20100228/p1
"RSpecによるユニットテストの書き方 - tech.recompile.net" http://tech.recompile.net/post/21340599029/rspec
ここでsubjectの設定してます