Skip to content

Commit 5d9b6f7

Browse files
author
Mattia Roccoberton
committed
Improve specs
- Add test examples for bold and italic content - Move some test examples - Adjust RSpec options
1 parent 6fa021c commit 5d9b6f7

3 files changed

Lines changed: 32 additions & 6 deletions

File tree

.rspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
--require rails_helper
22
--format documentation
3-
--profile

Rakefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ require 'bundler/gem_tasks'
55
begin
66
require 'rspec/core/rake_task'
77

8-
RSpec::Core::RakeTask.new(:spec)
8+
RSpec::Core::RakeTask.new(:spec) do |t|
9+
# t.ruby_opts = %w[-w]
10+
t.rspec_opts = ['--color', '--format documentation']
11+
end
912

1013
task default: :spec
1114
rescue LoadError

spec/system/quill_editor_spec.rb

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,50 @@
99
end
1010

1111
after do
12-
Post.destroy_all
13-
author.destroy
12+
Post.delete_all
13+
author.delete
1414
end
1515

1616
context 'with a Quill editor' do
17-
it 'updates some HTML content' do
17+
it 'initialize the editor' do
1818
visit "/admin/posts/#{post.id}/edit"
1919

2020
%w[bold italic underline link].each do |button|
2121
expect(page).to have_css(".ql-toolbar button.ql-#{button}")
2222
end
2323
expect(page).to have_css('#post_description[data-aa-quill-editor]')
2424
expect(page).to have_css('#post_description_input .ql-editor', text: 'Some content...')
25+
end
26+
27+
it 'adds some text to the description' do
28+
visit "/admin/posts/#{post.id}/edit"
29+
2530
find('#post_description_input .ql-editor').click
2631
find('#post_description_input .ql-editor').base.send_keys('more text')
27-
2832
find('[type="submit"]').click
2933
expect(page).to have_content('was successfully updated')
3034
expect(post.reload.description).to eq '<p>Some content...more text</p>'
3135
end
36+
37+
it 'adds some bold text to the description' do
38+
visit "/admin/posts/#{post.id}/edit"
39+
40+
find('#post_description_input .ql-editor').click
41+
find('#post_description_input .ql-toolbar .ql-bold').click
42+
find('#post_description_input .ql-editor').base.send_keys('more text')
43+
find('[type="submit"]').click
44+
expect(post.reload.description).to eq '<p>Some content...<strong>more text</strong></p>'
45+
end
46+
47+
it 'adds some italic text to the description' do
48+
visit "/admin/posts/#{post.id}/edit"
49+
50+
find('#post_description_input .ql-editor').click
51+
find('#post_description_input .ql-toolbar .ql-italic').click
52+
find('#post_description_input .ql-editor').base.send_keys('more text')
53+
find('[type="submit"]').click
54+
expect(post.reload.description).to eq '<p>Some content...<em>more text</em></p>'
55+
end
3256
end
3357

3458
context 'with a Quill editor in a nested resource' do

0 commit comments

Comments
 (0)