1. Get a mail from a colleague this morning
When you commit code, make sure you do it with your real name, and a proper email address (your scilearn address). You can set your name like this, in the repo:
|
|
You can also do it globally, for all repos:
|
|
and check the current name and email of a repo:
|
|
Thanks!
2. factory_girl and mysql
用 truncate
清空的表 id
会从新记录, 而 delete
清空的表则不会从新记录 会继续原数据记录,当然这里 id
为自增长。
When I am writing the cucucmber features for our new project, we meet an issue:
the snippet below will not work.
|
|
If everything is ok, the Given will find the step in pickle_step.rb
:
|
|
And the code will call the factory which defined before using factory_girl.
Then it will save a post in database sure enough.
But it says
Mysql2::Error: Cannot add or update a child row: a foreign key constraint fails
Obviously, we have something wrong with the user_id field. And more obviously, we have not generate a user.
I thought before the factory_girl will take care of the association object if there is no record in database.
Actually, if we feed the factory attributes, factory_girl will take these values and create a post object rather than create a association record.
So here, it won’t create a user with id 1. The Given will be interpreted to a sql at last:
|
|
And we have a foreign key constraint on user_id, of course it will fail.
###Solutions:
- Given a user with name: “Test”
- Prepare a user before test.
- If the user does not matter, just remove user_id, let factory_girl take care of user.
3. Capybara get the native css value
element.native.css_value("text-overflow")
- element is the capybara element
- native is used to get the selenium-webdriver element
- css_value is used to get the computed style.