diff --git a/.rspec b/.rspec index f3308b8..6378586 100644 --- a/.rspec +++ b/.rspec @@ -1,3 +1,2 @@ --require rails_helper --format documentation ---profile diff --git a/Rakefile b/Rakefile index e318f19..33129e7 100644 --- a/Rakefile +++ b/Rakefile @@ -5,7 +5,10 @@ require 'bundler/gem_tasks' begin 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 rescue LoadError diff --git a/spec/system/quill_editor_spec.rb b/spec/system/quill_editor_spec.rb index b5f1148..5505ae4 100644 --- a/spec/system/quill_editor_spec.rb +++ b/spec/system/quill_editor_spec.rb @@ -9,12 +9,12 @@ RSpec.describe 'Quill editor', type: :system do end after do - Post.destroy_all - author.destroy + Post.delete_all + author.delete end context 'with a Quill editor' do - it 'updates some HTML content' do + it 'initialize the editor' do visit "/admin/posts/#{post.id}/edit" %w[bold italic underline link].each do |button| @@ -22,13 +22,37 @@ RSpec.describe 'Quill editor', type: :system do end expect(page).to have_css('#post_description[data-aa-quill-editor]') 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').base.send_keys('more text') - find('[type="submit"]').click expect(page).to have_content('was successfully updated') expect(post.reload.description).to eq '

Some content...more text

' 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 '

Some content...more text

' + 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 '

Some content...more text

' + end end context 'with a Quill editor in a nested resource' do