kosmas58-cucumber 0.2.0.1 → 0.2.2.1
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.
- data/History.txt +32 -1
- data/Manifest.txt +4 -11
- data/examples/dos_line_endings/features/dos_line_endings.feature +9 -9
- data/examples/pure_java/README.textile +5 -0
- data/examples/self_test/features/tons_of_cukes.feature +52 -0
- data/examples/sinatra/features/support/env.rb +6 -2
- data/examples/tickets/features/248.feature +11 -0
- data/examples/tickets/features/step_definitons/248_steps.rb +15 -0
- data/features/cucumber_cli.feature +1 -1
- data/features/custom_formatter.feature +2 -2
- data/features/usage.feature +108 -0
- data/gem_tasks/features.rake +18 -6
- data/lib/autotest/cucumber_mixin.rb +1 -1
- data/lib/cucumber/ast/feature.rb +1 -1
- data/lib/cucumber/ast/features.rb +6 -0
- data/lib/cucumber/ast/step.rb +4 -0
- data/lib/cucumber/ast/step_invocation.rb +10 -2
- data/lib/cucumber/ast/table.rb +4 -0
- data/lib/cucumber/cli/configuration.rb +11 -14
- data/lib/cucumber/cli/main.rb +14 -21
- data/lib/cucumber/core_ext/exception.rb +1 -1
- data/lib/cucumber/formatter.rb +1 -1
- data/lib/cucumber/formatter/html.rb +47 -8
- data/lib/cucumber/formatter/pretty.rb +1 -2
- data/lib/cucumber/formatter/rerun.rb +8 -0
- data/lib/cucumber/formatter/usage.rb +69 -0
- data/lib/cucumber/languages.yml +7 -2
- data/lib/cucumber/rails/world.rb +22 -21
- data/lib/cucumber/step_definition.rb +65 -54
- data/lib/cucumber/step_match.rb +10 -2
- data/lib/cucumber/step_mother.rb +4 -10
- data/lib/cucumber/version.rb +1 -1
- data/rails_generators/cucumber/templates/env.rb +2 -0
- data/rails_generators/feature/templates/steps.erb +1 -1
- data/spec/cucumber/ast/feature_spec.rb +2 -1
- data/spec/cucumber/cli/configuration_spec.rb +18 -6
- data/spec/cucumber/cli/main_spec.rb +1 -14
- data/spec/cucumber/parser/feature_parser_spec.rb +15 -15
- data/spec/cucumber/step_definition_spec.rb +21 -9
- data/spec/cucumber/step_mother_spec.rb +17 -1
- metadata +8 -13
- data/examples/jbehave/README.textile +0 -20
- data/examples/jbehave/features/support/env.rb +0 -7
- data/examples/jbehave/features/trading.feature +0 -28
- data/examples/jbehave/pom.xml +0 -53
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java +0 -32
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Stock.java +0 -42
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Trader.java +0 -29
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/persistence/TraderPersister.java +0 -22
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java +0 -70
- data/gem_tasks/jar.rake +0 -67
- data/lib/cucumber/jbehave.rb +0 -97
@@ -58,15 +58,7 @@ module Cucumber
|
|
58
58
|
step_match("Outside").invoke(@world, nil)
|
59
59
|
end.should raise_error(Pending, "Do me!")
|
60
60
|
end
|
61
|
-
|
62
|
-
it "should have a #to_s suitable for automcompletion" do
|
63
|
-
stepdef = Given /Hello (.*)/ do
|
64
|
-
end
|
65
|
-
|
66
|
-
stepdef.to_s.should == '/Hello (.*)/ # spec/cucumber/step_definition_spec.rb:63'
|
67
|
-
stepdef.to_s(2).should == '/Hello (.*)/ # spec/cucumber/step_definition_spec.rb:63'
|
68
|
-
end
|
69
|
-
|
61
|
+
|
70
62
|
it "should allow announce" do
|
71
63
|
v = mock('visitor')
|
72
64
|
v.should_receive(:announce).with('wasup')
|
@@ -77,5 +69,25 @@ module Cucumber
|
|
77
69
|
end
|
78
70
|
step_match("Loud").invoke(world, nil)
|
79
71
|
end
|
72
|
+
|
73
|
+
def unindented(s)
|
74
|
+
s.split("\n")[1..-2].join("\n").indent(-8)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should recognise quotes in name and make according regexp" do
|
78
|
+
StepDefinition.snippet_text('Given', 'A "first" arg').should == unindented(%{
|
79
|
+
Given /^A "([^\\"]*)" arg$/ do |arg1|
|
80
|
+
pending
|
81
|
+
end
|
82
|
+
})
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should not use quote group when there are no quotes" do
|
86
|
+
StepDefinition.snippet_text('Given', 'A first arg').should == unindented(%{
|
87
|
+
Given /^A first arg$/ do
|
88
|
+
pending
|
89
|
+
end
|
90
|
+
})
|
91
|
+
end
|
80
92
|
end
|
81
93
|
end
|
@@ -19,7 +19,7 @@ module Cucumber
|
|
19
19
|
format.should == "it [snows] in [april]"
|
20
20
|
end
|
21
21
|
|
22
|
-
it "should raise Ambiguous error when multiple step definitions match" do
|
22
|
+
it "should raise Ambiguous error with guess hint when multiple step definitions match" do
|
23
23
|
@step_mother.Given(/Three (.*) mice/) {|disability|}
|
24
24
|
@step_mother.Given(/Three blind (.*)/) {|animal|}
|
25
25
|
|
@@ -30,6 +30,22 @@ module Cucumber
|
|
30
30
|
spec/cucumber/step_mother_spec.rb:23:in `/Three (.*) mice/'
|
31
31
|
spec/cucumber/step_mother_spec.rb:24:in `/Three blind (.*)/'
|
32
32
|
|
33
|
+
You can run again with --guess to make Cucumber be more smart about it
|
34
|
+
})
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should not show --guess hint when --guess is used" do
|
38
|
+
@step_mother.options = {:guess => true}
|
39
|
+
@step_mother.Given(/Three (.*) mice/) {|disability|}
|
40
|
+
@step_mother.Given(/Three cute (.*)/) {|animal|}
|
41
|
+
|
42
|
+
lambda do
|
43
|
+
@step_mother.step_match("Three cute mice")
|
44
|
+
end.should raise_error(Ambiguous, %{Ambiguous match of "Three cute mice":
|
45
|
+
|
46
|
+
spec/cucumber/step_mother_spec.rb:39:in `/Three (.*) mice/'
|
47
|
+
spec/cucumber/step_mother_spec.rb:40:in `/Three cute (.*)/'
|
48
|
+
|
33
49
|
})
|
34
50
|
end
|
35
51
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kosmas58-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Aslak Helles\xC3\xB8y"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-26 00:00:00 -07:00
|
13
13
|
default_executable: cucumber
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -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/
|
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
|
@@ -245,6 +237,7 @@ files:
|
|
245
237
|
- examples/self_test/features/step_definitions/sample_steps.rb
|
246
238
|
- examples/self_test/features/support/env.rb
|
247
239
|
- examples/self_test/features/support/tag_count_formatter.rb
|
240
|
+
- examples/self_test/features/tons_of_cukes.feature
|
248
241
|
- examples/sinatra/Rakefile
|
249
242
|
- examples/sinatra/app.rb
|
250
243
|
- examples/sinatra/features/add.feature
|
@@ -264,9 +257,11 @@ files:
|
|
264
257
|
- examples/tickets/features/180.feature
|
265
258
|
- examples/tickets/features/236.feature
|
266
259
|
- examples/tickets/features/241.feature
|
260
|
+
- examples/tickets/features/248.feature
|
267
261
|
- examples/tickets/features/lib/eatting_machine.rb
|
268
262
|
- examples/tickets/features/lib/pantry.rb
|
269
263
|
- examples/tickets/features/scenario_outline.feature
|
264
|
+
- examples/tickets/features/step_definitons/248_steps.rb
|
270
265
|
- examples/tickets/features/step_definitons/scenario_outline_steps.rb
|
271
266
|
- examples/tickets/features/step_definitons/tickets_steps.rb
|
272
267
|
- examples/tickets/features/tickets.feature
|
@@ -284,13 +279,13 @@ files:
|
|
284
279
|
- features/step_definitions/cucumber_steps.rb
|
285
280
|
- features/step_definitions/extra_steps.rb
|
286
281
|
- features/support/env.rb
|
282
|
+
- features/usage.feature
|
287
283
|
- gem_tasks/deployment.rake
|
288
284
|
- gem_tasks/environment.rake
|
289
285
|
- gem_tasks/features.rake
|
290
286
|
- gem_tasks/fix_cr_lf.rake
|
291
287
|
- gem_tasks/flog.rake
|
292
288
|
- gem_tasks/gemspec.rake
|
293
|
-
- gem_tasks/jar.rake
|
294
289
|
- gem_tasks/rspec.rake
|
295
290
|
- gem_tasks/yard.rake
|
296
291
|
- lib/autotest/cucumber.rb
|
@@ -337,8 +332,8 @@ files:
|
|
337
332
|
- lib/cucumber/formatter/progress.rb
|
338
333
|
- lib/cucumber/formatter/rerun.rb
|
339
334
|
- lib/cucumber/formatter/unicode.rb
|
335
|
+
- lib/cucumber/formatter/usage.rb
|
340
336
|
- lib/cucumber/formatters/unicode.rb
|
341
|
-
- lib/cucumber/jbehave.rb
|
342
337
|
- lib/cucumber/languages.yml
|
343
338
|
- lib/cucumber/parser.rb
|
344
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,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
|
data/examples/jbehave/pom.xml
DELETED
@@ -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>
|
data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
DELETED
@@ -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
|
-
}
|
data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/persistence/TraderPersister.java
DELETED
@@ -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
|
-
}
|
data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java
DELETED
@@ -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
|
-
}
|