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.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.gitmodules +15 -0
- data/.travis.yml +13 -0
- data/.yardopts +5 -0
- data/CHANGELOG.md +25 -0
- data/Gemfile +8 -0
- data/README.md +147 -0
- data/Rakefile +26 -0
- data/config.ru +10 -0
- data/example/Gemfile +4 -0
- data/example/README.md +13 -0
- data/example/Rakefile +8 -0
- data/example/opal/user.rb +11 -0
- data/example/spec/user_spec.rb +15 -0
- data/lib/opal-rspec.rb +2 -0
- data/lib/opal/rspec.rb +20 -0
- data/lib/opal/rspec/rake_task.rb +63 -0
- data/lib/opal/rspec/version.rb +5 -0
- data/opal-rspec.gemspec +21 -0
- data/opal/opal-rspec.rb +1 -0
- data/opal/opal/rspec.rb +25 -0
- data/opal/opal/rspec/async.rb +289 -0
- data/opal/opal/rspec/browser_formatter.rb +188 -0
- data/opal/opal/rspec/fixes.rb +116 -0
- data/opal/opal/rspec/requires.rb +45 -0
- data/opal/opal/rspec/runner.rb +69 -0
- data/opal/opal/rspec/sprockets_runner.rb.erb +11 -0
- data/opal/opal/rspec/text_formatter.rb +74 -0
- data/spec/async_spec.rb +38 -0
- data/spec/example_spec.rb +163 -0
- data/spec/matchers_spec.rb +201 -0
- data/spec/mock_spec.rb +63 -0
- data/spec/named_subject_spec.rb +11 -0
- data/spec/should_syntax_spec.rb +17 -0
- data/vendor/spec_runner.js +50 -0
- data/vendor_lib/rspec-expectations.rb +1 -0
- data/vendor_lib/rspec.rb +3 -0
- data/vendor_lib/rspec/autorun.rb +2 -0
- data/vendor_lib/rspec/core.rb +203 -0
- data/vendor_lib/rspec/core/backport_random.rb +302 -0
- data/vendor_lib/rspec/core/backtrace_formatter.rb +65 -0
- data/vendor_lib/rspec/core/command_line.rb +36 -0
- data/vendor_lib/rspec/core/configuration.rb +1129 -0
- data/vendor_lib/rspec/core/configuration_options.rb +143 -0
- data/vendor_lib/rspec/core/drb_command_line.rb +26 -0
- data/vendor_lib/rspec/core/drb_options.rb +87 -0
- data/vendor_lib/rspec/core/dsl.rb +26 -0
- data/vendor_lib/rspec/core/example.rb +312 -0
- data/vendor_lib/rspec/core/example_group.rb +540 -0
- data/vendor_lib/rspec/core/filter_manager.rb +224 -0
- data/vendor_lib/rspec/core/flat_map.rb +17 -0
- data/vendor_lib/rspec/core/formatters.rb +54 -0
- data/vendor_lib/rspec/core/formatters/base_formatter.rb +291 -0
- data/vendor_lib/rspec/core/formatters/base_text_formatter.rb +307 -0
- data/vendor_lib/rspec/core/formatters/deprecation_formatter.rb +193 -0
- data/vendor_lib/rspec/core/formatters/documentation_formatter.rb +67 -0
- data/vendor_lib/rspec/core/formatters/helpers.rb +82 -0
- data/vendor_lib/rspec/core/formatters/html_formatter.rb +155 -0
- data/vendor_lib/rspec/core/formatters/html_printer.rb +408 -0
- data/vendor_lib/rspec/core/formatters/json_formatter.rb +99 -0
- data/vendor_lib/rspec/core/formatters/progress_formatter.rb +32 -0
- data/vendor_lib/rspec/core/formatters/snippet_extractor.rb +101 -0
- data/vendor_lib/rspec/core/hooks.rb +535 -0
- data/vendor_lib/rspec/core/memoized_helpers.rb +431 -0
- data/vendor_lib/rspec/core/metadata.rb +313 -0
- data/vendor_lib/rspec/core/mocking/with_absolutely_nothing.rb +11 -0
- data/vendor_lib/rspec/core/mocking/with_flexmock.rb +27 -0
- data/vendor_lib/rspec/core/mocking/with_mocha.rb +52 -0
- data/vendor_lib/rspec/core/mocking/with_rr.rb +27 -0
- data/vendor_lib/rspec/core/mocking/with_rspec.rb +27 -0
- data/vendor_lib/rspec/core/option_parser.rb +234 -0
- data/vendor_lib/rspec/core/ordering.rb +154 -0
- data/vendor_lib/rspec/core/pending.rb +110 -0
- data/vendor_lib/rspec/core/project_initializer.rb +88 -0
- data/vendor_lib/rspec/core/rake_task.rb +128 -0
- data/vendor_lib/rspec/core/reporter.rb +132 -0
- data/vendor_lib/rspec/core/ruby_project.rb +44 -0
- data/vendor_lib/rspec/core/runner.rb +97 -0
- data/vendor_lib/rspec/core/shared_context.rb +53 -0
- data/vendor_lib/rspec/core/shared_example_group.rb +146 -0
- data/vendor_lib/rspec/core/shared_example_group/collection.rb +27 -0
- data/vendor_lib/rspec/core/version.rb +7 -0
- data/vendor_lib/rspec/core/warnings.rb +22 -0
- data/vendor_lib/rspec/core/world.rb +131 -0
- data/vendor_lib/rspec/expectations.rb +75 -0
- data/vendor_lib/rspec/expectations/differ.rb +154 -0
- data/vendor_lib/rspec/expectations/errors.rb +9 -0
- data/vendor_lib/rspec/expectations/expectation_target.rb +87 -0
- data/vendor_lib/rspec/expectations/extensions.rb +1 -0
- data/vendor_lib/rspec/expectations/extensions/object.rb +29 -0
- data/vendor_lib/rspec/expectations/fail_with.rb +79 -0
- data/vendor_lib/rspec/expectations/handler.rb +68 -0
- data/vendor_lib/rspec/expectations/syntax.rb +182 -0
- data/vendor_lib/rspec/expectations/version.rb +8 -0
- data/vendor_lib/rspec/matchers.rb +633 -0
- data/vendor_lib/rspec/matchers/built_in.rb +39 -0
- data/vendor_lib/rspec/matchers/built_in/base_matcher.rb +68 -0
- data/vendor_lib/rspec/matchers/built_in/be.rb +213 -0
- data/vendor_lib/rspec/matchers/built_in/be_instance_of.rb +15 -0
- data/vendor_lib/rspec/matchers/built_in/be_kind_of.rb +11 -0
- data/vendor_lib/rspec/matchers/built_in/be_within.rb +55 -0
- data/vendor_lib/rspec/matchers/built_in/change.rb +141 -0
- data/vendor_lib/rspec/matchers/built_in/cover.rb +21 -0
- data/vendor_lib/rspec/matchers/built_in/eq.rb +22 -0
- data/vendor_lib/rspec/matchers/built_in/eql.rb +23 -0
- data/vendor_lib/rspec/matchers/built_in/equal.rb +48 -0
- data/vendor_lib/rspec/matchers/built_in/exist.rb +26 -0
- data/vendor_lib/rspec/matchers/built_in/has.rb +48 -0
- data/vendor_lib/rspec/matchers/built_in/include.rb +61 -0
- data/vendor_lib/rspec/matchers/built_in/match.rb +17 -0
- data/vendor_lib/rspec/matchers/built_in/match_array.rb +51 -0
- data/vendor_lib/rspec/matchers/built_in/raise_error.rb +154 -0
- data/vendor_lib/rspec/matchers/built_in/respond_to.rb +74 -0
- data/vendor_lib/rspec/matchers/built_in/satisfy.rb +30 -0
- data/vendor_lib/rspec/matchers/built_in/start_and_end_with.rb +48 -0
- data/vendor_lib/rspec/matchers/built_in/throw_symbol.rb +94 -0
- data/vendor_lib/rspec/matchers/built_in/yield.rb +297 -0
- data/vendor_lib/rspec/matchers/compatibility.rb +14 -0
- data/vendor_lib/rspec/matchers/configuration.rb +113 -0
- data/vendor_lib/rspec/matchers/dsl.rb +23 -0
- data/vendor_lib/rspec/matchers/generated_descriptions.rb +35 -0
- data/vendor_lib/rspec/matchers/matcher.rb +301 -0
- data/vendor_lib/rspec/matchers/method_missing.rb +12 -0
- data/vendor_lib/rspec/matchers/operator_matcher.rb +99 -0
- data/vendor_lib/rspec/matchers/pretty.rb +70 -0
- data/vendor_lib/rspec/matchers/test_unit_integration.rb +11 -0
- data/vendor_lib/rspec/mocks.rb +100 -0
- data/vendor_lib/rspec/mocks/any_instance/chain.rb +92 -0
- data/vendor_lib/rspec/mocks/any_instance/expectation_chain.rb +47 -0
- data/vendor_lib/rspec/mocks/any_instance/message_chains.rb +75 -0
- data/vendor_lib/rspec/mocks/any_instance/recorder.rb +200 -0
- data/vendor_lib/rspec/mocks/any_instance/stub_chain.rb +45 -0
- data/vendor_lib/rspec/mocks/any_instance/stub_chain_chain.rb +23 -0
- data/vendor_lib/rspec/mocks/argument_list_matcher.rb +104 -0
- data/vendor_lib/rspec/mocks/argument_matchers.rb +264 -0
- data/vendor_lib/rspec/mocks/arity_calculator.rb +66 -0
- data/vendor_lib/rspec/mocks/configuration.rb +111 -0
- data/vendor_lib/rspec/mocks/error_generator.rb +203 -0
- data/vendor_lib/rspec/mocks/errors.rb +12 -0
- data/vendor_lib/rspec/mocks/example_methods.rb +201 -0
- data/vendor_lib/rspec/mocks/extensions/marshal.rb +17 -0
- data/vendor_lib/rspec/mocks/framework.rb +36 -0
- data/vendor_lib/rspec/mocks/instance_method_stasher.rb +112 -0
- data/vendor_lib/rspec/mocks/matchers/have_received.rb +99 -0
- data/vendor_lib/rspec/mocks/matchers/receive.rb +112 -0
- data/vendor_lib/rspec/mocks/matchers/receive_messages.rb +72 -0
- data/vendor_lib/rspec/mocks/message_expectation.rb +643 -0
- data/vendor_lib/rspec/mocks/method_double.rb +209 -0
- data/vendor_lib/rspec/mocks/method_reference.rb +95 -0
- data/vendor_lib/rspec/mocks/mock.rb +7 -0
- data/vendor_lib/rspec/mocks/mutate_const.rb +406 -0
- data/vendor_lib/rspec/mocks/object_reference.rb +90 -0
- data/vendor_lib/rspec/mocks/order_group.rb +82 -0
- data/vendor_lib/rspec/mocks/proxy.rb +269 -0
- data/vendor_lib/rspec/mocks/proxy_for_nil.rb +37 -0
- data/vendor_lib/rspec/mocks/space.rb +95 -0
- data/vendor_lib/rspec/mocks/standalone.rb +3 -0
- data/vendor_lib/rspec/mocks/stub_chain.rb +51 -0
- data/vendor_lib/rspec/mocks/syntax.rb +374 -0
- data/vendor_lib/rspec/mocks/targets.rb +90 -0
- data/vendor_lib/rspec/mocks/test_double.rb +109 -0
- data/vendor_lib/rspec/mocks/verifying_double.rb +77 -0
- data/vendor_lib/rspec/mocks/verifying_message_expecation.rb +60 -0
- data/vendor_lib/rspec/mocks/verifying_proxy.rb +151 -0
- data/vendor_lib/rspec/mocks/version.rb +7 -0
- data/vendor_lib/rspec/support.rb +6 -0
- data/vendor_lib/rspec/support/caller_filter.rb +56 -0
- data/vendor_lib/rspec/support/spec.rb +14 -0
- data/vendor_lib/rspec/support/spec/deprecation_helpers.rb +29 -0
- data/vendor_lib/rspec/support/spec/in_sub_process.rb +40 -0
- data/vendor_lib/rspec/support/spec/stderr_splitter.rb +50 -0
- data/vendor_lib/rspec/support/version.rb +7 -0
- data/vendor_lib/rspec/support/warnings.rb +41 -0
- data/vendor_lib/rspec/version.rb +5 -0
- 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
|
data/spec/mock_spec.rb
ADDED
|
@@ -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,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"
|
data/vendor_lib/rspec.rb
ADDED
|
@@ -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
|