File: doubled_classes.rb

package info (click to toggle)
ruby-rspec 3.9.0c2e2m1s3-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,612 kB
  • sloc: ruby: 67,456; sh: 1,572; makefile: 98
file content (87 lines) | stat: -rw-r--r-- 1,475 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
class LoadedClass
  extend RSpec::Support::RubyFeatures

  M = :m
  N = :n
  INSTANCE = LoadedClass.new

  def initialize(_a, _b)
  end

  class << self
    def respond_to?(method_name, include_all=false)
      return true if method_name == :dynamic_class_method
      super
    end

    def defined_class_method
    end

    def send
      # fake out!
    end

    def defined_instance_and_class_method
    end

  protected

    def defined_protected_class_method
    end

  private

    def defined_private_class_method
    end
  end

  def defined_instance_method
  end

  def instance_method_with_two_args(_a, _b)
  end

  def instance_method_with_only_defaults(_a=1, _b=2)
  end

  def defined_instance_and_class_method
  end

  if required_kw_args_supported?
    # Need to eval this since it is invalid syntax on earlier rubies.
    eval <<-RUBY
      def kw_args_method(foo, optional_arg:'hello', required_arg:)
      end

      def mixed_args_method(foo, bar, optional_arg_1:1, optional_arg_2:2)
      end
    RUBY
  end

  def send(*)
  end

  def respond_to?(method_name, include_all=false)
    return true if method_name == :dynamic_instance_method
    super
  end

  class Nested; end

protected

  def defined_protected_method
  end

private

  def defined_private_method
    "wink wink ;)"
  end
end

class LoadedClassWithOverriddenName < LoadedClass
  def self.name
    "Overriding name is not a good idea but we can't count on users not doing this"
  end
end