opal-rspec 0.5.0 → 0.6.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +6 -0
  3. data/.gitignore +1 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +36 -26
  6. data/Appraisals +7 -0
  7. data/CHANGELOG.md +8 -0
  8. data/Gemfile +2 -4
  9. data/README.md +38 -16
  10. data/Rakefile +19 -7
  11. data/config.ru +3 -1
  12. data/gemfiles/opal_0.10_stable.gemfile +15 -0
  13. data/gemfiles/opal_master.gemfile +12 -15
  14. data/lib/opal/rspec/rake_task.rb +21 -8
  15. data/lib/opal/rspec/version.rb +1 -1
  16. data/lib/opal/rspec.rb +2 -2
  17. data/opal/opal/rspec/async/async_example.rb +5 -5
  18. data/opal/opal/rspec/async/example_group.rb +4 -4
  19. data/opal/opal/rspec/async/hooks.rb +2 -2
  20. data/opal/opal/rspec/async/legacy.rb +8 -9
  21. data/opal/opal/rspec/fixes/opal/compatibility.rb +3 -181
  22. data/opal/opal/rspec/fixes/opal.rb +0 -4
  23. data/opal/opal/rspec/fixes/rspec/core/metadata.rb +7 -26
  24. data/opal/opal/rspec/fixes/rspec/core.rb +0 -2
  25. data/opal/opal/rspec/fixes/rspec/example_groups.rb +0 -11
  26. data/opal/opal/rspec/fixes/rspec/expectations.rb +0 -1
  27. data/opal/opal/rspec/fixes/rspec/matchers/built_in/start_and_end_with.rb +0 -21
  28. data/opal/opal/rspec/fixes/rspec/mocks/error_generator.rb +0 -26
  29. data/opal/opal/rspec/fixes/rspec/support/spec/stderr_splitter.rb +13 -0
  30. data/opal/opal/rspec/fixes/rspec/support/spec.rb +1 -0
  31. data/opal/opal/rspec/fixes/rspec/support.rb +1 -1
  32. data/opal/opal/rspec/formatter/html_printer.rb +1 -1
  33. data/opal/opal/rspec/pre_require_fixes.rb +0 -5
  34. data/opal/opal/rspec/runner.rb +1 -1
  35. data/opal-rspec.gemspec +2 -3
  36. data/spec/mri/integration/browser_spec.rb +0 -3
  37. data/spec/mri/integration/spec_opts_spec.rb +1 -1
  38. data/spec/mri/unit/opal/rspec/browser_formatter_spec.rb +0 -3
  39. data/spec/mri/unit/opal/rspec/rack/config.ru +1 -1
  40. data/spec/mri/unit/opal/rspec/rake_task_spec.rb +60 -6
  41. data/spec/opal/after_hooks_spec.rb +26 -24
  42. data/spec/opal/around_hooks_spec.rb +2 -0
  43. data/spec/opal/async_spec.rb +22 -20
  44. data/spec/opal/before_hooks_spec.rb +20 -18
  45. data/spec/opal/example_spec.rb +4 -2
  46. data/spec/opal/matchers_spec.rb +3 -1
  47. data/spec/opal/mock_spec.rb +2 -0
  48. data/spec/opal/should_syntax_spec.rb +2 -0
  49. data/spec/opal/skip_pending_spec.rb +7 -5
  50. data/spec/opal/spec_helper.rb +4 -0
  51. data/spec/opal/subject_spec.rb +2 -0
  52. data/spec/rspec/core/filter/core/async/hooks.rb +0 -1
  53. data/spec/rspec/core/filter/core/async/metadata.rb +4 -0
  54. data/spec/rspec/core/filter/core/bugs/memoized_helpers.rb +0 -6
  55. data/spec/rspec/core/require_specs.rb +0 -1
  56. data/spec/rspec/expectations/config.rb +6 -1
  57. data/spec/rspec/expectations/filter/bugs/configuration.txt +0 -3
  58. data/spec/rspec/expectations/filter/bugs/contain_exactly.rb +0 -5
  59. data/spec/rspec/expectations/filter/bugs/define_negated_matcher.rb +0 -1
  60. data/spec/rspec/expectations/filter/bugs/dsl.rb +15 -0
  61. data/spec/rspec/expectations/filter/bugs/expectation_target.rb +4 -0
  62. data/spec/rspec/expectations/filter/bugs/expectations.rb +4 -0
  63. data/spec/rspec/expectations/filter/bugs/respond_to.rb +5 -11
  64. data/spec/rspec/expectations/filter/unsupported/dsl.rb +10 -0
  65. data/spec/rspec/expectations/fixes/example_patches.rb +0 -17
  66. data/spec/rspec/expectations/opal_alternates/dsl_spec.rb +2 -2
  67. data/spec/rspec/expectations/require_specs.rb +0 -1
  68. data/spec/rspec/filter_processor.rb +21 -5
  69. data/spec/rspec/mocks/filter/bugs/and_call_original.rb +11 -0
  70. data/spec/rspec/mocks/filter/bugs/and_yield.rb +4 -0
  71. data/spec/rspec/mocks/filter/bugs/any_instance.rb +1 -7
  72. data/spec/rspec/mocks/filter/bugs/partial_double.rb +5 -6
  73. data/spec/rspec/mocks/filter/bugs/stub_implementation.rb +0 -4
  74. data/spec/rspec/mocks/filter/unsupported/and_call_original.rb +7 -0
  75. data/spec/rspec/mocks/filter/unsupported/and_return.rb +4 -0
  76. data/spec/rspec/mocks/filter/unsupported/argument_matchers.rb +0 -3
  77. data/spec/rspec/mocks/filter/unsupported/combining_implementation_instructions.rb +0 -5
  78. data/spec/rspec/mocks/filter/unsupported/double.rb +0 -3
  79. data/spec/rspec/mocks/filter/unsupported/instance_double_with_class_loaded.rb +10 -0
  80. data/spec/rspec/mocks/filter/unsupported/nil_expectation_warning.rb +0 -4
  81. data/spec/rspec/mocks/filter/unsupported/partial_double.rb +0 -2
  82. data/spec/rspec/mocks/mocks_spec_loader.rb +1 -1
  83. data/spec/rspec/mocks/require_specs.rb +0 -1
  84. data/spec/rspec/mocks/spec_helper_opal.rb +2 -0
  85. data/spec/rspec/opal_rspec_spec_loader.rb +19 -4
  86. data/spec/rspec/support/filter/unsupported/fuzzy_matcher.rb +4 -0
  87. data/spec/rspec/support/filter/unsupported/support.rb +0 -3
  88. data/spec/rspec/support/require_specs.rb +0 -1
  89. metadata +27 -51
  90. data/opal/opal/rspec/fixes/opal/class.rb +0 -8
  91. data/opal/opal/rspec/fixes/opal/corelib/error.rb +0 -61
  92. data/opal/opal/rspec/fixes/opal/corelib/regexp.rb +0 -92
  93. data/opal/opal/rspec/fixes/opal/corelib/struct.rb +0 -260
  94. data/opal/opal/rspec/fixes/opal/corelib.rb +0 -3
  95. data/opal/opal/rspec/fixes/opal/kernel.rb +0 -80
  96. data/opal/opal/rspec/fixes/opal/stdlib/pp.rb +0 -23
  97. data/opal/opal/rspec/fixes/opal/stdlib/set.rb +0 -36
  98. data/opal/opal/rspec/fixes/opal/stdlib.rb +0 -2
  99. data/opal/opal/rspec/fixes/rspec/core/example_group.rb +0 -9
  100. data/opal/opal/rspec/fixes/rspec/core/reporter.rb +0 -14
  101. data/opal/opal/rspec/fixes/rspec/expectations/syntax.rb +0 -25
  102. data/opal/opal/rspec/fixes/rspec/support/fuzzy_matcher.rb +0 -23
  103. data/opal/opal/rspec/fixes/rspec/support/ruby_features.rb +0 -8
  104. data/spec/rspec/core/filter/core/async/metadata.txt +0 -2
  105. data/spec/rspec/core/filter/core/unsupported/metadata_filter.txt +0 -2
  106. data/spec/rspec/core/fixes/opal_itself.rb +0 -38
  107. data/spec/rspec/expectations/filter/bugs/aliases.rb +0 -13
  108. data/spec/rspec/expectations/filter/bugs/be.rb +0 -4
  109. data/spec/rspec/expectations/filter/bugs/be_instance_of.rb +0 -7
  110. data/spec/rspec/expectations/filter/bugs/description_generation.rb +0 -4
  111. data/spec/rspec/expectations/filter/bugs/dsl.txt +0 -14
  112. data/spec/rspec/expectations/filter/bugs/expectation_target.txt +0 -2
  113. data/spec/rspec/expectations/filter/bugs/expectations.txt +0 -2
  114. data/spec/rspec/expectations/filter/bugs/have_attributes.rb +0 -8
  115. data/spec/rspec/expectations/filter/bugs/include.rb +0 -4
  116. data/spec/rspec/expectations/filter/unsupported/dsl.txt +0 -8
  117. data/spec/rspec/expectations/filter/unsupported/respond_to.rb +0 -5
  118. data/spec/rspec/expectations/fixes/opal_itself.rb +0 -140
  119. data/spec/rspec/mocks/filter/bugs/and_call_original.txt +0 -9
  120. data/spec/rspec/mocks/filter/bugs/argument_matchers.rb +0 -3
  121. data/spec/rspec/mocks/filter/bugs/double.txt +0 -3
  122. data/spec/rspec/mocks/filter/bugs/methods.rb +0 -5
  123. data/spec/rspec/mocks/filter/unsupported/and_call_original.txt +0 -5
  124. data/spec/rspec/mocks/filter/unsupported/and_return.txt +0 -2
  125. data/spec/rspec/mocks/filter/unsupported/expected_arg_verification.txt +0 -2
  126. data/spec/rspec/mocks/filter/unsupported/instance_double_with_class_loaded.txt +0 -8
  127. data/spec/rspec/mocks/filter/unsupported/receive_message_chain.rb +0 -4
  128. data/spec/rspec/mocks/filter/unsupported/stub.rb +0 -7
  129. data/spec/rspec/mocks/fixes/opal_itself.rb +0 -59
  130. data/spec/rspec/support/filter/unsupported/fuzzy_matcher.txt +0 -2
  131. data/spec/rspec/support/fixes/opal_itself.rb +0 -13
@@ -1,61 +0,0 @@
1
- unless Opal::RSpec::Compatibility.exception_inspect_matches?
2
- # https://github.com/opal/opal/pull/1134 and https://github.com/opal/opal/pull/1151
3
- # only doing this fix in the tests since it's actual uses of opal-rspec will probably not zero in on the failure
4
- Exception.remove_method(:to_s)
5
- class Exception
6
- def message
7
- to_s
8
- end
9
-
10
- def inspect
11
- as_str = to_s
12
- as_str.empty? ? self.class.to_s : "#<#{self.class.to_s}: #{to_s}>"
13
- end
14
-
15
- def to_s
16
- (@message && @message.to_s) || self.class.to_s
17
- end
18
- end
19
- end
20
-
21
- # https://github.com/opal/opal/pull/1151 - should be fixed in Opal 0.9
22
- unless Opal::RSpec::Compatibility.exception_exception_method_works?
23
- class Exception
24
- def self.new(*args)
25
- # undefined check can be removed if https://github.com/opal/opal/pull/1117 happens
26
- %x{
27
- var message = (args.length > 0 && args[0] !== undefined) ? args[0] : nil;
28
- var err = new self.$$alloc(message);
29
-
30
- if (Error.captureStackTrace) {
31
- Error.captureStackTrace(err);
32
- }
33
-
34
- err.name = self.$$name;
35
- err.$initialize.apply(err, args);
36
- return err;
37
- }
38
- end
39
-
40
- def self.exception(*args)
41
- new(*args)
42
- end
43
-
44
- def initialize(*args)
45
- # undefined check can be removed if https://github.com/opal/opal/pull/1117 happens
46
- `self.message = (args.length > 0 && args[0] !== undefined) ? args[0] : nil`
47
- end
48
-
49
- def exception(str=nil)
50
- %x{
51
- if (str === nil || self === str) {
52
- return self;
53
- }
54
-
55
- var cloned = #{self.clone};
56
- cloned.message = str;
57
- return cloned;
58
- }
59
- end
60
- end
61
- end
@@ -1,92 +0,0 @@
1
- # https://github.com/opal/opal/pull/1129
2
- unless Opal::RSpec::Compatibility.multiline_regex_works? && Opal::RSpec::Compatibility.empty_regex_works?
3
- class Regexp
4
- # https://github.com/opal/opal/pull/1129
5
- unless Opal::RSpec::Compatibility.empty_regex_works?
6
- class << self
7
- def allocate
8
- allocated = super
9
- `#{allocated}.un_initialized = true`
10
- allocated
11
- end
12
- end
13
-
14
- def options
15
- %x{
16
- if (self.un_initialized) {
17
- #{raise TypeError, 'uninitialized Regexp'}
18
- }
19
- var result = 0;
20
- // should be supported in IE6 according to https://msdn.microsoft.com/en-us/library/7f5z26w4(v=vs.94).aspx
21
- if (self.multiline) {
22
- result |= #{MULTILINE};
23
- }
24
- if (self.ignoreCase) {
25
- result |= #{IGNORECASE};
26
- }
27
- return result;
28
- }
29
- end
30
- end
31
-
32
- # https://github.com/opal/opal/pull/1129
33
- unless Opal::RSpec::Compatibility.regex_case_compare_works?
34
- def ===(string)
35
- `#{match(Opal.coerce_to?(string, String, :to_str))} !== nil`
36
- end
37
- end
38
-
39
- unless Opal::RSpec::Compatibility.multiline_regex_works?
40
- # https://github.com/opal/opal/pull/1129
41
- def match(string, pos = undefined, &block)
42
- %x{
43
- if (self.un_initialized) {
44
- #{raise TypeError, 'uninitialized Regexp'}
45
- }
46
-
47
- if (pos === undefined) {
48
- pos = 0;
49
- } else {
50
- pos = #{Opal.coerce_to(pos, Integer, :to_int)};
51
- }
52
-
53
- if (string === nil) {
54
- return #{$~ = nil};
55
- }
56
-
57
- string = #{Opal.coerce_to(string, String, :to_str)};
58
-
59
- if (pos < 0) {
60
- pos += string.length;
61
- if (pos < 0) {
62
- return #{$~ = nil};
63
- }
64
- }
65
-
66
- var source = self.source;
67
- var flags = 'g';
68
- // m flag + a . in Ruby will match white space, but in JS, it only matches beginning/ending of lines, so we get the equivalent here
69
- if (self.multiline) {
70
- source = source.replace('.', "[\\s\\S]");
71
- flags += 'm';
72
- }
73
-
74
- // global RegExp maintains state, so not using self/this
75
- var md, re = new RegExp(source, flags + (self.ignoreCase ? 'i' : ''));
76
-
77
- while (true) {
78
- md = re.exec(string);
79
- if (md === null) {
80
- return #{$~ = nil};
81
- }
82
- if (md.index >= pos) {
83
- #{$~ = MatchData.new(`re`, `md`)}
84
- return block === nil ? #{$~} : #{block.call($~)};
85
- }
86
- re.lastIndex = md.index + 1;
87
- }
88
- }
89
- end
90
- end
91
- end
92
- end
@@ -1,260 +0,0 @@
1
- unless Opal::RSpec::Compatibility.is_struct_hash_correct?
2
- module Opal
3
- def self.valid_method_name?(method_name)
4
- method_name = Opal.coerce_to!(method_name, String, :to_str)
5
-
6
- `/^[a-zA-Z_][a-zA-Z0-9_]*?$/.test(method_name)`
7
- end
8
- end
9
-
10
- # Struct was rewritten in Opal 0.9
11
- # https://github.com/opal/opal/blob/1a33f23fdb4b07ff07b89f8077da060f1fdb635c/opal/corelib/struct.rb
12
- # Then a hash fix for Struct (which keeps deprectation formatter from grouping properly) was submitted in https://github.com/opal/opal/pull/1123
13
- # For simplicity's sake, cut and pasted entire Opal 0.9 struct class here
14
-
15
- # Native monkey patches struct's initializer, so get it in first
16
- require 'native'
17
-
18
- class Struct
19
- include Enumerable
20
-
21
- def self.new(name = undefined, *args, &block)
22
- return super unless self == Struct
23
-
24
- if name[0] == name[0].upcase
25
- Struct.const_set(name, new(*args))
26
- else
27
- args.unshift name
28
-
29
- Class.new(self) {
30
- args.each { |arg| define_struct_attribute arg }
31
-
32
- instance_eval(&block) if block
33
-
34
- class << self
35
- def new(*args)
36
- instance = allocate
37
- `#{instance}.$$data = {};`
38
- instance.initialize(*args)
39
- instance
40
- end
41
-
42
- alias [] new
43
- end
44
- }
45
- end
46
- end
47
-
48
- def self.define_struct_attribute(name)
49
- if self == Struct
50
- raise ArgumentError, 'you cannot define attributes to the Struct class'
51
- end
52
-
53
- members << name
54
-
55
- define_method name do
56
- self[name]
57
- end
58
-
59
- define_method "#{name}=" do |value|
60
- self[name] = value
61
- end
62
- end
63
-
64
- def self.members
65
- if self == Struct
66
- raise ArgumentError, 'the Struct class has no members'
67
- end
68
-
69
- @members ||= []
70
- end
71
-
72
- def self.inherited(klass)
73
- members = @members
74
-
75
- klass.instance_eval {
76
- @members = members
77
- }
78
- end
79
-
80
- def initialize(*args)
81
- members.each_with_index { |name, index|
82
- self[name] = args[index]
83
- }
84
- end
85
-
86
- def members
87
- self.class.members
88
- end
89
-
90
- def [](name)
91
- if Integer === name
92
- raise IndexError, "offset #{name} too small for struct(size:#{members.size})" if name < -members.size
93
- raise IndexError, "offset #{name} too large for struct(size:#{members.size})" if name >= members.size
94
-
95
- name = members[name]
96
- elsif String === name
97
- raise NameError, "no member '#{name}' in struct" unless members.include?(name.to_sym)
98
- else
99
- raise TypeError, "no implicit conversion of #{name.class} into Integer"
100
- end
101
-
102
- name = Opal.coerce_to!(name, String, :to_str)
103
- `self.$$data[name]`
104
- end
105
-
106
- def []=(name, value)
107
- if Integer === name
108
- raise IndexError, "offset #{name} too small for struct(size:#{members.size})" if name < -members.size
109
- raise IndexError, "offset #{name} too large for struct(size:#{members.size})" if name >= members.size
110
-
111
- name = members[name]
112
- elsif String === name
113
- raise NameError, "no member '#{name}' in struct" unless members.include?(name.to_sym)
114
- else
115
- raise TypeError, "no implicit conversion of #{name.class} into Integer"
116
- end
117
-
118
- name = Opal.coerce_to!(name, String, :to_str)
119
- `self.$$data[name] = value`
120
- end
121
-
122
- def ==(other)
123
- return false unless other.instance_of?(self.class)
124
-
125
- %x{
126
- var recursed1 = {}, recursed2 = {};
127
-
128
- function _eqeq(struct, other) {
129
- var key, a, b;
130
-
131
- recursed1[#{`struct`.__id__}] = true;
132
- recursed2[#{`other`.__id__}] = true;
133
-
134
- for (key in struct.$$data) {
135
- a = struct.$$data[key];
136
- b = other.$$data[key];
137
-
138
- if (#{Struct === `a`}) {
139
- if (!recursed1.hasOwnProperty(#{`a`.__id__}) || !recursed2.hasOwnProperty(#{`b`.__id__})) {
140
- if (!_eqeq(a, b)) {
141
- return false;
142
- }
143
- }
144
- } else {
145
- if (!#{`a` == `b`}) {
146
- return false;
147
- }
148
- }
149
- }
150
-
151
- return true;
152
- }
153
-
154
- return _eqeq(self, other);
155
- }
156
- end
157
-
158
- def hash
159
- Hash.new(`self.$$data`).hash
160
- end
161
-
162
- def eql?(other)
163
- return false unless other.instance_of?(self.class)
164
-
165
- %x{
166
- var recursed1 = {}, recursed2 = {};
167
-
168
- function _eqeq(struct, other) {
169
- var key, a, b;
170
-
171
- recursed1[#{`struct`.__id__}] = true;
172
- recursed2[#{`other`.__id__}] = true;
173
-
174
- for (key in struct.$$data) {
175
- a = struct.$$data[key];
176
- b = other.$$data[key];
177
-
178
- if (#{Struct === `a`}) {
179
- if (!recursed1.hasOwnProperty(#{`a`.__id__}) || !recursed2.hasOwnProperty(#{`b`.__id__})) {
180
- if (!_eqeq(a, b)) {
181
- return false;
182
- }
183
- }
184
- } else {
185
- if (!#{`a`.eql?(`b`)}) {
186
- return false;
187
- }
188
- }
189
- }
190
-
191
- return true;
192
- }
193
-
194
- return _eqeq(self, other);
195
- }
196
- end
197
-
198
- def each
199
- return enum_for(:each) { self.size } unless block_given?
200
-
201
- members.each { |name| yield self[name] }
202
- self
203
- end
204
-
205
- def each_pair
206
- return enum_for(:each_pair) { self.size } unless block_given?
207
-
208
- members.each { |name| yield [name, self[name]] }
209
- self
210
- end
211
-
212
- def length
213
- members.length
214
- end
215
-
216
- alias size length
217
-
218
- def to_a
219
- members.map { |name| self[name] }
220
- end
221
-
222
- alias values to_a
223
-
224
- def inspect
225
- result = "#<struct "
226
-
227
- if self.class == Struct
228
- result += "#{self.class} "
229
- end
230
-
231
- result += each_pair.map { |name, value|
232
- "#{name}=#{value.inspect}"
233
- }.join ", "
234
-
235
- result += ">"
236
-
237
- result
238
- end
239
-
240
- alias to_s inspect
241
-
242
- def to_h
243
- members.inject({}) { |h, name| h[name] = self[name]; h }
244
- end
245
-
246
- def values_at(*args)
247
- args = args.map { |arg| `arg.$$is_range ? #{arg.to_a} : arg` }.flatten
248
- %x{
249
- var result = [];
250
- for (var i = 0, len = args.length; i < len; i++) {
251
- if (!args[i].$$is_number) {
252
- #{raise TypeError, "no implicit conversion of #{`args[i]`.class} into Integer"}
253
- }
254
- result.push(#{self[`args[i]`]});
255
- }
256
- return result;
257
- }
258
- end
259
- end
260
- end
@@ -1,3 +0,0 @@
1
- # struct is done in pre-require fixes
2
- require_relative 'corelib/regexp'
3
- require_relative 'corelib/error'
@@ -1,80 +0,0 @@
1
- module Kernel
2
- unless Opal::RSpec::Compatibility.clones_singleton_methods?
3
- def copy_singleton_methods(other)
4
- %x{
5
- var name;
6
- if (other.hasOwnProperty('$$meta')) {
7
- var other_singleton_class_proto = Opal.get_singleton_class(other).$$proto;
8
- var self_singleton_class_proto = Opal.get_singleton_class(self).$$proto;
9
- for (name in other_singleton_class_proto) {
10
- if (name.charAt(0) === '$' && other_singleton_class_proto.hasOwnProperty(name)) {
11
- self_singleton_class_proto[name] = other_singleton_class_proto[name];
12
- }
13
- }
14
- }
15
- for (name in other) {
16
- if (name.charAt(0) === '$' && name.charAt(1) !== '$' && other.hasOwnProperty(name)) {
17
- self[name] = other[name];
18
- }
19
- }
20
- }
21
- end
22
-
23
- def clone
24
- copy = self.class.allocate
25
-
26
- copy.copy_instance_variables(self)
27
- copy.copy_singleton_methods(self)
28
- copy.initialize_clone(self)
29
-
30
- copy
31
- end
32
- end
33
-
34
- # RSpec tries to add context with this. something like this: https://github.com/stacktracejs/stacktrace.js would be better than this but
35
- # avoiding adding an NPM dependency for now
36
- def caller
37
- %x{
38
- function getErrorObject(){
39
- try { throw Error('') } catch(err) { return err; }
40
- }
41
-
42
-
43
- var err = getErrorObject();
44
- }
45
- stack = `err.stack`
46
- caller_lines = stack.split("\n")[4..-1]
47
- caller_lines.reject! { |l| l.strip.empty? }
48
-
49
- result_formatter = lambda do |filename, line, method=nil|
50
- "#{filename}:#{line} in `(#{method ? method : 'unknown method'})'"
51
- end
52
-
53
- caller_lines.map do |raw_line|
54
- if match = /\s*at (.*) \((\S+):(\d+):\d+/.match(raw_line)
55
- method, filename, line = match.captures
56
- result_formatter[filename, line, method]
57
- elsif match = /\s*at (\S+):(\d+):\d+/.match(raw_line)
58
- filename, line = match.captures
59
- result_formatter[filename, line]
60
- # catch phantom/no 2nd line/col #
61
- elsif match = /\s*at (.*) \((\S+):(\d+)/.match(raw_line)
62
- method, filename, line = match.captures
63
- result_formatter[filename, line, method]
64
- elsif match = /\s*at (.*):(\d+)/.match(raw_line)
65
- filename, line = match.captures
66
- result_formatter[filename, line]
67
- # Firefox - Opal.modules["rspec/core/metadata"]/</</</</def.$populate@http://192.168.59.103:9292/assets/rspec/core/metadata.self.js?body=1:102:13
68
- elsif match = /(.*?)@(\S+):(\d+):\d+/.match(raw_line)
69
- method, filename, line = match.captures
70
- result_formatter[filename, line, method]
71
- # webkit - http://192.168.59.103:9292/assets/opal/rspec/sprockets_runner.js:45117:314
72
- elsif match = /(\S+):(\d+):\d+/.match(raw_line)
73
- filename, line = match.captures
74
- result_formatter[filename, line]
75
- else
76
- "#{filename}:-1 in `(can't parse this stack trace)`"
77
- end
78
- end
79
- end
80
- end
@@ -1,23 +0,0 @@
1
- # https://github.com/opal/opal/pull/1104, fixed in Opal 0.9
2
- # Opal hasn't been using $stdout as a default value
3
- unless Opal::RSpec::Compatibility.pp_uses_stdout_default?
4
- class PP
5
- class << self
6
- if `(typeof(console) === "undefined" || typeof(console.log) === "undefined")`
7
- def pp(obj, out=$stdout, width=79)
8
- p(*args)
9
- end
10
- else
11
- def pp(obj, out=$stdout, width=79)
12
- if String === out
13
- out + obj.inspect + "\n"
14
- else
15
- out << obj.inspect + "\n"
16
- end
17
- end
18
- end
19
-
20
- alias :singleline_pp :pp
21
- end
22
- end
23
- end
@@ -1,36 +0,0 @@
1
- # https://github.com/opal/opal/pull/1152
2
- unless Opal::RSpec::Compatibility.set_has_superset?
3
- class Set
4
- def superset?(set)
5
- set.is_a?(Set) or raise ArgumentError, "value must be a set"
6
- return false if size < set.size
7
- set.all? { |o| include?(o) }
8
- end
9
-
10
- alias >= superset?
11
-
12
- def proper_superset?(set)
13
- set.is_a?(Set) or raise ArgumentError, "value must be a set"
14
- return false if size <= set.size
15
- set.all? { |o| include?(o) }
16
- end
17
-
18
- alias > proper_superset?
19
-
20
- def subset?(set)
21
- set.is_a?(Set) or raise ArgumentError, "value must be a set"
22
- return false if set.size < size
23
- all? { |o| set.include?(o) }
24
- end
25
-
26
- alias <= subset?
27
-
28
- def proper_subset?(set)
29
- set.is_a?(Set) or raise ArgumentError, "value must be a set"
30
- return false if set.size <= size
31
- all? { |o| set.include?(o) }
32
- end
33
-
34
- alias < proper_subset?
35
- end
36
- end
@@ -1,2 +0,0 @@
1
- require_relative 'stdlib/pp'
2
- require_relative 'stdlib/set'
@@ -1,9 +0,0 @@
1
- unless Opal::RSpec::Compatibility.class_descendant_of_self_fixed?
2
- class ::RSpec::Core::ExampleGroup
3
- def self.parent_groups
4
- # https://github.com/opal/opal/issues/1077, fixed in Opal 0.9
5
- # @parent_groups ||= ancestors.select { |a| a < RSpec::Core::ExampleGroup }
6
- @parent_groups ||= ancestors.select { |a| a < RSpec::Core::ExampleGroup and a != RSpec::Core::ExampleGroup }
7
- end
8
- end
9
- end
@@ -1,14 +0,0 @@
1
- unless Opal::RSpec::Compatibility.is_set_coerced_to_array?
2
- class RSpec::Core::Reporter
3
- # https://github.com/opal/opal/issues/858, fixed in Opal 0.9
4
- # The problem is not directly related to the Reporter class (it has more to do with Formatter's call in add using a splat in the args list and right now, Opal does not run a to_a on a set that can be an array in the splat before the callee method takes over)
5
- def register_listener(listener, *notifications)
6
- # Without this, we won't flatten out each notification properly (e.g. example_started, finished, etc.)
7
- notifications = notifications[0].to_a if notifications[0].is_a? Set
8
- notifications.each do |notification|
9
- @listeners[notification.to_sym] << listener
10
- end
11
- true
12
- end
13
- end
14
- end
@@ -1,25 +0,0 @@
1
- unless Opal::RSpec::Compatibility.undef_within_exec_works?
2
- module ::RSpec::Expectations::Syntax
3
- def disable_expect(syntax_host=::RSpec::Matchers)
4
- return unless expect_enabled?(syntax_host)
5
-
6
- # undef not working on Opal 0.8
7
- # syntax_host.module_exec do
8
- # undef expect
9
- # end
10
- syntax_host.remove_method(:expect)
11
- end
12
-
13
- def disable_should(syntax_host=default_should_host)
14
- return unless should_enabled?(syntax_host)
15
-
16
- # undef not working on Opal 0.8
17
- # syntax_host.module_exec do
18
- # undef should
19
- # undef should_not
20
- # end
21
- syntax_host.remove_method(:should)
22
- syntax_host.remove_method(:should_not)
23
- end
24
- end
25
- end
@@ -1,23 +0,0 @@
1
- unless Opal::RSpec::Compatibility.lambda_zero_arg_throws_arg_error?
2
- module ::RSpec::Support::FuzzyMatcher
3
- def self.values_match?(expected, actual)
4
- if Array === expected && Enumerable === actual && !(Struct === actual)
5
- return arrays_match?(expected, actual.to_a)
6
- elsif Hash === expected && Hash === actual
7
- return hashes_match?(expected, actual)
8
- elsif actual == expected
9
- return true
10
- elsif expected.is_a?(Proc)
11
- return expected == actual
12
- end
13
-
14
- begin
15
- expected === actual
16
- rescue ArgumentError
17
- # Some objects, like 0-arg lambdas on 1.9+, raise
18
- # ArgumentError for `expected === actual`.
19
- false
20
- end
21
- end
22
- end
23
- end
@@ -1,8 +0,0 @@
1
- require 'rspec/support/ruby_features'
2
-
3
- module ::RSpec::Support::RubyFeatures
4
- # Weird behavior when optional_and_splat_args_supported? is false (which is the case on Opal) and required_kw_args_supported? is true, so forcing this to false
5
- def required_kw_args_supported?
6
- false
7
- end
8
- end
@@ -1,2 +0,0 @@
1
- # Promise on the run, see opal alternates
2
- RSpec::Core::Metadata backwards compatibility :example_group allows integration libraries like VCR to infer a fixture name from the example description by walking up nesting structure
@@ -1,2 +0,0 @@
1
- # Opal doesn't do checking to see if args match arity
2
- RSpec::Core::MetadataFilter.filter_applies\? raises an error when the proc has an incorrect arity
@@ -1,38 +0,0 @@
1
- # RSpec::Core::ExampleGroup setting pending metadata in parent marks every example as pending
2
- # This opal-rspec test failure is happening because 'fail' in opal does not behave correctly
3
- # https://github.com/opal/opal/pull/1117, status pending
4
- unless Opal::RSpec::Compatibility.fail_raise_matches_mri?
5
- module Kernel
6
- def fail(message=nil)
7
- if message
8
- raise message
9
- else
10
- raise RuntimeError.new
11
- end
12
- end
13
- end
14
- end
15
-
16
- # https://github.com/opal/opal/issues/1110, fixed in Opal 0.9
17
- unless Opal::RSpec::Compatibility.class_within_class_new_works?
18
- class ::RSpec::Core::HooksHost
19
- include Hooks
20
-
21
- def parent_groups
22
- []
23
- end
24
- end
25
- end
26
-
27
- # Fixed in Opal 0.9
28
- # https://github.com/opal/opal/commit/a6ec3164fcbb0f98ef46d385ea06bf0591828f23)
29
- unless Object.const_defined? :ZeroDivisionError
30
- class ZeroDivisionError < StandardError
31
- end
32
- end
33
-
34
- # https://github.com/opal/opal/commit/5a17a12de1d3af45e189d34994a047fb7c1b4c72
35
- unless Object.const_defined? :SecurityError
36
- class SecurityError < Exception
37
- end
38
- end