cucumber 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,12 @@
1
+ == 0.2.2 2009-03-25
2
+
3
+ This release includes some minor changes to make Cucumber work with pure Java. Cucumber
4
+ has already worked with Java for a while (using JRuby and step definitions in Ruby),
5
+ but now you can write step definitions in pure Java!
6
+
7
+ Check out the Cucumber Java project for more details:
8
+ http://github.com/aslakhellesoy/cucumber_java/tree/master
9
+
1
10
  == 0.2.1 2009-03-25
2
11
 
3
12
  This release fixes a few minor bugs and adds a couple of new features.
@@ -124,15 +124,7 @@ examples/java/features/step_definitons/hello_steps.rb
124
124
  examples/java/features/step_definitons/tree_steps.rb
125
125
  examples/java/features/tree.feature
126
126
  examples/java/src/cucumber/demo/Hello.java
127
- examples/jbehave/README.textile
128
- examples/jbehave/features/support/env.rb
129
- examples/jbehave/features/trading.feature
130
- examples/jbehave/pom.xml
131
- examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
132
- examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Stock.java
133
- examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Trader.java
134
- examples/jbehave/src/main/java/cukes/jbehave/examples/trader/persistence/TraderPersister.java
135
- examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java
127
+ examples/pure_java/README.textile
136
128
  examples/selenium/Rakefile
137
129
  examples/selenium/features/search.feature
138
130
  examples/selenium/features/step_definitons/search_steps.rb
@@ -255,7 +247,6 @@ lib/cucumber/formatter/rerun.rb
255
247
  lib/cucumber/formatter/unicode.rb
256
248
  lib/cucumber/formatter/usage.rb
257
249
  lib/cucumber/formatters/unicode.rb
258
- lib/cucumber/jbehave.rb
259
250
  lib/cucumber/languages.yml
260
251
  lib/cucumber/parser.rb
261
252
  lib/cucumber/parser/basic.rb
@@ -0,0 +1,5 @@
1
+ h1. Cucumber with pure Java
2
+
3
+ You can use Cucumber with step definitions in pure Java.
4
+
5
+ See http://github.com/aslakhellesoy/cucumber_java/tree/master
@@ -20,7 +20,7 @@
20
20
  #
21
21
  class Exception
22
22
  CUCUMBER_FILTER_PATTERNS = [
23
- /vendor\/rails|lib\/cucumber|lib\/rspec|gems\//
23
+ /vendor\/rails|lib\/cucumber|bin\/cucumber:|lib\/rspec|gems\//
24
24
  ]
25
25
 
26
26
  INSTANCE_EXEC_OFFSET = (Cucumber::RUBY_1_9 || Cucumber::JRUBY) ? -3 : -4
@@ -2,7 +2,7 @@ module Cucumber #:nodoc:
2
2
  class VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 1
5
+ TINY = 2
6
6
  PATCH = nil # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Aslak Helles\xC3\xB8y"
@@ -211,15 +211,7 @@ files:
211
211
  - examples/java/features/step_definitons/tree_steps.rb
212
212
  - examples/java/features/tree.feature
213
213
  - examples/java/src/cucumber/demo/Hello.java
214
- - examples/jbehave/README.textile
215
- - examples/jbehave/features/support/env.rb
216
- - examples/jbehave/features/trading.feature
217
- - examples/jbehave/pom.xml
218
- - examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
219
- - examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Stock.java
220
- - examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Trader.java
221
- - examples/jbehave/src/main/java/cukes/jbehave/examples/trader/persistence/TraderPersister.java
222
- - examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java
214
+ - examples/pure_java/README.textile
223
215
  - examples/selenium/Rakefile
224
216
  - examples/selenium/features/search.feature
225
217
  - examples/selenium/features/step_definitons/search_steps.rb
@@ -342,7 +334,6 @@ files:
342
334
  - lib/cucumber/formatter/unicode.rb
343
335
  - lib/cucumber/formatter/usage.rb
344
336
  - lib/cucumber/formatters/unicode.rb
345
- - lib/cucumber/jbehave.rb
346
337
  - lib/cucumber/languages.yml
347
338
  - lib/cucumber/parser.rb
348
339
  - lib/cucumber/parser/basic.rb
@@ -1,20 +0,0 @@
1
- h1. Cucumber and JBehave
2
-
3
- Look ma - no Ruby!
4
-
5
- h2. Running the example
6
-
7
- First, compile the java code (and JBehave steps)
8
-
9
- <code>mvn compile jar:jar</code>
10
-
11
- Second, set your CLASSPATH
12
- <code>export CLASSPATH=~/.m2/repository/cucumber/cucumber-support/0.2/cucumber-support-0.2.jar:~/.m2/repository/org/jbehave/jbehave-core/2.1.1/jbehave-core-2.1.1.jar:~/.m2/repository/org/hamcrest/hamcrest-all/1.1/hamcrest-all-1.1.jar:~/.m2/repository/junit/junit/4.4/junit-4.4.jar</code>
13
-
14
- Third, run Cucumber:
15
-
16
- <code>jruby -S cucumber features</code>
17
-
18
- Or if you got the source with Git:
19
-
20
- <code>jruby ../../bin/cucumber features</code>
@@ -1,7 +0,0 @@
1
- require 'cucumber/jbehave'
2
-
3
- project_code = File.expand_path(File.dirname(__FILE__) + '/../../target/jbehave-example-0.2-SNAPSHOT.jar')
4
- require project_code
5
-
6
- import 'cukes.jbehave.examples.trader.scenarios.TraderSteps'
7
- JBehave(TraderSteps.new)
@@ -1,28 +0,0 @@
1
- Feature: Trading
2
- In order to avoid lost trades
3
- Traders should be alerted about stocks
4
-
5
- Scenario: Status alert can be activated
6
- Given a stock of prices 0.5,1.0 and a threshold of 10.0
7
- When the stock is traded at 5.0
8
- Then the alert status should be OFF
9
- When the stock is traded at 11.0
10
- Then the alert status should be ON
11
-
12
- Scenario: Status alert is never activated
13
- Given a stock of prices 0.5,1.0 and a threshold of 15.0
14
- When the stock is traded at 5.0
15
- Then the alert status should be OFF
16
- When the stock is traded at 11.0
17
- Then the alert status should be OFF
18
-
19
- Scenario: Trader sells all stocks
20
- # Given the following table
21
- # | a | b |
22
- # | 1 | 2 |
23
- # | 3 | 4 |
24
- Given a trader of name Mauro
25
- Given a stock of prices 0.5,1.0 and a threshold of 1.5
26
- When the stock is traded at 2.0
27
- Then the trader sells all stocks
28
- And the trader gets a bonus
@@ -1,53 +0,0 @@
1
- <project xmlns="http://maven.apache.org/POM/4.0.0"
2
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4
- http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
- <modelVersion>4.0.0</modelVersion>
6
- <groupId>cukes</groupId>
7
- <artifactId>jbehave-example</artifactId>
8
- <packaging>jar</packaging>
9
- <version>0.2-SNAPSHOT</version>
10
- <name>Cucumber JBehave Example</name>
11
- <url>http://cukes.info/</url>
12
-
13
- <repositories>
14
- <repository>
15
- <id>codehaus</id>
16
- <url>http://repository.codehaus.org</url>
17
- </repository>
18
- </repositories>
19
-
20
- <dependencies>
21
- <dependency>
22
- <groupId>cucumber</groupId>
23
- <artifactId>cucumber-support</artifactId>
24
- <version>0.2</version>
25
- </dependency>
26
- <dependency>
27
- <groupId>org.jbehave</groupId>
28
- <artifactId>jbehave-core</artifactId>
29
- <version>2.1.1</version>
30
- </dependency>
31
- <dependency>
32
- <groupId>junit</groupId>
33
- <artifactId>junit</artifactId>
34
- <version>4.4</version>
35
- </dependency>
36
- </dependencies>
37
-
38
- <build>
39
- <pluginManagement>
40
- <plugins>
41
- <plugin>
42
- <groupId>org.apache.maven.plugins</groupId>
43
- <artifactId>maven-compiler-plugin</artifactId>
44
- <version>2.0.2</version>
45
- <configuration>
46
- <source>1.5</source>
47
- <target>1.5</target>
48
- </configuration>
49
- </plugin>
50
- </plugins>
51
- </pluginManagement>
52
- </build>
53
- </project>
@@ -1,32 +0,0 @@
1
- package cukes.jbehave.examples.trader.converters;
2
-
3
- import java.lang.reflect.Type;
4
-
5
- import cukes.jbehave.examples.trader.model.Trader;
6
- import cukes.jbehave.examples.trader.persistence.TraderPersister;
7
- import org.jbehave.scenario.steps.ParameterConverters.InvalidParameterException;
8
- import org.jbehave.scenario.steps.ParameterConverters.ParameterConverter;
9
-
10
- public class TraderConverter implements ParameterConverter {
11
- private TraderPersister persister;
12
-
13
- public TraderConverter(TraderPersister persister) {
14
- this.persister = persister;
15
- }
16
-
17
- public boolean accept(Type type) {
18
- if (type instanceof Class) {
19
- return Trader.class.isAssignableFrom((Class<?>) type);
20
- }
21
- return false;
22
- }
23
-
24
- public Object convertValue(String value, Type type) {
25
- Trader trader = persister.retrieveTrader(value);
26
- if (trader == null) {
27
- throw new InvalidParameterException("Trader not found for name " + value, null);
28
- }
29
- return trader;
30
- }
31
-
32
- }
@@ -1,42 +0,0 @@
1
- package cukes.jbehave.examples.trader.model;
2
-
3
- import static cukes.jbehave.examples.trader.model.Stock.AlertStatus.OFF;
4
- import static cukes.jbehave.examples.trader.model.Stock.AlertStatus.ON;
5
-
6
- import java.util.List;
7
-
8
- public class Stock {
9
-
10
- public enum AlertStatus {
11
- ON, OFF
12
- };
13
-
14
- private List<Double> prices;
15
- private double alertPrice;
16
- private AlertStatus status = OFF;
17
-
18
- public Stock(List<Double> prices, double alertPrice) {
19
- this.prices = prices;
20
- this.alertPrice = alertPrice;
21
- }
22
-
23
- public List<Double> getPrices() {
24
- return prices;
25
- }
26
-
27
- public void tradeAt(double price) {
28
- this.prices.add(price);
29
- if (price > alertPrice) {
30
- status = ON;
31
- }
32
- }
33
-
34
- public void resetAlert() {
35
- status = OFF;
36
- }
37
-
38
- public AlertStatus getStatus() {
39
- return status;
40
- }
41
-
42
- }
@@ -1,29 +0,0 @@
1
- package cukes.jbehave.examples.trader.model;
2
-
3
- import static java.util.Arrays.asList;
4
-
5
- import java.util.List;
6
-
7
- public class Trader {
8
-
9
- private final String name;
10
- private List<Stock> stocks;
11
-
12
- public Trader(String name, List<Stock> stocks) {
13
- this.name = name;
14
- this.stocks = stocks;
15
- }
16
-
17
- public String getName() {
18
- return name;
19
- }
20
-
21
- public List<Stock> getStocks() {
22
- return stocks;
23
- }
24
-
25
- public void sellAllStocks(){
26
- this.stocks = asList(new Stock[]{});
27
- }
28
-
29
- }
@@ -1,22 +0,0 @@
1
- package cukes.jbehave.examples.trader.persistence;
2
-
3
- import cukes.jbehave.examples.trader.model.Trader;
4
-
5
- public class TraderPersister {
6
-
7
- private Trader[] traders;
8
-
9
- public TraderPersister(Trader... traders) {
10
- this.traders = traders;
11
- }
12
-
13
- public Trader retrieveTrader(String name) {
14
- for (Trader trader : traders) {
15
- if (trader.getName().equals(name)) {
16
- return trader;
17
- }
18
- }
19
- return null;
20
- }
21
-
22
- }
@@ -1,70 +0,0 @@
1
- package cukes.jbehave.examples.trader.scenarios;
2
-
3
- import static java.util.Arrays.asList;
4
- import static org.hamcrest.CoreMatchers.equalTo;
5
- import static org.jbehave.Ensure.ensureThat;
6
-
7
- import java.util.List;
8
-
9
- import cukes.jbehave.examples.trader.converters.TraderConverter;
10
- import cukes.jbehave.examples.trader.model.Stock;
11
- import cukes.jbehave.examples.trader.model.Trader;
12
- import cukes.jbehave.examples.trader.persistence.TraderPersister;
13
- import org.jbehave.scenario.annotations.Given;
14
- import org.jbehave.scenario.annotations.Then;
15
- import org.jbehave.scenario.annotations.When;
16
- import org.jbehave.scenario.parser.PrefixCapturingPatternBuilder;
17
- import org.jbehave.scenario.steps.ParameterConverters;
18
- import org.jbehave.scenario.steps.SilentStepMonitor;
19
- import org.jbehave.scenario.steps.Steps;
20
- import org.jbehave.scenario.steps.StepsConfiguration;
21
- import cucumber.ast.Table;
22
-
23
- public class TraderSteps extends Steps {
24
-
25
- private static final StepsConfiguration configuration = new StepsConfiguration();
26
- private Stock stock;
27
- private Trader trader;
28
-
29
- public TraderSteps() {
30
- super(configuration);
31
- configuration.useParameterConverters(new ParameterConverters(
32
- new SilentStepMonitor(), new TraderConverter(mockTradePersister())));
33
- configuration.usePatternBuilder(new PrefixCapturingPatternBuilder("%"));
34
- }
35
-
36
- private TraderPersister mockTradePersister() {
37
- return new TraderPersister(new Trader("Mauro", asList(new Stock(asList(1.0d), 10.d))));
38
- }
39
-
40
- @Given("a trader of name %trader")
41
- public void aTrader(Trader trader) {
42
- this.trader = trader;
43
- }
44
-
45
- @Given("a stock of prices %prices and a threshold of %threshold")
46
- public void aStockOfPrice(List<Double> prices, double threshold) {
47
- stock = new Stock(prices, threshold);
48
- }
49
-
50
- @Given("the following table")
51
- public void theFollowingTable(Table table) {
52
- System.out.println("My table:" + table);
53
- }
54
-
55
- @When("the stock is traded at %price")
56
- public void theStockIsTradedAt(double price) {
57
- stock.tradeAt(price);
58
- }
59
-
60
- @Then("the alert status should be %status")
61
- public void theAlertStatusShouldBe(String status) {
62
- ensureThat(stock.getStatus().name(), equalTo(status));
63
- }
64
-
65
- @Then("the trader sells all stocks")
66
- public void theTraderSellsAllStocks() {
67
- trader.sellAllStocks();
68
- ensureThat(trader.getStocks().size(), equalTo(0));
69
- }
70
- }
@@ -1,98 +0,0 @@
1
- if defined?(JRUBY_VERSION)
2
- require 'java'
3
-
4
- Exception::CUCUMBER_FILTER_PATTERNS.unshift(/^org\/jruby|^org\/jbehave|^org\/junit|^java\/|^sun\/|^\$_dot_dot_/)
5
-
6
- module Cucumber
7
- module JBehave
8
- # Register an instance of org.jbehave.scenario.steps.Steps
9
- def JBehave(jbehave_steps)
10
- jbehave_steps.getSteps.each do |jbehave_candidate_step|
11
- step_definitions << JBehaveStepDefinition.new(jbehave_steps, jbehave_candidate_step)
12
- end
13
- end
14
-
15
- # Open up so we can get the pattern....
16
- JBehaveCandidateStep = org.jbehave.scenario.steps.CandidateStep
17
- class JBehaveCandidateStep
18
- field_reader :pattern
19
- end
20
-
21
- # Adapter for JBehave org.jbehave.scenario.steps.CandidateStep
22
- class JBehaveStepDefinition
23
- def initialize(jbehave_steps, jbehave_candidate_step)
24
- @jbehave_steps = jbehave_steps
25
- @jbehave_candidate_step = jbehave_candidate_step
26
- @regexp = Regexp.new(jbehave_candidate_step.pattern.pattern)
27
- end
28
-
29
- def step_match(name_to_match, name_to_report)
30
- raise "FIXME"
31
- if(match = name_to_match.match(@regexp))
32
- StepMatch.new(self, name_to_match, name_to_report, match.captures)
33
- else
34
- nil
35
- end
36
- end
37
-
38
- def file_colon_line
39
- @jbehave_steps.java_class.name
40
- end
41
-
42
- def format_args(step_name, format)
43
- step_name.gzub(@regexp, format)
44
- end
45
-
46
- def invoke(world, args, step_name)
47
- step = @jbehave_candidate_step.createFrom("Given #{step_name}") # JBehave doesn't care about the adverb.
48
- step = @jbehave_candidate_step.__send__(:createStep, "Given #{step_name}", args) # JBehave doesn't care about the adverb.
49
-
50
- result = step.perform
51
- result.describeTo(Reporter)
52
- end
53
- end
54
-
55
- # Implements the org.jbehave.scenario.reporters.ScenarioReporter methods
56
- class Reporter
57
- def self.successful(step_text)
58
- # noop
59
- end
60
-
61
- def self.failed(step, java_exception)
62
- raise java_exception_to_ruby_exception(java_exception)
63
- end
64
-
65
- private
66
-
67
- def self.java_exception_to_ruby_exception(java_exception)
68
- # OK, this is a little funky - JRuby weirdness
69
- ruby_exception = org.jruby.NativeException.new(JRuby.runtime, JBehaveException, java_exception)
70
- ruby_exception.set_backtrace([]) # work around backtrace bug in jruby
71
- exception = JBehaveException.new("#{java_exception.getClass.getName}: #{java_exception.getMessage}")
72
- bt = ruby_exception.backtrace
73
- Exception.cucumber_strip_backtrace!(bt, nil, nil)
74
- exception.set_backtrace(bt)
75
- exception
76
- end
77
- end
78
-
79
- class JBehaveException < Exception
80
- end
81
-
82
- def self.snippet_text(step_keyword, step_name)
83
- camel = step_name.gsub(/(\s.)/) {$1.upcase.strip}
84
- method = camel[0..0].downcase + camel[1..-1]
85
- snippet = %{ @#{step_keyword}("#{step_name}")
86
- public void #{method}() {
87
- throw new RuntimeException("pending");
88
- }}
89
- end
90
- end
91
- end
92
-
93
- self.extend(Cucumber::JBehave)
94
- self.snippet_generator = Cucumber::JBehave
95
- else
96
- STDERR.puts "ERROR: cucumber/jbehave only works with JRuby"
97
- Kernel.exit(1)
98
- end