opal-rspec-cj 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.gitmodules +15 -0
  4. data/.travis.yml +13 -0
  5. data/.yardopts +5 -0
  6. data/CHANGELOG.md +25 -0
  7. data/Gemfile +8 -0
  8. data/README.md +147 -0
  9. data/Rakefile +26 -0
  10. data/config.ru +10 -0
  11. data/example/Gemfile +4 -0
  12. data/example/README.md +13 -0
  13. data/example/Rakefile +8 -0
  14. data/example/opal/user.rb +11 -0
  15. data/example/spec/user_spec.rb +15 -0
  16. data/lib/opal-rspec.rb +2 -0
  17. data/lib/opal/rspec.rb +20 -0
  18. data/lib/opal/rspec/rake_task.rb +63 -0
  19. data/lib/opal/rspec/version.rb +5 -0
  20. data/opal-rspec.gemspec +21 -0
  21. data/opal/opal-rspec.rb +1 -0
  22. data/opal/opal/rspec.rb +25 -0
  23. data/opal/opal/rspec/async.rb +289 -0
  24. data/opal/opal/rspec/browser_formatter.rb +188 -0
  25. data/opal/opal/rspec/fixes.rb +116 -0
  26. data/opal/opal/rspec/requires.rb +45 -0
  27. data/opal/opal/rspec/runner.rb +69 -0
  28. data/opal/opal/rspec/sprockets_runner.rb.erb +11 -0
  29. data/opal/opal/rspec/text_formatter.rb +74 -0
  30. data/spec/async_spec.rb +38 -0
  31. data/spec/example_spec.rb +163 -0
  32. data/spec/matchers_spec.rb +201 -0
  33. data/spec/mock_spec.rb +63 -0
  34. data/spec/named_subject_spec.rb +11 -0
  35. data/spec/should_syntax_spec.rb +17 -0
  36. data/vendor/spec_runner.js +50 -0
  37. data/vendor_lib/rspec-expectations.rb +1 -0
  38. data/vendor_lib/rspec.rb +3 -0
  39. data/vendor_lib/rspec/autorun.rb +2 -0
  40. data/vendor_lib/rspec/core.rb +203 -0
  41. data/vendor_lib/rspec/core/backport_random.rb +302 -0
  42. data/vendor_lib/rspec/core/backtrace_formatter.rb +65 -0
  43. data/vendor_lib/rspec/core/command_line.rb +36 -0
  44. data/vendor_lib/rspec/core/configuration.rb +1129 -0
  45. data/vendor_lib/rspec/core/configuration_options.rb +143 -0
  46. data/vendor_lib/rspec/core/drb_command_line.rb +26 -0
  47. data/vendor_lib/rspec/core/drb_options.rb +87 -0
  48. data/vendor_lib/rspec/core/dsl.rb +26 -0
  49. data/vendor_lib/rspec/core/example.rb +312 -0
  50. data/vendor_lib/rspec/core/example_group.rb +540 -0
  51. data/vendor_lib/rspec/core/filter_manager.rb +224 -0
  52. data/vendor_lib/rspec/core/flat_map.rb +17 -0
  53. data/vendor_lib/rspec/core/formatters.rb +54 -0
  54. data/vendor_lib/rspec/core/formatters/base_formatter.rb +291 -0
  55. data/vendor_lib/rspec/core/formatters/base_text_formatter.rb +307 -0
  56. data/vendor_lib/rspec/core/formatters/deprecation_formatter.rb +193 -0
  57. data/vendor_lib/rspec/core/formatters/documentation_formatter.rb +67 -0
  58. data/vendor_lib/rspec/core/formatters/helpers.rb +82 -0
  59. data/vendor_lib/rspec/core/formatters/html_formatter.rb +155 -0
  60. data/vendor_lib/rspec/core/formatters/html_printer.rb +408 -0
  61. data/vendor_lib/rspec/core/formatters/json_formatter.rb +99 -0
  62. data/vendor_lib/rspec/core/formatters/progress_formatter.rb +32 -0
  63. data/vendor_lib/rspec/core/formatters/snippet_extractor.rb +101 -0
  64. data/vendor_lib/rspec/core/hooks.rb +535 -0
  65. data/vendor_lib/rspec/core/memoized_helpers.rb +431 -0
  66. data/vendor_lib/rspec/core/metadata.rb +313 -0
  67. data/vendor_lib/rspec/core/mocking/with_absolutely_nothing.rb +11 -0
  68. data/vendor_lib/rspec/core/mocking/with_flexmock.rb +27 -0
  69. data/vendor_lib/rspec/core/mocking/with_mocha.rb +52 -0
  70. data/vendor_lib/rspec/core/mocking/with_rr.rb +27 -0
  71. data/vendor_lib/rspec/core/mocking/with_rspec.rb +27 -0
  72. data/vendor_lib/rspec/core/option_parser.rb +234 -0
  73. data/vendor_lib/rspec/core/ordering.rb +154 -0
  74. data/vendor_lib/rspec/core/pending.rb +110 -0
  75. data/vendor_lib/rspec/core/project_initializer.rb +88 -0
  76. data/vendor_lib/rspec/core/rake_task.rb +128 -0
  77. data/vendor_lib/rspec/core/reporter.rb +132 -0
  78. data/vendor_lib/rspec/core/ruby_project.rb +44 -0
  79. data/vendor_lib/rspec/core/runner.rb +97 -0
  80. data/vendor_lib/rspec/core/shared_context.rb +53 -0
  81. data/vendor_lib/rspec/core/shared_example_group.rb +146 -0
  82. data/vendor_lib/rspec/core/shared_example_group/collection.rb +27 -0
  83. data/vendor_lib/rspec/core/version.rb +7 -0
  84. data/vendor_lib/rspec/core/warnings.rb +22 -0
  85. data/vendor_lib/rspec/core/world.rb +131 -0
  86. data/vendor_lib/rspec/expectations.rb +75 -0
  87. data/vendor_lib/rspec/expectations/differ.rb +154 -0
  88. data/vendor_lib/rspec/expectations/errors.rb +9 -0
  89. data/vendor_lib/rspec/expectations/expectation_target.rb +87 -0
  90. data/vendor_lib/rspec/expectations/extensions.rb +1 -0
  91. data/vendor_lib/rspec/expectations/extensions/object.rb +29 -0
  92. data/vendor_lib/rspec/expectations/fail_with.rb +79 -0
  93. data/vendor_lib/rspec/expectations/handler.rb +68 -0
  94. data/vendor_lib/rspec/expectations/syntax.rb +182 -0
  95. data/vendor_lib/rspec/expectations/version.rb +8 -0
  96. data/vendor_lib/rspec/matchers.rb +633 -0
  97. data/vendor_lib/rspec/matchers/built_in.rb +39 -0
  98. data/vendor_lib/rspec/matchers/built_in/base_matcher.rb +68 -0
  99. data/vendor_lib/rspec/matchers/built_in/be.rb +213 -0
  100. data/vendor_lib/rspec/matchers/built_in/be_instance_of.rb +15 -0
  101. data/vendor_lib/rspec/matchers/built_in/be_kind_of.rb +11 -0
  102. data/vendor_lib/rspec/matchers/built_in/be_within.rb +55 -0
  103. data/vendor_lib/rspec/matchers/built_in/change.rb +141 -0
  104. data/vendor_lib/rspec/matchers/built_in/cover.rb +21 -0
  105. data/vendor_lib/rspec/matchers/built_in/eq.rb +22 -0
  106. data/vendor_lib/rspec/matchers/built_in/eql.rb +23 -0
  107. data/vendor_lib/rspec/matchers/built_in/equal.rb +48 -0
  108. data/vendor_lib/rspec/matchers/built_in/exist.rb +26 -0
  109. data/vendor_lib/rspec/matchers/built_in/has.rb +48 -0
  110. data/vendor_lib/rspec/matchers/built_in/include.rb +61 -0
  111. data/vendor_lib/rspec/matchers/built_in/match.rb +17 -0
  112. data/vendor_lib/rspec/matchers/built_in/match_array.rb +51 -0
  113. data/vendor_lib/rspec/matchers/built_in/raise_error.rb +154 -0
  114. data/vendor_lib/rspec/matchers/built_in/respond_to.rb +74 -0
  115. data/vendor_lib/rspec/matchers/built_in/satisfy.rb +30 -0
  116. data/vendor_lib/rspec/matchers/built_in/start_and_end_with.rb +48 -0
  117. data/vendor_lib/rspec/matchers/built_in/throw_symbol.rb +94 -0
  118. data/vendor_lib/rspec/matchers/built_in/yield.rb +297 -0
  119. data/vendor_lib/rspec/matchers/compatibility.rb +14 -0
  120. data/vendor_lib/rspec/matchers/configuration.rb +113 -0
  121. data/vendor_lib/rspec/matchers/dsl.rb +23 -0
  122. data/vendor_lib/rspec/matchers/generated_descriptions.rb +35 -0
  123. data/vendor_lib/rspec/matchers/matcher.rb +301 -0
  124. data/vendor_lib/rspec/matchers/method_missing.rb +12 -0
  125. data/vendor_lib/rspec/matchers/operator_matcher.rb +99 -0
  126. data/vendor_lib/rspec/matchers/pretty.rb +70 -0
  127. data/vendor_lib/rspec/matchers/test_unit_integration.rb +11 -0
  128. data/vendor_lib/rspec/mocks.rb +100 -0
  129. data/vendor_lib/rspec/mocks/any_instance/chain.rb +92 -0
  130. data/vendor_lib/rspec/mocks/any_instance/expectation_chain.rb +47 -0
  131. data/vendor_lib/rspec/mocks/any_instance/message_chains.rb +75 -0
  132. data/vendor_lib/rspec/mocks/any_instance/recorder.rb +200 -0
  133. data/vendor_lib/rspec/mocks/any_instance/stub_chain.rb +45 -0
  134. data/vendor_lib/rspec/mocks/any_instance/stub_chain_chain.rb +23 -0
  135. data/vendor_lib/rspec/mocks/argument_list_matcher.rb +104 -0
  136. data/vendor_lib/rspec/mocks/argument_matchers.rb +264 -0
  137. data/vendor_lib/rspec/mocks/arity_calculator.rb +66 -0
  138. data/vendor_lib/rspec/mocks/configuration.rb +111 -0
  139. data/vendor_lib/rspec/mocks/error_generator.rb +203 -0
  140. data/vendor_lib/rspec/mocks/errors.rb +12 -0
  141. data/vendor_lib/rspec/mocks/example_methods.rb +201 -0
  142. data/vendor_lib/rspec/mocks/extensions/marshal.rb +17 -0
  143. data/vendor_lib/rspec/mocks/framework.rb +36 -0
  144. data/vendor_lib/rspec/mocks/instance_method_stasher.rb +112 -0
  145. data/vendor_lib/rspec/mocks/matchers/have_received.rb +99 -0
  146. data/vendor_lib/rspec/mocks/matchers/receive.rb +112 -0
  147. data/vendor_lib/rspec/mocks/matchers/receive_messages.rb +72 -0
  148. data/vendor_lib/rspec/mocks/message_expectation.rb +643 -0
  149. data/vendor_lib/rspec/mocks/method_double.rb +209 -0
  150. data/vendor_lib/rspec/mocks/method_reference.rb +95 -0
  151. data/vendor_lib/rspec/mocks/mock.rb +7 -0
  152. data/vendor_lib/rspec/mocks/mutate_const.rb +406 -0
  153. data/vendor_lib/rspec/mocks/object_reference.rb +90 -0
  154. data/vendor_lib/rspec/mocks/order_group.rb +82 -0
  155. data/vendor_lib/rspec/mocks/proxy.rb +269 -0
  156. data/vendor_lib/rspec/mocks/proxy_for_nil.rb +37 -0
  157. data/vendor_lib/rspec/mocks/space.rb +95 -0
  158. data/vendor_lib/rspec/mocks/standalone.rb +3 -0
  159. data/vendor_lib/rspec/mocks/stub_chain.rb +51 -0
  160. data/vendor_lib/rspec/mocks/syntax.rb +374 -0
  161. data/vendor_lib/rspec/mocks/targets.rb +90 -0
  162. data/vendor_lib/rspec/mocks/test_double.rb +109 -0
  163. data/vendor_lib/rspec/mocks/verifying_double.rb +77 -0
  164. data/vendor_lib/rspec/mocks/verifying_message_expecation.rb +60 -0
  165. data/vendor_lib/rspec/mocks/verifying_proxy.rb +151 -0
  166. data/vendor_lib/rspec/mocks/version.rb +7 -0
  167. data/vendor_lib/rspec/support.rb +6 -0
  168. data/vendor_lib/rspec/support/caller_filter.rb +56 -0
  169. data/vendor_lib/rspec/support/spec.rb +14 -0
  170. data/vendor_lib/rspec/support/spec/deprecation_helpers.rb +29 -0
  171. data/vendor_lib/rspec/support/spec/in_sub_process.rb +40 -0
  172. data/vendor_lib/rspec/support/spec/stderr_splitter.rb +50 -0
  173. data/vendor_lib/rspec/support/version.rb +7 -0
  174. data/vendor_lib/rspec/support/warnings.rb +41 -0
  175. data/vendor_lib/rspec/version.rb +5 -0
  176. metadata +268 -0
@@ -0,0 +1,201 @@
1
+ describe "be_truthy" do
2
+ it "passes with truthy values" do
3
+ expect(true).to be_truthy
4
+ expect(1.0).to be_truthy
5
+ expect([]).to be_truthy
6
+ end
7
+
8
+ it "fails with falsey values" do
9
+ expect {
10
+ expect(false).to be_truthy
11
+ }.to raise_error(Exception)
12
+
13
+ expect {
14
+ expect(nil).to be_truthy
15
+ }.to raise_error(Exception)
16
+ end
17
+ end
18
+
19
+ describe "be_falsey" do
20
+ it "passes with falsey values" do
21
+ expect(false).to be_falsey
22
+ expect(nil).to be_falsey
23
+ end
24
+
25
+ it "fails with truthy values" do
26
+ expect {
27
+ expect(true).to be_falsey
28
+ }.to raise_error(Exception)
29
+
30
+ expect {
31
+ expect({}).to be_falsey
32
+ }.to raise_error(Exception)
33
+ end
34
+ end
35
+
36
+ describe "be_nil" do
37
+ it "passes when object is nil" do
38
+ expect(nil).to be_nil
39
+ end
40
+
41
+ it "fails with any other object" do
42
+ expect {
43
+ expect(false).to be_nil
44
+ }.to raise_error(Exception)
45
+
46
+ expect {
47
+ expect(:foo).to be_nil
48
+ }.to raise_error(Exception)
49
+ end
50
+ end
51
+
52
+ describe "be_kind_of" do
53
+ it "passes if actual is kind of expected class" do
54
+ expect("foo").to be_kind_of(String)
55
+ expect("foo").to_not be_kind_of(Numeric)
56
+ end
57
+
58
+ it "passes if actual is kind of superclass of expected class" do
59
+ expect([]).to be_kind_of(Object)
60
+ end
61
+
62
+ it "fails if expected is not a kind of expected" do
63
+ expect {
64
+ expect("foo").to be_kind_of(Integer)
65
+ }.to raise_error(Exception)
66
+
67
+ expect {
68
+ expect("foo").to_not be_kind_of(String)
69
+ }.to raise_error(Exception)
70
+ end
71
+ end
72
+
73
+ describe "eq" do
74
+ it "matches when actual == expected" do
75
+ expect(:foo).to eq(:foo)
76
+ end
77
+
78
+ it "does not match when actual != expected" do
79
+ expect(:foo).not_to eq(42)
80
+ end
81
+
82
+ it "fails if matcher does not match" do
83
+ expect {
84
+ expect(:foo).to eq(42)
85
+ }.to raise_error(Exception)
86
+
87
+ expect {
88
+ expect(:foo).not_to eq(:foo)
89
+ }.to raise_error(Exception)
90
+ end
91
+ end
92
+
93
+ describe "eql" do
94
+ it "matches when expected.eql?(actual)" do
95
+ expect(1).to eql(1)
96
+ end
97
+
98
+ it "does not match when !expected.eql?(actual)" do
99
+ expect(1).to_not eql(:foo)
100
+ end
101
+
102
+ it "fails if matcher does not match" do
103
+ expect {
104
+ expect(1).to eql(:bar)
105
+ }.to raise_error(Exception)
106
+
107
+ expect {
108
+ expect(2).to_not eql(2)
109
+ }.to raise_error(Exception)
110
+ end
111
+ end
112
+
113
+ describe "include" do
114
+ it "matches if actual includes expected" do
115
+ expect("foo").to include("f")
116
+ expect([:foo, :bar, :baz]).to include(:baz)
117
+ expect({ :yellow => 'lorry' }).to include(:yellow)
118
+ end
119
+
120
+ it "does not match if actual does not inlcude expected" do
121
+ expect("foo").to_not include("b")
122
+ expect([:foo, :bar, :baz]).to_not include(:kapow)
123
+ expect({ :yellow => 'lorry' }).to_not include(:red)
124
+ end
125
+
126
+ it "fails if matcher does not match" do
127
+ expect {
128
+ expect("bar").to include("z")
129
+ }.to raise_error(Exception)
130
+ end
131
+ end
132
+
133
+ describe "respond_to" do
134
+ it "matches if actual responds to sym" do
135
+ expect("foo").to respond_to(:upcase)
136
+ end
137
+
138
+ it "does not match if actual does not respond to sym" do
139
+ expect(Object.new).to_not respond_to(:upcase)
140
+ end
141
+
142
+ it "fails if actual does not respond to sym" do
143
+ expect {
144
+ expect(Object.new).to respond_to(:upcase)
145
+ }.to raise_error(Exception)
146
+ end
147
+ end
148
+
149
+ describe "match" do
150
+ it "matches if actual matches expected" do
151
+ expect("foobar").to match(/ar/)
152
+ expect("foobar").to match("oob")
153
+ end
154
+
155
+ it "does not match if actual does not match expected" do
156
+ expect("foobar").to_not match(/baz/)
157
+ expect("foobar").to_not match("woosh")
158
+ end
159
+
160
+ it "fails unless matcher matches" do
161
+ expect {
162
+ exprct("hello").to match(/world/)
163
+ }.to raise_error(Exception)
164
+ end
165
+ end
166
+
167
+ describe "operator ==" do
168
+ it "matches if actual == expected" do
169
+ "hello".should == "hello"
170
+ end
171
+
172
+ it "does not match when actual does not == expected" do
173
+ "hello".should_not == "world"
174
+ end
175
+
176
+ it "fails unless matcher matches" do
177
+ expect {
178
+ "hello".should == "world"
179
+ }.to raise_error(Exception)
180
+ end
181
+ end
182
+
183
+ class PredicateTest
184
+ def foo?
185
+ true
186
+ end
187
+
188
+ def bar?
189
+ false
190
+ end
191
+ end
192
+
193
+ describe "predicate matchers" do
194
+ it "works with positive expectations" do
195
+ expect(PredicateTest.new).to be_foo
196
+ end
197
+
198
+ it "work with negative expectations" do
199
+ expect(PredicateTest.new).to_not be_bar
200
+ end
201
+ end
@@ -0,0 +1,63 @@
1
+ describe "RSpec mocks" do
2
+ describe "stubs" do
3
+ it "can stub basic methods" do
4
+ obj = Object.new
5
+ expect(obj).to receive(:foo) { 100 }
6
+ obj.foo.should == 100
7
+ end
8
+
9
+ it "raises an exception when stub returns wrong value" do
10
+ expect {
11
+ obj = Object.new
12
+ expect(obj).to receive(:bar) { 400 }
13
+ obj.bar.should == 42
14
+ }.to raise_error(Exception)
15
+ end
16
+
17
+ it "allow" do
18
+ obj = Object.new
19
+ allow(obj).to receive(:name) { "Adam B" }
20
+ allow(obj).to receive(:job).and_return("Eating Fruit Gums")
21
+
22
+ expect(obj.name).to eq("Adam B")
23
+ expect(obj.job).to eq("Eating Fruit Gums")
24
+ end
25
+
26
+ it "expecting arguments" do
27
+ person = double("person")
28
+ expect(person).to receive(:foo).with(4, 5, 6)
29
+ person.foo(4, 5, 6)
30
+ end
31
+ end
32
+
33
+ describe "doubles" do
34
+ it "define methods on double" do
35
+ person = double("person", :name => "Adam")
36
+ expect(person.name).to eq("Adam")
37
+ end
38
+
39
+ it "once" do
40
+ person = double("person")
41
+ expect(person).to receive(:name).once
42
+ person.name.should eq(nil)
43
+ end
44
+
45
+ it "twice" do
46
+ person = double("person")
47
+ expect(person).to receive(:name).twice
48
+ person.name
49
+ person.name.should
50
+ end
51
+ end
52
+
53
+ it "can mock existing methods on objects" do
54
+ expect(Time).to receive(:now).once.and_call_original
55
+ Time.now.should be_kind_of(Time)
56
+ end
57
+
58
+ describe 'stubs' do
59
+ it 'works and displays deprecation' do
60
+ Object.new.stub :foo
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,11 @@
1
+ describe "named subject" do
2
+ subject(:named_subject) { [1, 2, 3] }
3
+
4
+ it "should be the subject" do
5
+ subject.should be_kind_of(Array)
6
+ end
7
+
8
+ it "should be the named subject" do
9
+ subject.should eql(named_subject)
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ describe "One-liner should syntax" do
2
+ subject { 42 }
3
+
4
+ describe "should" do
5
+ it { should == 42 }
6
+ it { should_not == 43 }
7
+ end
8
+
9
+ describe "is_expected" do
10
+ it { is_expected.to eq(42) }
11
+ it { is_expected.to_not eq(43) }
12
+ end
13
+
14
+ describe "expect" do
15
+ it { expect(42).to eq(42) }
16
+ end
17
+ end
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Test runner for phantomjs
3
+ */
4
+ var args = phantom.args;
5
+ var page = require('webpage').create();
6
+
7
+ page.onConsoleMessage = function(msg) {
8
+ console.log(msg);
9
+ };
10
+
11
+ page.onInitialized = function() {
12
+ page.evaluate(function () {
13
+ window.OPAL_SPEC_PHANTOM = true;
14
+ });
15
+ };
16
+
17
+ /*
18
+ * Exit phantom instance "safely" see - https://github.com/ariya/phantomjs/issues/12697
19
+ * https://github.com/nobuoka/gulp-qunit/commit/d242aff9b79de7543d956e294b2ee36eda4bac6c
20
+ */
21
+ function phantom_exit(code) {
22
+ page.close();
23
+ setTimeout(function () { phantom.exit(code); }, 0);
24
+ }
25
+
26
+ page.open(args[0], function(status) {
27
+ if (status !== 'success') {
28
+ console.error("Cannot load: " + args[0]);
29
+ phantom_exit(1);
30
+ } else {
31
+ var timeout = parseInt(args[1] || 60000, 10);
32
+ var start = Date.now();
33
+ var interval = setInterval(function() {
34
+ if (Date.now() > start + timeout) {
35
+ console.error("Specs timed out");
36
+ phantom_exit(124);
37
+ } else {
38
+ var code = page.evaluate(function() {
39
+ return window.OPAL_SPEC_CODE;
40
+ });
41
+
42
+ if (code === 0 || code === 1) {
43
+ clearInterval(interval);
44
+ phantom_exit(code);
45
+ }
46
+ }
47
+ }, 500);
48
+ }
49
+ });
50
+
@@ -0,0 +1 @@
1
+ require "rspec/expectations"
@@ -0,0 +1,3 @@
1
+ require 'rspec/core'
2
+ require 'rspec/version'
3
+
@@ -0,0 +1,2 @@
1
+ require 'rspec/core'
2
+ RSpec::Core::Runner.autorun
@@ -0,0 +1,203 @@
1
+ require_rspec = if defined?(require_relative)
2
+ lambda do |path|
3
+ require_relative path
4
+ end
5
+ else # for 1.8.7
6
+ lambda do |path|
7
+ require "rspec/#{path}"
8
+ end
9
+ end
10
+
11
+ require 'set'
12
+ require 'time'
13
+ require 'rbconfig'
14
+
15
+ require_rspec['core/version']
16
+
17
+ require 'rspec/support/caller_filter'
18
+ require 'rspec/core/warnings'
19
+ require 'rspec/support/warnings'
20
+
21
+ require_rspec['core/flat_map']
22
+ require_rspec['core/filter_manager']
23
+ require_rspec['core/dsl']
24
+ require_rspec['core/reporter']
25
+
26
+ require_rspec['core/hooks']
27
+ require_rspec['core/memoized_helpers']
28
+ require_rspec['core/metadata']
29
+ require_rspec['core/pending']
30
+ require_rspec['core/formatters']
31
+ require_rspec['core/ordering']
32
+
33
+ require_rspec['core/world']
34
+ require_rspec['core/configuration']
35
+ require_rspec['core/option_parser']
36
+ require_rspec['core/configuration_options']
37
+ require_rspec['core/command_line']
38
+ require_rspec['core/runner']
39
+ require_rspec['core/example']
40
+ require_rspec['core/shared_example_group/collection']
41
+ require_rspec['core/shared_example_group']
42
+ require_rspec['core/example_group']
43
+
44
+ module RSpec
45
+ autoload :SharedContext, 'rspec/core/shared_context'
46
+
47
+ # @private
48
+ def self.wants_to_quit
49
+ # Used internally to determine what to do when a SIGINT is received
50
+ world.wants_to_quit
51
+ end
52
+
53
+ # @private
54
+ # Used internally to determine what to do when a SIGINT is received
55
+ def self.wants_to_quit=(maybe)
56
+ world.wants_to_quit=(maybe)
57
+ end
58
+
59
+ # @private
60
+ # Internal container for global non-configuration data
61
+ def self.world
62
+ @world ||= RSpec::Core::World.new
63
+ end
64
+
65
+ # @private
66
+ # Used internally to set the global object
67
+ def self.world=(new_world)
68
+ @world = new_world
69
+ end
70
+
71
+ # @private
72
+ # Used internally to ensure examples get reloaded between multiple runs in
73
+ # the same process.
74
+ def self.reset
75
+ @world = nil
76
+ @configuration = nil
77
+ end
78
+
79
+ # Returns the global [Configuration](RSpec/Core/Configuration) object. While you
80
+ # _can_ use this method to access the configuration, the more common
81
+ # convention is to use [RSpec.configure](RSpec#configure-class_method).
82
+ #
83
+ # @example
84
+ # RSpec.configuration.drb_port = 1234
85
+ # @see RSpec.configure
86
+ # @see Core::Configuration
87
+ def self.configuration
88
+ if block_given?
89
+ RSpec.warn_deprecation <<-WARNING
90
+
91
+ *****************************************************************
92
+ DEPRECATION WARNING
93
+
94
+ * RSpec.configuration with a block is deprecated and has no effect.
95
+ * please use RSpec.configure with a block instead.
96
+
97
+ Called from #{CallerFilter.first_non_rspec_line}
98
+ *****************************************************************
99
+
100
+ WARNING
101
+ end
102
+ @configuration ||= RSpec::Core::Configuration.new
103
+ end
104
+
105
+ # @private
106
+ # Used internally to set the global object
107
+ def self.configuration=(new_configuration)
108
+ @configuration = new_configuration
109
+ end
110
+
111
+ # Yields the global configuration to a block.
112
+ # @yield [Configuration] global configuration
113
+ #
114
+ # @example
115
+ # RSpec.configure do |config|
116
+ # config.add_formatter 'documentation'
117
+ # end
118
+ # @see Core::Configuration
119
+ def self.configure
120
+ yield configuration if block_given?
121
+ end
122
+
123
+ # @private
124
+ # Used internally to clear remaining groups when fail_fast is set
125
+ def self.clear_remaining_example_groups
126
+ world.example_groups.clear
127
+ end
128
+
129
+ # The example being executed.
130
+ #
131
+ # The primary audience for this method is library authors who need access
132
+ # to the example currently being executed and also want to support all
133
+ # versions of RSpec 2 and 3.
134
+ #
135
+ # @example
136
+ #
137
+ # RSpec.configure do |c|
138
+ # # context.example is deprecated, but RSpec.current_example is not
139
+ # # available until RSpec 3.0.
140
+ # fetch_current_example = RSpec.respond_to?(:current_example) ?
141
+ # proc { RSpec.current_example } : proc { |context| context.example }
142
+ #
143
+ # c.before(:each) do
144
+ # example = fetch_current_example.call(self)
145
+ #
146
+ # # ...
147
+ # end
148
+ # end
149
+ #
150
+ def self.current_example
151
+ Thread.current[:_rspec_current_example]
152
+ end
153
+
154
+ # Set the current example being executed.
155
+ # @api private
156
+ def self.current_example=(example)
157
+ Thread.current[:_rspec_current_example] = example
158
+ end
159
+
160
+ # @private
161
+ def self.windows_os?
162
+ RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/
163
+ end
164
+
165
+ module Core
166
+ # @private
167
+ # This avoids issues with reporting time caused by examples that
168
+ # change the value/meaning of Time.now without properly restoring
169
+ # it.
170
+ class Time
171
+ class << self
172
+ define_method(:now, &::Time.method(:now))
173
+ end
174
+ end
175
+
176
+ # @private path to executable file
177
+ def self.path_to_executable
178
+ @path_to_executable ||= File.expand_path('../../../exe/rspec', __FILE__)
179
+ end
180
+ end
181
+
182
+ MODULES_TO_AUTOLOAD = {
183
+ :Matchers => "rspec/expectations",
184
+ :Expectations => "rspec/expectations",
185
+ :Mocks => "rspec/mocks"
186
+ }
187
+
188
+ def self.const_missing(name)
189
+ # Load rspec-expectations when RSpec::Matchers is referenced. This allows
190
+ # people to define custom matchers (using `RSpec::Matchers.define`) before
191
+ # rspec-core has loaded rspec-expectations (since it delays the loading of
192
+ # it to allow users to configure a different assertion/expectation
193
+ # framework). `autoload` can't be used since it works with ruby's built-in
194
+ # require (e.g. for files that are available relative to a load path dir),
195
+ # but not with rubygems' extended require.
196
+ #
197
+ # As of rspec 2.14.1, we no longer require `rspec/mocks` and
198
+ # `rspec/expectations` when `rspec` is required, so we want
199
+ # to make them available as an autoload. For more info, see:
200
+ require MODULES_TO_AUTOLOAD.fetch(name) { return super }
201
+ ::RSpec.const_get(name)
202
+ end
203
+ end