Sha256: 107331febcf76994fff7820ada4b63367354b577af712b4711ee54ea348fa7c6
Contents?: true
Size: 1.84 KB
Versions: 4
Compression:
Stored size: 1.84 KB
Contents
require 'spec_helper' require 'debugging/howtocall' describe "howtocall" do it "displays method parameters" do def function(a, b) end expect( capture_stdout{ howtocall :function } ).to eq "function(a, b)\n" end it "underlines optional parameters" do def function(a, b = 3) end expect( capture_stdout{ howtocall :function } ).to eq "function(a, \e[4mb\e[0m)\n" end it "shows block parameters" do def function(a, &b) end expect( capture_stdout{ howtocall :function } ).to eq "function(a, &b)\n" end it "optionally takes an object where the method shoud be looked for (if not self)" do module Klass def self.function(a,b) end end expect( capture_stdout{ howtocall Klass, :function } ).to eq "function(a, b)\n" end it "appends : for keyword arguments" do def function(a: 42, b: 43) end expect( capture_stdout{ howtocall :function } ).to eq "function(\e[4ma\e[0m:, \e[4mb\e[0m:)\n" end it "shows *splats and keyword **splats" do def function(*cmd, **opts) end expect( capture_stdout{ howtocall :function } ).to eq "function(*cmd, **opts)\n" end it "shows ? for array deconstructor parameters" do def function((a, b)) end expect( capture_stdout{ howtocall :function } ).to eq "function(?)\n" end it "also works for procs" do lambda = ->(a, b){} expect( capture_stdout{ howtocall lambda } ).to eq "call(a, b)\n" end if RUBY_ENGINE == "ruby" || RUBY_ENGINE == "jruby" context "[native methods]" do it "shows ? instead of parameter names for fixed amount of parameters" do expect( capture_stdout{ howtocall :is_a? } ).to eq "is_a?(?)\n" end it "shows * instead of parameters for variable amount of parameters" do expect( capture_stdout{ howtocall :puts } ).to eq "puts(*)\n" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
debugging-2.1.0 | spec/howtocall_spec.rb |
debugging-2.0.0 | spec/howtocall_spec.rb |
debugging-1.1.2 | spec/howtocall_spec.rb |
debugging-1.1.1 | spec/howtocall_spec.rb |