Benito Serna Tips and tools for Ruby on Rails developers

Did you finish the exercise?… Well here is my answer =)

describe "All documents..." do
  it "returns all documents" do
    store = store_with([
      document_with(file_url: "path/to_url/Doc-1.xls"),
      document_with(file_url: "path/to_url/Doc-2.xls")
    ])

    docs = Docs.all_documents(store)
    expect(docs.count).to eq 2
  end

  it "has each document with..." do
    store = store_with([
      document_with(
        file_url: "path/to_url/Doc-1.xls",
        uploaded_at: Time.new(2018, 10, 3),
        uploader: user_with(
          name: "Benito Serna",
          photo_url: "path/to/user/1/photo.png"
        )
      )
    ])

    doc = Docs.all_documents(store).first
    expect(doc.icon_type).to eq "xls"
    expect(doc.file_name).to eq "Doc-1.xls"
    expect(doc.uploader_photo_url).to eq "path/to/user/1/photo.png"
    expect(doc.uploader_name).to eq "Benito Serna"
    expect(doc.uploaded_at).to eq Time.new(2018, 10, 3)
  end
end

Weekly tips and tools for Ruby on Rails developers

I send an email each week, trying to share knowledge and fixes to common problems and struggles for ruby on rails developers, like How to fetch the latest-N-of-each record or How to test that an specific mail was sent or a Capybara cheatsheet. You can see more examples on Most recent posts or All post by topic.