-
-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shared state between tests #275
Comments
Here's a simplified example: describe "Description" do
evaluate <<-ruby, "Test 1" do
def m1
123
end
ruby
m1.should == 123
end
it "Test 2" do
def m2
456
end
m2.should == 456
end
it "Test 3" do
lambda { self.m1 }.should raise_error(NoMethodError)
lambda { self.m2 }.should_not raise_error(NoMethodError)
end
end It passes because
|
The environment is different per-file, isn't it? ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
[\ | 0% | 00:00:00] 0F 0E#<Object:0x00560dda563770>
[\ | ==================50% | 00:00:00] 0F 0E#<Object:0x00560dda641fe8>
[- | ==================100%================== | 00:00:00] 0F 0E So, maybe an Opal bug? |
I was testing on a single file 😄
Yes, you are right, Opal runs all specs in the context of single object, this static object. Thanks for pointing that env is different per file! |
There are some weird conflicts between tests that define methods explicitly.
it
are evaluated on the context of MSpec's@env
b
.b
to be undefined.rescue_spec
runs beforereturn_spec
everything is fine.return_spec
runs beforerescue_spec
this test fails.Should we replace all occurrences of explicitly defined methods to
evaluate("def ...", &block)
?The text was updated successfully, but these errors were encountered: