Reduce factory creation (17 -> 0) in PlainTextFormatter spec (#32487)
		
	This commit is contained in:
		
					parent
					
						
							
								92c8860451
							
						
					
				
			
			
				commit
				
					
						b742ce9d09
					
				
			
		
					 1 changed files with 10 additions and 10 deletions
				
			
		|  | @ -7,7 +7,7 @@ RSpec.describe PlainTextFormatter do | |||
|     subject { described_class.new(status.text, status.local?).to_s } | ||||
| 
 | ||||
|     context 'when status is local' do | ||||
|       let(:status) { Fabricate(:status, text: '<p>a text by a nerd who uses an HTML tag in text</p>', uri: nil) } | ||||
|       let(:status) { Fabricate.build(:status, text: '<p>a text by a nerd who uses an HTML tag in text</p>', uri: nil) } | ||||
| 
 | ||||
|       it 'returns the raw text' do | ||||
|         expect(subject).to eq '<p>a text by a nerd who uses an HTML tag in text</p>' | ||||
|  | @ -15,10 +15,10 @@ RSpec.describe PlainTextFormatter do | |||
|     end | ||||
| 
 | ||||
|     context 'when status is remote' do | ||||
|       let(:remote_account) { Fabricate(:account, domain: 'remote.test', username: 'bob', url: 'https://remote.test/') } | ||||
|       let(:remote_account) { Fabricate.build(:account, domain: 'remote.test', username: 'bob', url: 'https://remote.test/') } | ||||
| 
 | ||||
|       context 'when text contains inline HTML tags' do | ||||
|         let(:status) { Fabricate(:status, account: remote_account, text: '<b>Lorem</b> <em>ipsum</em>') } | ||||
|         let(:status) { Fabricate.build(:status, account: remote_account, text: '<b>Lorem</b> <em>ipsum</em>') } | ||||
| 
 | ||||
|         it 'strips the tags' do | ||||
|           expect(subject).to eq 'Lorem ipsum' | ||||
|  | @ -26,7 +26,7 @@ RSpec.describe PlainTextFormatter do | |||
|       end | ||||
| 
 | ||||
|       context 'when text contains <p> tags' do | ||||
|         let(:status) { Fabricate(:status, account: remote_account, text: '<p>Lorem</p><p>ipsum</p>') } | ||||
|         let(:status) { Fabricate.build(:status, account: remote_account, text: '<p>Lorem</p><p>ipsum</p>') } | ||||
| 
 | ||||
|         it 'inserts a newline' do | ||||
|           expect(subject).to eq "Lorem\nipsum" | ||||
|  | @ -34,7 +34,7 @@ RSpec.describe PlainTextFormatter do | |||
|       end | ||||
| 
 | ||||
|       context 'when text contains a single <br> tag' do | ||||
|         let(:status) { Fabricate(:status, account: remote_account, text: 'Lorem<br>ipsum') } | ||||
|         let(:status) { Fabricate.build(:status, account: remote_account, text: 'Lorem<br>ipsum') } | ||||
| 
 | ||||
|         it 'inserts a newline' do | ||||
|           expect(subject).to eq "Lorem\nipsum" | ||||
|  | @ -42,7 +42,7 @@ RSpec.describe PlainTextFormatter do | |||
|       end | ||||
| 
 | ||||
|       context 'when text contains consecutive <br> tag' do | ||||
|         let(:status) { Fabricate(:status, account: remote_account, text: 'Lorem<br><br><br>ipsum') } | ||||
|         let(:status) { Fabricate.build(:status, account: remote_account, text: 'Lorem<br><br><br>ipsum') } | ||||
| 
 | ||||
|         it 'inserts a single newline' do | ||||
|           expect(subject).to eq "Lorem\nipsum" | ||||
|  | @ -50,7 +50,7 @@ RSpec.describe PlainTextFormatter do | |||
|       end | ||||
| 
 | ||||
|       context 'when text contains HTML entity' do | ||||
|         let(:status) { Fabricate(:status, account: remote_account, text: 'Lorem & ipsum ❤') } | ||||
|         let(:status) { Fabricate.build(:status, account: remote_account, text: 'Lorem & ipsum ❤') } | ||||
| 
 | ||||
|         it 'unescapes the entity' do | ||||
|           expect(subject).to eq 'Lorem & ipsum ❤' | ||||
|  | @ -58,7 +58,7 @@ RSpec.describe PlainTextFormatter do | |||
|       end | ||||
| 
 | ||||
|       context 'when text contains <script> tag' do | ||||
|         let(:status) { Fabricate(:status, account: remote_account, text: 'Lorem <script> alert("Booh!") </script>ipsum') } | ||||
|         let(:status) { Fabricate.build(:status, account: remote_account, text: 'Lorem <script> alert("Booh!") </script>ipsum') } | ||||
| 
 | ||||
|         it 'strips the tag and its contents' do | ||||
|           expect(subject).to eq 'Lorem ipsum' | ||||
|  | @ -66,7 +66,7 @@ RSpec.describe PlainTextFormatter do | |||
|       end | ||||
| 
 | ||||
|       context 'when text contains an HTML comment tags' do | ||||
|         let(:status) { Fabricate(:status, account: remote_account, text: 'Lorem <!-- Booh! -->ipsum') } | ||||
|         let(:status) { Fabricate.build(:status, account: remote_account, text: 'Lorem <!-- Booh! -->ipsum') } | ||||
| 
 | ||||
|         it 'strips the comment' do | ||||
|           expect(subject).to eq 'Lorem ipsum' | ||||
|  | @ -74,7 +74,7 @@ RSpec.describe PlainTextFormatter do | |||
|       end | ||||
| 
 | ||||
|       context 'when text contains HTML ruby tags' do | ||||
|         let(:status) { Fabricate(:status, account: remote_account, text: '<p>Lorem <ruby>明日 <rp>(</rp><rt>Ashita</rt><rp>)</rp></ruby> ipsum</p>') } | ||||
|         let(:status) { Fabricate.build(:status, account: remote_account, text: '<p>Lorem <ruby>明日 <rp>(</rp><rt>Ashita</rt><rp>)</rp></ruby> ipsum</p>') } | ||||
| 
 | ||||
|         it 'strips the comment' do | ||||
|           expect(subject).to eq 'Lorem 明日 (Ashita) ipsum' | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue