File: append_comment_spec.rb

package info (click to toggle)
tdiary 5.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,092 kB
  • sloc: ruby: 23,031; javascript: 1,029; xml: 325; makefile: 26; sh: 2
file content (93 lines) | stat: -rw-r--r-- 2,620 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
require 'acceptance_helper'

feature 'ツッコミの更新' do
	scenario 'ツッコミを入れてlatestとdayで表示する' do
		append_default_diary
		visit '/'
		click_link 'ツッコミを入れる'
		fill_in "name", with: "alpha"
		fill_in "body", with: <<-BODY
こんにちは!こんにちは!
BODY

		click_button '投稿'
		expect(page).to have_content "Click here!"

		visit "/"
		within('div.day div.comment div.commentshort') {
			within('span.commentator') {
				expect(page).to have_content "alpha"
			}
			expect(page).to have_content "こんにちは!こんにちは!"
		}
		today = Date.today.strftime('%Y年%m月%d日')
		page.find('h2', text: today).click_link today
		within('div.day div.comment div.commentbody') {
			within('div.commentator'){
				t = Time.now
				within('span.commenttime'){ expect(page).to have_content "%04d年%02d月%02d日" % [t.year, t.month, t.day] }
				within('span.commentator'){ expect(page).to have_content "alpha" }
			}
			expect(page).to have_content "こんにちは!こんにちは!"
		}
	end

	scenario 'ツッコミを2回入れる' do
		append_default_diary
		append_default_comment
		visit "/"
		click_link 'ツッコミを入れる'
		fill_in "name", with: "bravo"
		fill_in "body", with: <<-BODY
こんばんは!こんばんは!
BODY

		click_button '投稿'
		expect(page).to have_content "Click here!"

		visit "/"
		within('div.day div.comment div.commentshort') {
			expect(page).to have_content "alpha"
			expect(page).to have_content "bravo"
			expect(page).to have_content "こんにちは!こんにちは!"
			expect(page).to have_content "こんばんは!こんばんは!"
		}

		today = Date.today.strftime('%Y年%m月%d日')
		page.find('h2', text: today).click_link today
		within('div.day div.comment div.commentbody') {
			t = Time.now
			expect(page).to have_content "%04d年%02d月%02d日" % [t.year, t.month, t.day]
			expect(page).to have_content "alpha"
			expect(page).to have_content "bravo"
			expect(page).to have_content "こんにちは!こんにちは!"
			expect(page).to have_content "こんばんは!こんばんは!"
		}
	end

	scenario 'recent_comment3.rb' do
		append_default_diary
		visit '/'
		click_link 'ツッコミを入れる'
		fill_in "name", with: "alpha"
		fill_in "body", with: <<-BODY
こんにちは!こんにちは!
BODY

		click_button '投稿'
		expect(page).to have_content "Click here!"

		visit "/"
		within('ol.recent-comment > li') do
			expect(page).to have_content "alpha"
		end
	end
end

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3