mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Refactor abstract_word_count method
This commit is contained in:
parent
9f3da955f0
commit
80f8bba951
2 changed files with 21 additions and 5 deletions
20
spec/models/event_spec.rb
Normal file
20
spec/models/event_spec.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Event do
|
||||
|
||||
describe 'abstract_word_count' do
|
||||
it 'counts words in abstract' do
|
||||
event = build(:event)
|
||||
expect(event.abstract_word_count).to eq(233)
|
||||
event.update_attributes!(abstract: "abstract.")
|
||||
expect(event.abstract_word_count).to eq(1)
|
||||
end
|
||||
|
||||
it 'counts 0 when abstract is empty' do
|
||||
event = build(:event, abstract: nil)
|
||||
expect(event.abstract_word_count).to eq(0)
|
||||
event.abstract = ""
|
||||
expect(event.abstract_word_count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue