Giter VIP home page Giter VIP logo

Comments (4)

jferris avatar jferris commented on July 22, 2024

I haven't been feeling much pain from this. I think I've been writing this version:

stub_request(:put, url).
  with(
    headers: {
      "Authorization" => "some_token",
      "Accept" => "some_media_type",
    }
  ).
  to_return(
    body: "some body text",
    status: 200
  )

It's consistent with all the guidelines, it's consistently formatted, and it's easy to scan for method names in the chain.

from guides.

jferris avatar jferris commented on July 22, 2024

I'm going to close this, as the discussion seems to have wrapped up.

@gylaz want to open a pull request to solidify this?

from guides.

mcmire avatar mcmire commented on July 22, 2024

FWIW, I agree with this, we should make this a guideline. I've seen the second form lately and was irked.

from guides.

gylaz avatar gylaz commented on July 22, 2024

Actually, we already have a guideline that covers this:

If you break up a chain of method invocations, keep each method invocation on its own line. Place the . at the end of each line, except the last.

Source

However, I'm not sure how it's suppose to work in a case like this:

  some_really_really_long_method_name(
    arg1: "foo",
    arg2: "bar",
    arg3: "baz",
  ).
  another_method_name_with_args(
    arg1: "one",
    arg2: "two",
    arg3: "three",
  )

Should the another_method_name_with_args method be indented one level (but that would look weird)?
We always indent subsequent method in chains like:

  User.where(name: "blah").
    order("name DESC").
    includes(:subscriptions, :address).
    limit(10)

from guides.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.