thoughtbot / testing-rails

Source code for the Testing Rails book
Other
279 stars 49 forks source link

Typo in the antipatterns chapter #47

Closed alexeyzab closed 9 years ago

alexeyzab commented 9 years ago

Hi there!

I think I found a typo inside a code sample in this file: testing-rails/book/antipatterns/using_factories_like_fixtures.md

# DON'T do this

factory :user do
  sequence(:username) { |n| "username#{n}" }
  password_digest "password
  name "Donald Duck"
  age 24
end

# DO this

factory :user do
  sequence(:username) { |n| "username#{n}" }
  password_digest "password
end

It should be

# DON'T do this

factory :user do
  sequence(:username) { |n| "username#{n}" }
  password_digest "password"
  name "Donald Duck"
  age 24
end

# DO this

factory :user do
  sequence(:username) { |n| "username#{n}" }
  password_digest "password"
end

Notice the quote sign after the "password.

Mind if I submit a pull request?

alexeyzab commented 9 years ago

Found more in another code sample, same chapter.

# DON'T do this

factory :admin_user, class: User do
  sequence(:username) { |n| "admin_username#{n}" }
  password_digest "password
  name "Mr. Admin"
  age 27
  admin true
end

factory :normal_user, class: User do
  sequence(:username) { |n| "username#{n}" }
  password_digest "password
  name "Donald Duck"
  age 24
  admin false
end

# DO this

factory :user do
  sequence(:username) { |n| "username#{n}" }
  password_digest "password

  trait :admin do
    admin true
  end
end

Same thing, missing quotes.

jsteiner commented 9 years ago

Fixed in #48.