Ok, so I ran into a very strange problem directly related to blocks. I am doing integration testing through Watir and RSpec. For a simple test, to check if the user can login, I create a user record in db using factory_girl.
So, I put the following code:
before(:each) do @user = Factory(:user) end if "should perform a login" do
In do stuff I call the browser and see how the user is trying to log in. Unfortunately, somehow he cannot do this - "The username is invalid."
After some research, I found that if I put the code to create the user in the before(:all) block, everything works magically . Like this? What is the difference between :all and :each in this context? In addition, if I put the code to create the user in the body of the test, it still does not work (i.e. the user is somehow not added to the database or something else).
rspec
gmile
source share