diff options
author | Vinnie Okada <vokada@mrvinn.com> | 2014-10-17 08:10:50 +0400 |
---|---|---|
committer | Vinnie Okada <vokada@mrvinn.com> | 2014-10-19 02:58:34 +0400 |
commit | e1491465de441b386c72726f0b869104d1c15680 (patch) | |
tree | 9207fdd5957bda3d22946e268054f19ad8c1f093 /features/steps/shared | |
parent | cd3eabd71236d2be1430d2dbf23aad91d73aa783 (diff) |
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 'features/steps/shared')
-rw-r--r-- | features/steps/shared/diff_note.rb | 18 | ||||
-rw-r--r-- | features/steps/shared/issuable.rb | 15 | ||||
-rw-r--r-- | features/steps/shared/markdown.rb | 14 | ||||
-rw-r--r-- | features/steps/shared/note.rb | 12 |
4 files changed, 37 insertions, 22 deletions
diff --git a/features/steps/shared/diff_note.rb b/features/steps/shared/diff_note.rb index bd22e95daee..8871b93edb6 100644 --- a/features/steps/shared/diff_note.rb +++ b/features/steps/shared/diff_note.rb @@ -32,7 +32,7 @@ module SharedDiffNote click_diff_line(sample_commit.line_code) within("#{diff_file_selector} form[rel$='#{sample_commit.line_code}']") do fill_in "note[note]", with: "Should fix it :smile:" - find('.js-md-preview-button').trigger('click') + find('.js-md-preview-button').click end end @@ -41,7 +41,7 @@ module SharedDiffNote within("#{diff_file_selector} form[rel$='#{sample_commit.del_line_code}']") do fill_in "note[note]", with: "DRY this up" - find('.js-md-preview-button').trigger('click') + find('.js-md-preview-button').click end end @@ -73,7 +73,7 @@ module SharedDiffNote step 'I should not see the diff comment preview button' do within(diff_file_selector) do - page.should have_css('.js-md-preview-button', visible: false) + expect(page).not_to have_css('.js-md-preview-button') end end @@ -131,27 +131,27 @@ module SharedDiffNote step 'I should see the diff comment preview' do within("#{diff_file_selector} form") do - page.should have_css('.js-md-preview', visible: false) + expect(page).to have_css('.js-md-preview') end end step 'I should see the diff comment edit button' do within(diff_file_selector) do - page.should have_css('.js-md-write-button', visible: true) + expect(page).to have_css('.js-md-write-button') end end step 'I should see the diff comment preview button' do within(diff_file_selector) do - page.should have_css('.js-md-preview-button', visible: true) + expect(page).to have_css('.js-md-preview-button') end end step 'I should see two separate previews' do within(diff_file_selector) do - page.should have_css('.js-md-preview', visible: true, count: 2) - page.should have_content("Should fix it") - page.should have_content("DRY this up") + expect(page).to have_css('.js-md-preview', count: 2) + expect(page).to have_content("Should fix it") + expect(page).to have_content("DRY this up") end end diff --git a/features/steps/shared/issuable.rb b/features/steps/shared/issuable.rb new file mode 100644 index 00000000000..a0150e90380 --- /dev/null +++ b/features/steps/shared/issuable.rb @@ -0,0 +1,15 @@ +module SharedIssuable + include Spinach::DSL + + def edit_issuable + find('.issue-btn-group').click_link 'Edit' + end + + step 'I click link "Edit" for the merge request' do + edit_issuable + end + + step 'I click link "Edit" for the issue' do + edit_issuable + end +end diff --git a/features/steps/shared/markdown.rb b/features/steps/shared/markdown.rb index f3e61aa8e49..df4514b5646 100644 --- a/features/steps/shared/markdown.rb +++ b/features/steps/shared/markdown.rb @@ -56,27 +56,27 @@ EOT end step 'I should not see the Markdown preview' do - find('.gfm-form').should have_css('.js-md-preview', visible: false) + expect(find('.gfm-form')).not_to have_css('.js-md-preview') end step 'I should not see the Markdown preview button' do - find('.gfm-form').should have_css('.js-md-preview-button', visible: false) + expect(find('.gfm-form')).not_to have_css('.js-md-preview-button') end step 'I should not see the Markdown text field' do - find('.gfm-form').should have_css('textarea', visible: false) + expect(find('.gfm-form')).not_to have_css('textarea') end step 'I should see the Markdown edit button' do - find('.gfm-form').should have_css('.js-md-write-button', visible: true) + expect(find('.gfm-form')).to have_css('.js-md-write-button') end step 'I should see the Markdown preview' do - find('.gfm-form').should have_css('.js-md-preview', visible: true) + expect(find('.gfm-form')).to have_css('.js-md-preview') end step 'I should see the Markdown preview button' do - find('.gfm-form').should have_css('.js-md-preview-button', visible: true) + expect(find('.gfm-form')).to have_css('.js-md-preview-button') end step 'I write a description like "Nice"' do @@ -86,7 +86,7 @@ EOT step 'I preview a description text like "Bug fixed :smile:"' do within('.gfm-form') do fill_in 'Description', with: 'Bug fixed :smile:' - find('.js-md-preview-button').trigger('click') + find('.js-md-preview-button').click() end end diff --git a/features/steps/shared/note.rb b/features/steps/shared/note.rb index e298312f065..a83f74228af 100644 --- a/features/steps/shared/note.rb +++ b/features/steps/shared/note.rb @@ -23,7 +23,7 @@ module SharedNote step 'I preview a comment text like "Bug fixed :smile:"' do within(".js-main-target-form") do fill_in "note[note]", with: "Bug fixed :smile:" - find('.js-md-preview-button').trigger('click') + find('.js-md-preview-button').click end end @@ -51,13 +51,13 @@ module SharedNote step 'I should not see the comment preview' do within(".js-main-target-form") do - page.should have_css('.js-md-preview', visible: false) + expect(page).not_to have_css('.js-md-preview') end end step 'I should not see the comment preview button' do within(".js-main-target-form") do - page.should have_css('.js-md-preview-button', visible: false) + expect(page).not_to have_css('.js-md-preview-button') end end @@ -81,19 +81,19 @@ module SharedNote step 'I should see the comment edit button' do within(".js-main-target-form") do - page.should have_css('.js-md-write-button', visible: true) + expect(page).to have_css('.js-md-write-button') end end step 'I should see the comment preview' do within(".js-main-target-form") do - page.should have_css('.js-md-preview', visible: true) + expect(page).to have_css('.js-md-preview') end end step 'I should see the comment preview button' do within(".js-main-target-form") do - page.should have_css('.js-md-preview-button', visible: true) + expect(page).to have_css('.js-md-preview-button') end end |