4

In my Guardfile I have this strange method invocation syntax rspec.spec.("requests/#{m[1]}"). While this works perfectly I don't understand is what method is actually being called.

Is there a name or term for this syntax?

guard :rspec, cmd: "bundle exec rspec" do

  # ...
  watch(rails.controllers) do |m|
    [
      rspec.spec.("routing/#{m[1]}_routing"),
      rspec.spec.("controllers/#{m[1]}_controller"),
      rspec.spec.("requests/#{m[1]}")
    ]
  end
end
max
  • 96,212
  • 14
  • 104
  • 165
  • Thanks @Drenmi, I could not think up a good search phrase. Its a duplicate. – max Oct 19 '15 at 12:50
  • No problem @max. It took some searching to find because of the peculiar lack of method name. :-) – Drenmi Oct 19 '15 at 13:22

1 Answers1

3

Try:

foo = "Foo"
foo.("a")
# NoMethodError: undefined method `call' for "Foo":String

routine = Proc.new { |arg| puts "Hello #{arg}!" }
routine.("world")
# Hello world!
tompave
  • 11,952
  • 7
  • 37
  • 63