summaryrefslogtreecommitdiff
path: root/spec/features
diff options
context:
space:
mode:
authorVinnie Okada <vokada@mrvinn.com>2014-10-16 23:10:50 -0500
committerVinnie Okada <vokada@mrvinn.com>2014-10-18 17:58:34 -0500
commite1491465de441b386c72726f0b869104d1c15680 (patch)
tree9207fdd5957bda3d22946e268054f19ad8c1f093 /spec/features
parentcd3eabd71236d2be1430d2dbf23aad91d73aa783 (diff)
downloadgitlab-ce-e1491465de441b386c72726f0b869104d1c15680.tar.gz
Refactor Markdown preview tests
Create a new shared module for common issue/merge request behavior, use `expect` syntax instead of `should`, and avoid `visible: false` in the `have_css` matcher.
Diffstat (limited to 'spec/features')
-rw-r--r--spec/features/notes_on_merge_requests_spec.rb24
1 files changed, 15 insertions, 9 deletions
diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb
index bf3c12012e5..36394265abf 100644
--- a/spec/features/notes_on_merge_requests_spec.rb
+++ b/spec/features/notes_on_merge_requests_spec.rb
@@ -19,8 +19,10 @@ describe 'Comments' do
it 'should be valid' do
should have_css(".js-main-target-form", visible: true, count: 1)
find(".js-main-target-form input[type=submit]").value.should == "Add Comment"
- within(".js-main-target-form") { should_not have_link("Cancel") }
- within('.js-main-target-form') { should have_css('.js-md-preview-button', visible: false) }
+ within('.js-main-target-form') do
+ expect(page).not_to have_link('Cancel')
+ expect(page).not_to have_css('.js-md-preview-button', visible: true)
+ end
end
describe "with text" do
@@ -31,8 +33,10 @@ describe 'Comments' do
end
it 'should have enable submit button and preview button' do
- within(".js-main-target-form") { should_not have_css(".js-comment-button[disabled]") }
- within('.js-main-target-form') { should have_css('.js-md-preview-button', visible: true) }
+ within(".js-main-target-form") do
+ expect(page).not_to have_css(".js-comment-button[disabled]")
+ expect(page).to have_css('.js-md-preview-button')
+ end
end
end
end
@@ -41,15 +45,17 @@ describe 'Comments' do
before do
within(".js-main-target-form") do
fill_in "note[note]", with: "This is awsome!"
- find('.js-md-preview-button').trigger('click')
+ find('.js-md-preview-button').click
click_button "Add Comment"
end
end
it 'should be added and form reset' do
should have_content("This is awsome!")
- within(".js-main-target-form") { should have_no_field("note[note]", with: "This is awesome!") }
- within('.js-main-target-form') { should have_css('.js-md-preview', visible: false) }
+ within(".js-main-target-form") do
+ expect(page).to have_no_field("note[note]", with: "This is awesome!")
+ expect(page).not_to have_css('.js-md-preview', visible: true)
+ end
within(".js-main-target-form") { should have_css(".js-note-text", visible: true) }
end
end
@@ -172,11 +178,11 @@ describe 'Comments' do
# add two separate texts and trigger previews on both
within("tr[id='#{line_code}'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "One comment on line 7"
- find('.js-md-preview-button').trigger('click')
+ find('.js-md-preview-button').click
end
within("tr[id='#{line_code_2}'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "Another comment on line 10"
- find('.js-md-preview-button').trigger('click')
+ find('.js-md-preview-button').click
end
end
end