Add sluggable shared example for Sluggable concern
Why: * We need certain models that use a Sluggable to generate a slug based on name attribute on save How: * Creating a shared example that knows how to create a factory of the described class * Checking in it that new objects of the described class get the correct slug
This commit is contained in:
16
spec/models/concerns/sluggable.rb
Normal file
16
spec/models/concerns/sluggable.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
require 'spec_helper'
|
||||
|
||||
shared_examples_for 'sluggable' do
|
||||
|
||||
describe 'generate_slug' do
|
||||
before do
|
||||
create(described_class.name.parameterize.tr('-', '_').to_sym, name: "Marlo Brañido Carlo")
|
||||
end
|
||||
|
||||
context "when a new sluggable is created" do
|
||||
it "gets a slug string" do
|
||||
expect(described_class.last.slug).to eq("marlo-branido-carlo")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user