dradis-mediawiki 3.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/.github/issue_template.md +16 -0
  3. data/.github/pull_request_template.md +36 -0
  4. data/.rspec +2 -0
  5. data/CHANGELOG.md +51 -0
  6. data/CONTRIBUTING.md +3 -0
  7. data/Gemfile +23 -0
  8. data/LICENSE +339 -0
  9. data/README.md +32 -0
  10. data/Rakefile +1 -0
  11. data/dradis-mediawiki.gemspec +31 -0
  12. data/lib/dradis-mediawiki.rb +2 -0
  13. data/lib/dradis/plugins/mediawiki.rb +10 -0
  14. data/lib/dradis/plugins/mediawiki/engine.rb +17 -0
  15. data/lib/dradis/plugins/mediawiki/filters.rb +68 -0
  16. data/lib/dradis/plugins/mediawiki/gem_version.rb +21 -0
  17. data/lib/dradis/plugins/mediawiki/version.rb +9 -0
  18. data/lib/tasks/thorfile.rb +17 -0
  19. data/spec/spec_helper.rb +22 -0
  20. data/spec/wiki_import_spec.rb +18 -0
  21. data/test/vendor/mocha-0.9.5/COPYING +3 -0
  22. data/test/vendor/mocha-0.9.5/MIT-LICENSE +7 -0
  23. data/test/vendor/mocha-0.9.5/README +37 -0
  24. data/test/vendor/mocha-0.9.5/README.dradis +4 -0
  25. data/test/vendor/mocha-0.9.5/RELEASE +269 -0
  26. data/test/vendor/mocha-0.9.5/Rakefile +207 -0
  27. data/test/vendor/mocha-0.9.5/lib/mocha.rb +49 -0
  28. data/test/vendor/mocha-0.9.5/lib/mocha/any_instance_method.rb +55 -0
  29. data/test/vendor/mocha-0.9.5/lib/mocha/argument_iterator.rb +21 -0
  30. data/test/vendor/mocha-0.9.5/lib/mocha/backtrace_filter.rb +17 -0
  31. data/test/vendor/mocha-0.9.5/lib/mocha/cardinality.rb +95 -0
  32. data/test/vendor/mocha-0.9.5/lib/mocha/central.rb +27 -0
  33. data/test/vendor/mocha-0.9.5/lib/mocha/change_state_side_effect.rb +19 -0
  34. data/test/vendor/mocha-0.9.5/lib/mocha/class_method.rb +87 -0
  35. data/test/vendor/mocha-0.9.5/lib/mocha/configuration.rb +60 -0
  36. data/test/vendor/mocha-0.9.5/lib/mocha/deprecation.rb +22 -0
  37. data/test/vendor/mocha-0.9.5/lib/mocha/exception_raiser.rb +17 -0
  38. data/test/vendor/mocha-0.9.5/lib/mocha/expectation.rb +476 -0
  39. data/test/vendor/mocha-0.9.5/lib/mocha/expectation_error.rb +15 -0
  40. data/test/vendor/mocha-0.9.5/lib/mocha/expectation_list.rb +50 -0
  41. data/test/vendor/mocha-0.9.5/lib/mocha/in_state_ordering_constraint.rb +19 -0
  42. data/test/vendor/mocha-0.9.5/lib/mocha/inspect.rb +67 -0
  43. data/test/vendor/mocha-0.9.5/lib/mocha/instance_method.rb +16 -0
  44. data/test/vendor/mocha-0.9.5/lib/mocha/is_a.rb +9 -0
  45. data/test/vendor/mocha-0.9.5/lib/mocha/logger.rb +15 -0
  46. data/test/vendor/mocha-0.9.5/lib/mocha/metaclass.rb +13 -0
  47. data/test/vendor/mocha-0.9.5/lib/mocha/method_matcher.rb +21 -0
  48. data/test/vendor/mocha-0.9.5/lib/mocha/mini_test_adapter.rb +50 -0
  49. data/test/vendor/mocha-0.9.5/lib/mocha/mock.rb +200 -0
  50. data/test/vendor/mocha-0.9.5/lib/mocha/mockery.rb +181 -0
  51. data/test/vendor/mocha-0.9.5/lib/mocha/module_method.rb +16 -0
  52. data/test/vendor/mocha-0.9.5/lib/mocha/multiple_yields.rb +20 -0
  53. data/test/vendor/mocha-0.9.5/lib/mocha/names.rb +53 -0
  54. data/test/vendor/mocha-0.9.5/lib/mocha/no_yields.rb +11 -0
  55. data/test/vendor/mocha-0.9.5/lib/mocha/object.rb +187 -0
  56. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers.rb +27 -0
  57. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/all_of.rb +42 -0
  58. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/any_of.rb +47 -0
  59. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/any_parameters.rb +40 -0
  60. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/anything.rb +33 -0
  61. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/base.rb +15 -0
  62. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/equals.rb +42 -0
  63. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/has_entries.rb +45 -0
  64. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/has_entry.rb +56 -0
  65. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/has_key.rb +42 -0
  66. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/has_value.rb +42 -0
  67. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/includes.rb +40 -0
  68. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/instance_of.rb +42 -0
  69. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/is_a.rb +42 -0
  70. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/kind_of.rb +42 -0
  71. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/not.rb +42 -0
  72. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/object.rb +15 -0
  73. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/optionally.rb +55 -0
  74. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/regexp_matches.rb +43 -0
  75. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/responds_with.rb +43 -0
  76. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/yaml_equivalent.rb +43 -0
  77. data/test/vendor/mocha-0.9.5/lib/mocha/parameters_matcher.rb +37 -0
  78. data/test/vendor/mocha-0.9.5/lib/mocha/pretty_parameters.rb +28 -0
  79. data/test/vendor/mocha-0.9.5/lib/mocha/return_values.rb +31 -0
  80. data/test/vendor/mocha-0.9.5/lib/mocha/sequence.rb +42 -0
  81. data/test/vendor/mocha-0.9.5/lib/mocha/single_return_value.rb +17 -0
  82. data/test/vendor/mocha-0.9.5/lib/mocha/single_yield.rb +18 -0
  83. data/test/vendor/mocha-0.9.5/lib/mocha/standalone.rb +166 -0
  84. data/test/vendor/mocha-0.9.5/lib/mocha/state_machine.rb +91 -0
  85. data/test/vendor/mocha-0.9.5/lib/mocha/stubbing_error.rb +16 -0
  86. data/test/vendor/mocha-0.9.5/lib/mocha/test_case_adapter.rb +103 -0
  87. data/test/vendor/mocha-0.9.5/lib/mocha/unexpected_invocation.rb +18 -0
  88. data/test/vendor/mocha-0.9.5/lib/mocha/yield_parameters.rb +31 -0
  89. data/test/vendor/mocha-0.9.5/lib/mocha_standalone.rb +2 -0
  90. data/test/vendor/mocha-0.9.5/lib/stubba.rb +4 -0
  91. data/test/wiki_import_test.rb +106 -0
  92. metadata +249 -0
@@ -0,0 +1,15 @@
1
+ require 'mocha/backtrace_filter'
2
+
3
+ module Mocha
4
+
5
+ class ExpectationError < StandardError
6
+
7
+ def initialize(message = nil, backtrace = [])
8
+ super(message)
9
+ filter = BacktraceFilter.new
10
+ set_backtrace(filter.filtered(backtrace))
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,50 @@
1
+ module Mocha # :nodoc:
2
+
3
+ class ExpectationList
4
+
5
+ def initialize
6
+ @expectations = []
7
+ end
8
+
9
+ def add(expectation)
10
+ @expectations.unshift(expectation)
11
+ expectation
12
+ end
13
+
14
+ def matches_method?(method_name)
15
+ @expectations.any? { |expectation| expectation.matches_method?(method_name) }
16
+ end
17
+
18
+ def match(method_name, *arguments)
19
+ matching_expectations(method_name, *arguments).first
20
+ end
21
+
22
+ def match_allowing_invocation(method_name, *arguments)
23
+ matching_expectations(method_name, *arguments).detect { |e| e.invocations_allowed? }
24
+ end
25
+
26
+ def verified?(assertion_counter = nil)
27
+ @expectations.all? { |expectation| expectation.verified?(assertion_counter) }
28
+ end
29
+
30
+ def to_a
31
+ @expectations
32
+ end
33
+
34
+ def to_set
35
+ @expectations.to_set
36
+ end
37
+
38
+ def length
39
+ @expectations.length
40
+ end
41
+
42
+ private
43
+
44
+ def matching_expectations(method_name, *arguments)
45
+ @expectations.select { |e| e.match?(method_name, *arguments) }
46
+ end
47
+
48
+ end
49
+
50
+ end
@@ -0,0 +1,19 @@
1
+ module Mocha
2
+
3
+ class InStateOrderingConstraint
4
+
5
+ def initialize(state_predicate)
6
+ @state_predicate = state_predicate
7
+ end
8
+
9
+ def allows_invocation_now?
10
+ @state_predicate.active?
11
+ end
12
+
13
+ def mocha_inspect
14
+ "when #{@state_predicate.mocha_inspect}"
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,67 @@
1
+ require 'date'
2
+
3
+ module Mocha
4
+
5
+ module ObjectMethods
6
+ def mocha_inspect
7
+ address = self.__id__ * 2
8
+ address += 0x100000000 if address < 0
9
+ inspect =~ /#</ ? "#<#{self.class}:0x#{'%x' % address}>" : inspect
10
+ end
11
+ end
12
+
13
+ module StringMethods
14
+ def mocha_inspect
15
+ inspect.gsub(/\"/, "'")
16
+ end
17
+ end
18
+
19
+ module ArrayMethods
20
+ def mocha_inspect
21
+ "[#{collect { |member| member.mocha_inspect }.join(', ')}]"
22
+ end
23
+ end
24
+
25
+ module HashMethods
26
+ def mocha_inspect
27
+ "{#{collect { |key, value| "#{key.mocha_inspect} => #{value.mocha_inspect}" }.join(', ')}}"
28
+ end
29
+ end
30
+
31
+ module TimeMethods
32
+ def mocha_inspect
33
+ "#{inspect} (#{to_f} secs)"
34
+ end
35
+ end
36
+
37
+ module DateMethods
38
+ def mocha_inspect
39
+ to_s
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ class Object
46
+ include Mocha::ObjectMethods
47
+ end
48
+
49
+ class String
50
+ include Mocha::StringMethods
51
+ end
52
+
53
+ class Array
54
+ include Mocha::ArrayMethods
55
+ end
56
+
57
+ class Hash
58
+ include Mocha::HashMethods
59
+ end
60
+
61
+ class Time
62
+ include Mocha::TimeMethods
63
+ end
64
+
65
+ class Date
66
+ include Mocha::DateMethods
67
+ end
@@ -0,0 +1,16 @@
1
+ require 'mocha/class_method'
2
+
3
+ module Mocha
4
+
5
+ class InstanceMethod < ClassMethod
6
+
7
+ def method_exists?(method)
8
+ return true if stubbee.public_methods(false).include?(method)
9
+ return true if stubbee.protected_methods(false).include?(method)
10
+ return true if stubbee.private_methods(false).include?(method)
11
+ return false
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,9 @@
1
+ class Object
2
+
3
+ # :stopdoc:
4
+
5
+ alias_method :__is_a__, :is_a?
6
+
7
+ # :startdoc:
8
+
9
+ end
@@ -0,0 +1,15 @@
1
+ module Mocha
2
+
3
+ class Logger
4
+
5
+ def initialize(io)
6
+ @io = io
7
+ end
8
+
9
+ def warn(message)
10
+ @io.puts "WARNING: #{message}"
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,13 @@
1
+ module Mocha
2
+
3
+ module ObjectMethods
4
+ def __metaclass__
5
+ class << self; self; end
6
+ end
7
+ end
8
+
9
+ end
10
+
11
+ class Object
12
+ include Mocha::ObjectMethods
13
+ end
@@ -0,0 +1,21 @@
1
+ module Mocha
2
+
3
+ class MethodMatcher
4
+
5
+ attr_reader :expected_method_name
6
+
7
+ def initialize(expected_method_name)
8
+ @expected_method_name = expected_method_name
9
+ end
10
+
11
+ def match?(actual_method_name)
12
+ @expected_method_name == actual_method_name
13
+ end
14
+
15
+ def mocha_inspect
16
+ "#{@expected_method_name}"
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,50 @@
1
+ module Mocha
2
+
3
+ module MiniTestCaseAdapter
4
+
5
+ class AssertionCounter
6
+ def initialize(test_case)
7
+ @test_case = test_case
8
+ end
9
+
10
+ def increment
11
+ @test_case._assertions += 1
12
+ end
13
+ end
14
+
15
+ def self.included(base)
16
+ base.class_eval do
17
+
18
+ alias_method :run_before_mocha_mini_test_adapter, :run
19
+
20
+ def run runner
21
+ assertion_counter = AssertionCounter.new(self)
22
+ result = '.'
23
+ begin
24
+ begin
25
+ @passed = nil
26
+ self.setup
27
+ self.__send__ self.name
28
+ mocha_verify(assertion_counter)
29
+ @passed = true
30
+ rescue Exception => e
31
+ @passed = false
32
+ result = runner.puke(self.class, self.name, e)
33
+ ensure
34
+ begin
35
+ self.teardown
36
+ rescue Exception => e
37
+ result = runner.puke(self.class, self.name, e)
38
+ end
39
+ end
40
+ ensure
41
+ mocha_teardown
42
+ end
43
+ result
44
+ end
45
+
46
+ end
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,200 @@
1
+ require 'mocha/expectation'
2
+ require 'mocha/expectation_list'
3
+ require 'mocha/metaclass'
4
+ require 'mocha/names'
5
+ require 'mocha/mockery'
6
+ require 'mocha/method_matcher'
7
+ require 'mocha/parameters_matcher'
8
+ require 'mocha/unexpected_invocation'
9
+ require 'mocha/argument_iterator'
10
+
11
+ module Mocha # :nodoc:
12
+
13
+ # Traditional mock object.
14
+ #
15
+ # Methods return an Expectation which can be further modified by methods on Expectation.
16
+ class Mock
17
+
18
+ # :call-seq: expects(method_name) -> expectation
19
+ # expects(method_names_vs_return_values) -> last expectation
20
+ #
21
+ # Adds an expectation that a method identified by +method_name+ Symbol/String must be called exactly once with any parameters.
22
+ # Returns the new expectation which can be further modified by methods on Expectation.
23
+ # object = mock()
24
+ # object.expects(:method1)
25
+ # object.method1
26
+ # # no error raised
27
+ #
28
+ # object = mock()
29
+ # object.expects(:method1)
30
+ # # error raised, because method1 not called exactly once
31
+ # If +method_names_vs_return_values+ is a +Hash+, an expectation will be set up for each entry using the key as +method_name+ and value as +return_value+.
32
+ # object = mock()
33
+ # object.expects(:method1 => :result1, :method2 => :result2)
34
+ #
35
+ # # exactly equivalent to
36
+ #
37
+ # object = mock()
38
+ # object.expects(:method1).returns(:result1)
39
+ # object.expects(:method2).returns(:result2)
40
+ #
41
+ # Aliased by <tt>\_\_expects\_\_</tt>
42
+ def expects(method_name_or_hash, backtrace = nil)
43
+ iterator = ArgumentIterator.new(method_name_or_hash)
44
+ iterator.each { |*args|
45
+ method_name = args.shift
46
+ ensure_method_not_already_defined(method_name)
47
+ expectation = Expectation.new(self, method_name, backtrace)
48
+ expectation.returns(args.shift) if args.length > 0
49
+ @expectations.add(expectation)
50
+ }
51
+ end
52
+
53
+ # :call-seq: stubs(method_name) -> expectation
54
+ # stubs(method_names_vs_return_values) -> last expectation
55
+ #
56
+ # Adds an expectation that a method identified by +method_name+ Symbol/String may be called any number of times with any parameters.
57
+ # Returns the new expectation which can be further modified by methods on Expectation.
58
+ # object = mock()
59
+ # object.stubs(:method1)
60
+ # object.method1
61
+ # object.method1
62
+ # # no error raised
63
+ # If +method_names_vs_return_values+ is a +Hash+, an expectation will be set up for each entry using the key as +method_name+ and value as +return_value+.
64
+ # object = mock()
65
+ # object.stubs(:method1 => :result1, :method2 => :result2)
66
+ #
67
+ # # exactly equivalent to
68
+ #
69
+ # object = mock()
70
+ # object.stubs(:method1).returns(:result1)
71
+ # object.stubs(:method2).returns(:result2)
72
+ #
73
+ # Aliased by <tt>\_\_stubs\_\_</tt>
74
+ def stubs(method_name_or_hash, backtrace = nil)
75
+ iterator = ArgumentIterator.new(method_name_or_hash)
76
+ iterator.each { |*args|
77
+ method_name = args.shift
78
+ ensure_method_not_already_defined(method_name)
79
+ expectation = Expectation.new(self, method_name, backtrace)
80
+ expectation.at_least(0)
81
+ expectation.returns(args.shift) if args.length > 0
82
+ @expectations.add(expectation)
83
+ }
84
+ end
85
+
86
+ # :call-seq: responds_like(responder) -> mock
87
+ #
88
+ # Constrains the +mock+ so that it can only expect or stub methods to which +responder+ responds. The constraint is only applied at method invocation time.
89
+ #
90
+ # A +NoMethodError+ will be raised if the +responder+ does not <tt>respond_to?</tt> a method invocation (even if the method has been expected or stubbed).
91
+ #
92
+ # The +mock+ will delegate its <tt>respond_to?</tt> method to the +responder+.
93
+ # class Sheep
94
+ # def chew(grass); end
95
+ # def self.number_of_legs; end
96
+ # end
97
+ #
98
+ # sheep = mock('sheep')
99
+ # sheep.expects(:chew)
100
+ # sheep.expects(:foo)
101
+ # sheep.respond_to?(:chew) # => true
102
+ # sheep.respond_to?(:foo) # => true
103
+ # sheep.chew
104
+ # sheep.foo
105
+ # # no error raised
106
+ #
107
+ # sheep = mock('sheep')
108
+ # sheep.responds_like(Sheep.new)
109
+ # sheep.expects(:chew)
110
+ # sheep.expects(:foo)
111
+ # sheep.respond_to?(:chew) # => true
112
+ # sheep.respond_to?(:foo) # => false
113
+ # sheep.chew
114
+ # sheep.foo # => raises NoMethodError exception
115
+ #
116
+ # sheep_class = mock('sheep_class')
117
+ # sheep_class.responds_like(Sheep)
118
+ # sheep_class.stubs(:number_of_legs).returns(4)
119
+ # sheep_class.expects(:foo)
120
+ # sheep_class.respond_to?(:number_of_legs) # => true
121
+ # sheep_class.respond_to?(:foo) # => false
122
+ # assert_equal 4, sheep_class.number_of_legs
123
+ # sheep_class.foo # => raises NoMethodError exception
124
+ #
125
+ # Aliased by +quacks_like+
126
+ def responds_like(object)
127
+ @responder = object
128
+ self
129
+ end
130
+
131
+ # :stopdoc:
132
+
133
+ def initialize(name = nil, &block)
134
+ @name = name || DefaultName.new(self)
135
+ @expectations = ExpectationList.new
136
+ @everything_stubbed = false
137
+ @responder = nil
138
+ instance_eval(&block) if block
139
+ end
140
+
141
+ attr_reader :everything_stubbed, :expectations
142
+
143
+ alias_method :__expects__, :expects
144
+
145
+ alias_method :__stubs__, :stubs
146
+
147
+ alias_method :quacks_like, :responds_like
148
+
149
+ def stub_everything
150
+ @everything_stubbed = true
151
+ end
152
+
153
+ def method_missing(symbol, *arguments, &block)
154
+ if @responder and not @responder.respond_to?(symbol)
155
+ raise NoMethodError, "undefined method `#{symbol}' for #{self.mocha_inspect} which responds like #{@responder.mocha_inspect}"
156
+ end
157
+ if matching_expectation_allowing_invocation = @expectations.match_allowing_invocation(symbol, *arguments)
158
+ matching_expectation_allowing_invocation.invoke(&block)
159
+ else
160
+ if (matching_expectation = @expectations.match(symbol, *arguments)) || (!matching_expectation && !@everything_stubbed)
161
+ message = UnexpectedInvocation.new(self, symbol, *arguments).to_s
162
+ message << Mockery.instance.mocha_inspect
163
+ raise ExpectationError.new(message, caller)
164
+ end
165
+ end
166
+ end
167
+
168
+ def respond_to?(symbol, include_private = false)
169
+ if @responder then
170
+ if @responder.method(:respond_to?).arity > 1
171
+ @responder.respond_to?(symbol, include_private)
172
+ else
173
+ @responder.respond_to?(symbol)
174
+ end
175
+ else
176
+ @everything_stubbed || @expectations.matches_method?(symbol)
177
+ end
178
+ end
179
+
180
+ def __verified__?(assertion_counter = nil)
181
+ @expectations.verified?(assertion_counter)
182
+ end
183
+
184
+ def mocha_inspect
185
+ @name.mocha_inspect
186
+ end
187
+
188
+ def inspect
189
+ mocha_inspect
190
+ end
191
+
192
+ def ensure_method_not_already_defined(method_name)
193
+ self.__metaclass__.send(:undef_method, method_name) if self.__metaclass__.method_defined?(method_name)
194
+ end
195
+
196
+ # :startdoc:
197
+
198
+ end
199
+
200
+ end