зеркало из
https://github.com/rs-pro/activeadmin-quill_editor.git
synced 2026-09-07 20:15:51 +03:00
Improve specs
- Add test examples for bold and italic content - Move some test examples - Adjust RSpec options
Этот коммит содержится в:
1
.rspec
1
.rspec
@@ -1,3 +1,2 @@
|
|||||||
--require rails_helper
|
--require rails_helper
|
||||||
--format documentation
|
--format documentation
|
||||||
--profile
|
|
||||||
|
|||||||
5
Rakefile
5
Rakefile
@@ -5,7 +5,10 @@ require 'bundler/gem_tasks'
|
|||||||
begin
|
begin
|
||||||
require 'rspec/core/rake_task'
|
require 'rspec/core/rake_task'
|
||||||
|
|
||||||
RSpec::Core::RakeTask.new(:spec)
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
||||||
|
# t.ruby_opts = %w[-w]
|
||||||
|
t.rspec_opts = ['--color', '--format documentation']
|
||||||
|
end
|
||||||
|
|
||||||
task default: :spec
|
task default: :spec
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ RSpec.describe 'Quill editor', type: :system do
|
|||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
Post.destroy_all
|
Post.delete_all
|
||||||
author.destroy
|
author.delete
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a Quill editor' do
|
context 'with a Quill editor' do
|
||||||
it 'updates some HTML content' do
|
it 'initialize the editor' do
|
||||||
visit "/admin/posts/#{post.id}/edit"
|
visit "/admin/posts/#{post.id}/edit"
|
||||||
|
|
||||||
%w[bold italic underline link].each do |button|
|
%w[bold italic underline link].each do |button|
|
||||||
@@ -22,13 +22,37 @@ RSpec.describe 'Quill editor', type: :system do
|
|||||||
end
|
end
|
||||||
expect(page).to have_css('#post_description[data-aa-quill-editor]')
|
expect(page).to have_css('#post_description[data-aa-quill-editor]')
|
||||||
expect(page).to have_css('#post_description_input .ql-editor', text: 'Some content...')
|
expect(page).to have_css('#post_description_input .ql-editor', text: 'Some content...')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'adds some text to the description' do
|
||||||
|
visit "/admin/posts/#{post.id}/edit"
|
||||||
|
|
||||||
find('#post_description_input .ql-editor').click
|
find('#post_description_input .ql-editor').click
|
||||||
find('#post_description_input .ql-editor').base.send_keys('more text')
|
find('#post_description_input .ql-editor').base.send_keys('more text')
|
||||||
|
|
||||||
find('[type="submit"]').click
|
find('[type="submit"]').click
|
||||||
expect(page).to have_content('was successfully updated')
|
expect(page).to have_content('was successfully updated')
|
||||||
expect(post.reload.description).to eq '<p>Some content...more text</p>'
|
expect(post.reload.description).to eq '<p>Some content...more text</p>'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'adds some bold text to the description' do
|
||||||
|
visit "/admin/posts/#{post.id}/edit"
|
||||||
|
|
||||||
|
find('#post_description_input .ql-editor').click
|
||||||
|
find('#post_description_input .ql-toolbar .ql-bold').click
|
||||||
|
find('#post_description_input .ql-editor').base.send_keys('more text')
|
||||||
|
find('[type="submit"]').click
|
||||||
|
expect(post.reload.description).to eq '<p>Some content...<strong>more text</strong></p>'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'adds some italic text to the description' do
|
||||||
|
visit "/admin/posts/#{post.id}/edit"
|
||||||
|
|
||||||
|
find('#post_description_input .ql-editor').click
|
||||||
|
find('#post_description_input .ql-toolbar .ql-italic').click
|
||||||
|
find('#post_description_input .ql-editor').base.send_keys('more text')
|
||||||
|
find('[type="submit"]').click
|
||||||
|
expect(post.reload.description).to eq '<p>Some content...<em>more text</em></p>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a Quill editor in a nested resource' do
|
context 'with a Quill editor in a nested resource' do
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user