I switch how to test depending on context as follows
> cat spec_helper.rb
def each_store(&block)
context 'with old storage', with_elasticsearch: false do
self.class_eval(&block)
end
context 'with Elasticsearch', with_elasticsearch: true do
def case_create
:
end
self.class_eval(&block)
end
end
> cat foo_spec.rb
describe 'foo' do
context 'with default settings' do
it do |ex|
if ex.metadata[:with_elasticsearch]
expect(something).to match /foo/
else
expect(something).not_to match /foo/
end
end
end
end
but isn't it possible to switch not in example blocks but describe and context block such as
describe 'foo' do
context 'with default settings' do |c|
if c.metadata[:with_elasticsearch]
it 'should match'
else
it 'should not match'
end
end
end
as I'd like to use different strings as the first argument of it method depending on the store.
Aucun commentaire:
Enregistrer un commentaire