Skip to content

Commit e220e90

Browse files
authored
Merge pull request #1765 from hennevogel/spec/to-change
Drop ".to change" from comment feature spec
2 parents ea7c708 + 2db96a9 commit e220e90

1 file changed

Lines changed: 24 additions & 28 deletions

File tree

spec/features/comment_spec.rb

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
feature 'Comment' do
44
let(:user) { create :user }
5+
let(:project) { create(:idea, originator: user) }
6+
let(:project_with_comments) { create(:idea, :with_comments, originator: user) }
7+
let(:comment_text) { Faker::Lorem.sentence }
58

69
before :each do
710
sign_in user
811
end
912

1013
scenario 'markdown preview', :js do
11-
project = create(:invention, originator: user, users: [user])
12-
1314
visit project_path(:all, project)
1415
fill_in 'comment_text', with: '_italic_ **bold** :smile: @user'
1516
click_on 'Preview'
@@ -21,48 +22,43 @@
2122
end
2223

2324
scenario 'create', :js do
24-
project = create(:idea, originator: user)
25-
comment_text = Faker::Lorem.sentence
26-
2725
visit project_path(nil, project)
26+
2827
within('#comments_form_section') do
2928
fill_in 'comment_text', with: comment_text
3029
end
3130

32-
expect do
33-
within('#comments_form_section') do
34-
click_on 'Create Comment'
35-
end
36-
end.to change(project.comments, :count).by(1)
37-
expect(page).to have_text comment_text
31+
within('#comments_form_section') do
32+
click_on 'Create Comment'
33+
end
34+
35+
within('#comments_section') do
36+
expect(page).to have_text comment_text
37+
end
3838
end
3939

4040
scenario 'reply to a comment', :js do
41-
project = create(:idea, :with_comments, originator: user)
42-
reply_text = 'You are wrong on the internet!'
43-
first_comment = project.comments.first
41+
visit project_path(nil, project_with_comments)
4442

45-
visit project_path(nil, project)
46-
47-
within("li#comment_#{first_comment.id}") do
43+
within("#comment_#{project_with_comments.comments.first.id}") do
4844
click_on 'Reply'
4945
end
5046

51-
within("#replyCommentcomment_#{first_comment.id}") do
52-
fill_in 'comment_text', with: reply_text
47+
within("#replyCommentcomment_#{project_with_comments.comments.first.id}") do
48+
fill_in 'comment_text', with: 'You are wrong on the internet!'
49+
end
50+
51+
within("#replyCommentcomment_#{project_with_comments.comments.first.id}") do
52+
click_on 'Create Comment'
5353
end
5454

55-
expect do
56-
within("#replyCommentcomment_#{first_comment.id}") do
57-
click_on 'Create Comment'
58-
end
59-
end.to change(first_comment.comments, :count).by(1)
55+
within("#comment_#{project_with_comments.comments.first.id}") do
56+
expect(page).to have_text 'You are wrong on the internet!'
57+
end
6058
end
6159

6260
scenario 'update', :js do
63-
project = create(:idea, originator: user)
6461
comment = create(:comment, commenter: user, commentable: project)
65-
update_text = Faker::Lorem.sentence
6662

6763
visit project_path(nil, project)
6864

@@ -71,12 +67,12 @@
7167
end
7268

7369
within("#editCommentcomment_#{comment.id}") do
74-
fill_in 'comment_text', with: update_text
70+
fill_in 'comment_text', with: comment_text
7571
click_on 'Update Comment'
7672
end
7773

7874
within("li#comment_#{comment.id}") do
79-
expect(page).to have_text update_text
75+
expect(page).to have_text comment_text
8076
end
8177
end
8278
end

0 commit comments

Comments
 (0)