Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Adding a way to load stuff into world #166

Merged
merged 1 commit into from

2 participants

David Kowis Aslak Hellesøy
David Kowis
Collaborator

In my specific example, RSpec matchers

World do
extend RSpec::Matchers
end

It's loaded in when the scripts are parsed into a Set, then applied each time the world is built.

Doing a pull request for a second set of eyes.

David Kowis dkowis Adding a way to load stuff into world
In my specific example, RSpec matchers
69dbe8e
Aslak Hellesøy

LGTM

Aslak Hellesøy aslakhellesoy merged commit 69dbe8e into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 23, 2012
  1. David Kowis

    Adding a way to load stuff into world

    dkowis authored
    In my specific example, RSpec matchers
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 5 deletions.
  1. +7 −5 jruby/src/main/java/cucumber/runtime/jruby/JRubyBackend.java
12 jruby/src/main/java/cucumber/runtime/jruby/JRubyBackend.java
View
@@ -15,10 +15,7 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
-import java.util.List;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
+import java.util.*;
public class JRubyBackend implements Backend {
private static final String DSL = "/cucumber/runtime/jruby/dsl.rb";
@@ -27,6 +24,7 @@
private Glue glue;
private ResourceLoader resourceLoader;
private UnreportedStepExecutor unreportedStepExecutor;
+ private final Set<JRubyWorldBlock> worldBlocks = new HashSet<JRubyWorldBlock>();
public JRubyBackend(ResourceLoader resourceLoader) throws UnsupportedEncodingException {
this.resourceLoader = resourceLoader;
@@ -68,6 +66,10 @@ public void setUnreportedStepExecutor(UnreportedStepExecutor executor) {
@Override
public void buildWorld() {
jruby.put("$world", new Object());
+
+ for (JRubyWorldBlock block : worldBlocks) {
+ block.execute();
+ }
}
private void runScriptlet(Resource resource) {
@@ -113,6 +115,6 @@ public void addAfterHook(RubyObject body) {
}
public void addWorldBlock(RubyObject body) {
- new JRubyWorldBlock(body).execute();
+ worldBlocks.add(new JRubyWorldBlock(body));
}
}
Something went wrong with that request. Please try again.