Problems with unit testing in rails especially with foreign keys -


i cant run unit test in rails. keep getting error: sqlite3::constraintexception: column email not unique. have foreign key email in post model dont know why keep getting above error. code follows test class:

test "should not save post without title"  post = post.new  post.text = "hello world"  assert !post.save end  test "should not save post without description"  post = post.new  post.title = "hello"  assert !post.save end 

it turns out rails 4 not using test in format above. worked when changes method headers like:

  def test should_not_save_post_without_title   //add testing code   end 

and make sure model fixtures have sample data in them every single variable needs tested. example of is:

in post fixture:

 one:   text: mystring   title: mystring 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -