[Stories]Changes in the database not taken into account

I have these scenarios :

Story: Filling a profile

As a user
I want to fill a profile
So that I can see my score

Scenario: Starting a new profile

...*
And 3 questions
...*
When the user answers a question

Then there should be one more answer
Then there should be one question less to answer

Scenario: Ending a profile

...*
And 1 question
...*
When the user answers a question

Then there should be one more answer
Then there should be no more question to answer
  • code hidden for clarity

If I run these two scenarios independently they both work, but when i
run them one after the other, the second scenario fails. The problem
appears in Given($amount questions?), even I create a new question in
the database, it doesn’t seem to be taken into account and keeps the 3
questions I created in the previous scenario. Here is what it looks
like :

Given("$amount questions?") do |amount|
Question.delete_all
amount.to_i.times do
Factory.create_valid_question
end
end

class Factory
def self.create_valid_question()
Question.create!(:value => "some question ")
end
end

By adding outputs I observed that during the second scenario there are
no questions in the database before the “times” loop, that they are
created inside it, but after the loop I have the same questions in the
database as the ones i had in the previous scenario and not the one i
just created through the loop. This is really strange. (Sorry for this
long question). Do you have any idea what I do wrong ?