cucumber 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +19 -0
- data/Manifest.txt +5 -1
- 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/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 +2 -13
- data/lib/cucumber/ast/step_invocation.rb +11 -3
- 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/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/jbehave.rb +1 -0
- 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 +1 -8
- 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/ast/step_collection_spec.rb +8 -0
- data/spec/cucumber/cli/configuration_spec.rb +18 -6
- data/spec/cucumber/cli/main_spec.rb +1 -13
- data/spec/cucumber/parser/feature_parser_spec.rb +15 -15
- data/spec/cucumber/step_definition_spec.rb +21 -9
- metadata +7 -3
- data/gem_tasks/jar.rake +0 -67
data/lib/cucumber/step_match.rb
CHANGED
@@ -10,10 +10,10 @@ module Cucumber
|
|
10
10
|
def invoke(world, multiline_arg)
|
11
11
|
all_args = @args.dup
|
12
12
|
all_args << multiline_arg if multiline_arg
|
13
|
-
@step_definition.invoke(world, all_args
|
13
|
+
@step_definition.invoke(world, all_args)
|
14
14
|
end
|
15
15
|
|
16
|
-
def format_args(format)
|
16
|
+
def format_args(format = lambda{|a| a})
|
17
17
|
@formatted_step_name || @step_definition.format_args(@step_name, format)
|
18
18
|
end
|
19
19
|
|
@@ -24,6 +24,10 @@ module Cucumber
|
|
24
24
|
def backtrace_line
|
25
25
|
@step_definition.backtrace_line
|
26
26
|
end
|
27
|
+
|
28
|
+
def text_length
|
29
|
+
@step_definition.text_length
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
class NoStepMatch
|
@@ -45,5 +49,9 @@ module Cucumber
|
|
45
49
|
def backtrace_line
|
46
50
|
@step.backtrace_line
|
47
51
|
end
|
52
|
+
|
53
|
+
def text_length
|
54
|
+
@step.text_length
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
data/lib/cucumber/step_mother.rb
CHANGED
@@ -101,7 +101,7 @@ module Cucumber
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def After(&proc)
|
104
|
-
(@after_procs ||= [])
|
104
|
+
(@after_procs ||= []).unshift(proc)
|
105
105
|
end
|
106
106
|
|
107
107
|
# Registers a World proc. You can call this method as many times as you
|
@@ -141,13 +141,6 @@ module Cucumber
|
|
141
141
|
def snippet_text(step_keyword, step_name)
|
142
142
|
@snippet_generator.snippet_text(step_keyword, step_name)
|
143
143
|
end
|
144
|
-
|
145
|
-
def print_step_definitions(out)
|
146
|
-
step_definitions.each do |step_definition|
|
147
|
-
indent = max_step_definition_length - step_definition.text_length
|
148
|
-
out.puts(step_definition.to_s(indent))
|
149
|
-
end
|
150
|
-
end
|
151
144
|
|
152
145
|
def before_and_after(scenario, skip=false)
|
153
146
|
unless current_world || skip
|
data/lib/cucumber/version.rb
CHANGED
@@ -4,6 +4,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
|
4
4
|
require 'cucumber/rails/world'
|
5
5
|
require 'cucumber/formatters/unicode' # Comment out this line if you don't want Cucumber Unicode support
|
6
6
|
Cucumber::Rails.use_transactional_fixtures
|
7
|
+
Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own error handling
|
8
|
+
# (e.g. rescue_action_in_public / rescue_responses / rescue_from)
|
7
9
|
|
8
10
|
require 'webrat'
|
9
11
|
|
@@ -10,7 +10,7 @@ When /^I delete the (\d+)(?:st|nd|rd|th) <%= singular_name %>$/ do |pos|
|
|
10
10
|
end
|
11
11
|
|
12
12
|
Then /^I should see the following <%= plural_name %>:$/ do |<%= plural_name %>|
|
13
|
-
<%= plural_name %>.
|
13
|
+
<%= plural_name %>.rows.each_with_index do |row, i|
|
14
14
|
row.each_with_index do |cell, j|
|
15
15
|
response.should have_selector("table > tr:nth-child(#{i+2}) > td:nth-child(#{j+1})") { |td|
|
16
16
|
td.inner_text.should == cell
|
@@ -9,7 +9,8 @@ module Cucumber
|
|
9
9
|
it "should convert to sexp" do
|
10
10
|
feature = create_feature(Object.new)
|
11
11
|
feature.to_sexp.should ==
|
12
|
-
[:feature,
|
12
|
+
[:feature,
|
13
|
+
"features/pretty_printing.feature",
|
13
14
|
"Pretty printing",
|
14
15
|
[:comment, "# My feature comment\n"],
|
15
16
|
[:tag, "one"],
|
@@ -3,6 +3,14 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
3
3
|
module Cucumber
|
4
4
|
module Ast
|
5
5
|
describe StepCollection do
|
6
|
+
it "should convert And to Given in snippets" do
|
7
|
+
c = StepCollection.new([
|
8
|
+
Step.new(1, 'Given', 'cukes'),
|
9
|
+
Step.new(2, 'And', 'turnips')
|
10
|
+
])
|
11
|
+
actual_keywords = c.step_invocations.map{|i| i.actual_keyword}
|
12
|
+
actual_keywords.should == %w{Given Given}
|
13
|
+
end
|
6
14
|
end
|
7
15
|
end
|
8
16
|
end
|
@@ -18,7 +18,7 @@ module Cli
|
|
18
18
|
it "should require files in support paths first" do
|
19
19
|
File.stub!(:directory?).and_return(true)
|
20
20
|
Dir.stub!(:[]).and_return(["/features/step_definitions/foo.rb","/features/support/bar.rb"])
|
21
|
-
|
21
|
+
|
22
22
|
config = Configuration.new(StringIO.new)
|
23
23
|
config.parse!(%w{--require /features})
|
24
24
|
|
@@ -31,7 +31,7 @@ module Cli
|
|
31
31
|
it "should require env.rb files first" do
|
32
32
|
File.stub!(:directory?).and_return(true)
|
33
33
|
Dir.stub!(:[]).and_return(["/features/support/a_file.rb","/features/support/env.rb"])
|
34
|
-
|
34
|
+
|
35
35
|
config = Configuration.new(StringIO.new)
|
36
36
|
config.parse!(%w{--require /features})
|
37
37
|
|
@@ -40,7 +40,19 @@ module Cli
|
|
40
40
|
"/features/support/a_file.rb"
|
41
41
|
]
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
|
+
it "should not require env.rb files when --dry-run" do
|
45
|
+
File.stub!(:directory?).and_return(true)
|
46
|
+
Dir.stub!(:[]).and_return(["/features/support/a_file.rb","/features/support/env.rb"])
|
47
|
+
|
48
|
+
config = Configuration.new(StringIO.new)
|
49
|
+
config.parse!(%w{--require /features --dry-run})
|
50
|
+
|
51
|
+
config.files_to_require.should == [
|
52
|
+
"/features/support/a_file.rb"
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
44
56
|
it "should expand args from YAML file" do
|
45
57
|
given_cucumber_yml_defined_as({'bongo' => '--require from/yml'})
|
46
58
|
|
@@ -101,11 +113,11 @@ END_OF_MESSAGE
|
|
101
113
|
config = Configuration.new(StringIO.new, error = StringIO.new)
|
102
114
|
config.parse!(%w{--profile i_do_not_exist})
|
103
115
|
|
104
|
-
error.string.should match(/cucumber.yml was not found. Please refer to cucumber's
|
116
|
+
error.string.should match(/cucumber.yml was not found. Please refer to cucumber's documentation on defining profiles in cucumber.yml./)
|
105
117
|
end
|
106
118
|
|
107
119
|
it "should provide a helpful error message when cucumber.yml is blank or malformed" do
|
108
|
-
expected_error_message = /cucumber.yml was found, but was blank or malformed. Please refer to cucumber's
|
120
|
+
expected_error_message = /cucumber.yml was found, but was blank or malformed. Please refer to cucumber's documentation on correct profile usage./
|
109
121
|
|
110
122
|
['', 'sfsadfs', "--- \n- an\n- array\n", "---dddfd"].each do |bad_input|
|
111
123
|
given_cucumber_yml_defined_as(bad_input)
|
@@ -118,7 +130,7 @@ END_OF_MESSAGE
|
|
118
130
|
end
|
119
131
|
|
120
132
|
it "should procide a helpful error message when the YAML can not be parsed" do
|
121
|
-
expected_error_message = /cucumber.yml was found, but could not be parsed. Please refer to cucumber's
|
133
|
+
expected_error_message = /cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentation on correct profile usage./
|
122
134
|
|
123
135
|
given_cucumber_yml_defined_as("input that causes an exception in YAML loading")
|
124
136
|
YAML.should_receive(:load).and_raise Exception
|
@@ -10,18 +10,6 @@ module Cli
|
|
10
10
|
Kernel.stub!(:exit).and_return(nil)
|
11
11
|
end
|
12
12
|
|
13
|
-
it "should print step definitions" do
|
14
|
-
step_mother = Object.new.extend(StepMother)
|
15
|
-
step_mother.Given(/Bonjour/) {}
|
16
|
-
step_mother.Given(/Monde/) {}
|
17
|
-
@cli = Main.new(%w{-S}, @out)
|
18
|
-
@cli.execute!(step_mother)
|
19
|
-
@out.string.should == %{
|
20
|
-
/Bonjour/ # spec/cucumber/cli/main_spec.rb:15
|
21
|
-
/Monde/ # spec/cucumber/cli/main_spec.rb:16
|
22
|
-
}.lstrip
|
23
|
-
end
|
24
|
-
|
25
13
|
describe "verbose mode" do
|
26
14
|
|
27
15
|
before(:each) do
|
@@ -54,7 +42,7 @@ module Cli
|
|
54
42
|
describe "diffing" do
|
55
43
|
|
56
44
|
before :each do
|
57
|
-
@configuration = mock('Configuration', :null_object => true
|
45
|
+
@configuration = mock('Configuration', :null_object => true)
|
58
46
|
Configuration.should_receive(:new).and_return(@configuration)
|
59
47
|
|
60
48
|
@step_mother = mock('StepMother', :null_object => true)
|
@@ -33,7 +33,7 @@ with blurb
|
|
33
33
|
parse(%{# My comment
|
34
34
|
Feature: hi
|
35
35
|
}).to_sexp.should ==
|
36
|
-
[:feature, "Feature: hi\n",
|
36
|
+
[:feature, nil, "Feature: hi\n",
|
37
37
|
[:comment, "# My comment\n"]]
|
38
38
|
end
|
39
39
|
|
@@ -45,7 +45,7 @@ Feature: hi
|
|
45
45
|
# When bar
|
46
46
|
Then baz
|
47
47
|
}).to_sexp.should ==
|
48
|
-
[:feature, "Feature: Hi",
|
48
|
+
[:feature, nil, "Feature: Hi",
|
49
49
|
[:scenario, 2, "Scenario:", "Hello",
|
50
50
|
[:step, 3, "Given", "foo"],
|
51
51
|
[:comment, "# When bar\n"],
|
@@ -59,18 +59,18 @@ Feature: hi
|
|
59
59
|
# World
|
60
60
|
Feature: hi
|
61
61
|
}).to_sexp.should ==
|
62
|
-
[:feature, "Feature: hi\n",
|
62
|
+
[:feature, nil, "Feature: hi\n",
|
63
63
|
[:comment, "# Hello\n# World\n"]]
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should parse a file with no comments" do
|
67
67
|
parse("Feature: hi\n").to_sexp.should ==
|
68
|
-
[:feature, "Feature: hi\n"]
|
68
|
+
[:feature, nil, "Feature: hi\n"]
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should parse a file with only a multiline comment with newlines" do
|
72
72
|
parse("# Hello\n\n# World\n").to_sexp.should ==
|
73
|
-
[:feature, "",
|
73
|
+
[:feature, nil, "",
|
74
74
|
[:comment, "# Hello\n\n# World\n"]]
|
75
75
|
end
|
76
76
|
end
|
@@ -78,7 +78,7 @@ Feature: hi
|
|
78
78
|
describe "Tags" do
|
79
79
|
it "should parse a file with tags on a feature" do
|
80
80
|
parse("# My comment\n@hello @world Feature: hi\n").to_sexp.should ==
|
81
|
-
[:feature, "Feature: hi\n",
|
81
|
+
[:feature, nil, "Feature: hi\n",
|
82
82
|
[:comment, "# My comment\n"],
|
83
83
|
[:tag, "hello"],
|
84
84
|
[:tag, "world"]]
|
@@ -96,7 +96,7 @@ Feature: hi
|
|
96
96
|
@st3
|
97
97
|
@st4 @ST5 @#^%&ST6**!
|
98
98
|
Scenario: Second}).to_sexp.should ==
|
99
|
-
[:feature, "Feature: hi",
|
99
|
+
[:feature, nil, "Feature: hi",
|
100
100
|
[:comment, "# FC\n "],
|
101
101
|
[:tag, "ft"],
|
102
102
|
[:scenario, 6, 'Scenario:', 'First',
|
@@ -111,7 +111,7 @@ Feature: hi
|
|
111
111
|
describe "Background" do
|
112
112
|
it "should have steps" do
|
113
113
|
parse("Feature: Hi\nBackground:\nGiven I am a step\n").to_sexp.should ==
|
114
|
-
[:feature, "Feature: Hi",
|
114
|
+
[:feature, nil, "Feature: Hi",
|
115
115
|
[:background, 2, "Background:",
|
116
116
|
[:step, 3, "Given", "I am a step"]]]
|
117
117
|
end
|
@@ -120,7 +120,7 @@ Feature: hi
|
|
120
120
|
describe "Scenarios" do
|
121
121
|
it "can be empty" do
|
122
122
|
parse("Feature: Hi\n\nScenario: Hello\n").to_sexp.should ==
|
123
|
-
[:feature, "Feature: Hi",
|
123
|
+
[:feature, nil, "Feature: Hi",
|
124
124
|
[:scenario, 3, "Scenario:", "Hello"]]
|
125
125
|
end
|
126
126
|
|
@@ -134,7 +134,7 @@ Scenario: bar
|
|
134
134
|
|
135
135
|
it "should have steps" do
|
136
136
|
parse("Feature: Hi\nScenario: Hello\nGiven I am a step\n").to_sexp.should ==
|
137
|
-
[:feature, "Feature: Hi",
|
137
|
+
[:feature, nil, "Feature: Hi",
|
138
138
|
[:scenario, 2, "Scenario:", "Hello",
|
139
139
|
[:step_invocation, 3, "Given", "I am a step"]]]
|
140
140
|
end
|
@@ -145,7 +145,7 @@ Scenario: Hello
|
|
145
145
|
Given I have a table
|
146
146
|
|a|b|
|
147
147
|
}).to_sexp.should ==
|
148
|
-
[:feature, "Feature: Hi",
|
148
|
+
[:feature, nil, "Feature: Hi",
|
149
149
|
[:scenario, 2, "Scenario:", "Hello",
|
150
150
|
[:step_invocation, 3, "Given", "I have a table",
|
151
151
|
[:table,
|
@@ -166,7 +166,7 @@ Given I have a string
|
|
166
166
|
"""
|
167
167
|
|
168
168
|
}).to_sexp.should ==
|
169
|
-
[:feature, "Feature: Hi",
|
169
|
+
[:feature, nil, "Feature: Hi",
|
170
170
|
[:scenario, 2, "Scenario:", "Hello",
|
171
171
|
[:step_invocation, 3, "Given", "I have a string",
|
172
172
|
[:py_string, "hello\nworld"]]]]
|
@@ -182,7 +182,7 @@ Examples:
|
|
182
182
|
|what|
|
183
183
|
|green|
|
184
184
|
}).to_sexp.should ==
|
185
|
-
[:feature, "Feature: Hi",
|
185
|
+
[:feature, nil, "Feature: Hi",
|
186
186
|
[:scenario_outline, "Scenario Outline:", "Hello",
|
187
187
|
[:step, 3, "Given", "a <what> cucumber"],
|
188
188
|
[:examples, "Examples:", "",
|
@@ -203,7 +203,7 @@ Examples:
|
|
203
203
|
|a|b|
|
204
204
|
|c|d|
|
205
205
|
}).to_sexp.should ==
|
206
|
-
[:feature, "Feature: Hi",
|
206
|
+
[:feature, nil, "Feature: Hi",
|
207
207
|
[:scenario_outline, "Scenario Outline:", "Hello",
|
208
208
|
[:step, 4, "Given", "I have a table",
|
209
209
|
[:table,
|
@@ -233,7 +233,7 @@ Examples:
|
|
233
233
|
|5|6|
|
234
234
|
|
235
235
|
").to_sexp.should ==
|
236
|
-
[:feature, "Feature: Hi",
|
236
|
+
[:feature, nil, "Feature: Hi",
|
237
237
|
[:scenario_outline, "Scenario Outline:", "Hello",
|
238
238
|
[:step, 5, "Given", "I have a table",
|
239
239
|
[:table,
|
@@ -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
|
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.
|
4
|
+
version: 0.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-25 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -245,6 +245,7 @@ files:
|
|
245
245
|
- examples/self_test/features/step_definitions/sample_steps.rb
|
246
246
|
- examples/self_test/features/support/env.rb
|
247
247
|
- examples/self_test/features/support/tag_count_formatter.rb
|
248
|
+
- examples/self_test/features/tons_of_cukes.feature
|
248
249
|
- examples/sinatra/Rakefile
|
249
250
|
- examples/sinatra/app.rb
|
250
251
|
- examples/sinatra/features/add.feature
|
@@ -264,9 +265,11 @@ files:
|
|
264
265
|
- examples/tickets/features/180.feature
|
265
266
|
- examples/tickets/features/236.feature
|
266
267
|
- examples/tickets/features/241.feature
|
268
|
+
- examples/tickets/features/248.feature
|
267
269
|
- examples/tickets/features/lib/eatting_machine.rb
|
268
270
|
- examples/tickets/features/lib/pantry.rb
|
269
271
|
- examples/tickets/features/scenario_outline.feature
|
272
|
+
- examples/tickets/features/step_definitons/248_steps.rb
|
270
273
|
- examples/tickets/features/step_definitons/scenario_outline_steps.rb
|
271
274
|
- examples/tickets/features/step_definitons/tickets_steps.rb
|
272
275
|
- examples/tickets/features/tickets.feature
|
@@ -284,13 +287,13 @@ files:
|
|
284
287
|
- features/step_definitions/cucumber_steps.rb
|
285
288
|
- features/step_definitions/extra_steps.rb
|
286
289
|
- features/support/env.rb
|
290
|
+
- features/usage.feature
|
287
291
|
- gem_tasks/deployment.rake
|
288
292
|
- gem_tasks/environment.rake
|
289
293
|
- gem_tasks/features.rake
|
290
294
|
- gem_tasks/fix_cr_lf.rake
|
291
295
|
- gem_tasks/flog.rake
|
292
296
|
- gem_tasks/gemspec.rake
|
293
|
-
- gem_tasks/jar.rake
|
294
297
|
- gem_tasks/rspec.rake
|
295
298
|
- gem_tasks/yard.rake
|
296
299
|
- lib/autotest/cucumber.rb
|
@@ -337,6 +340,7 @@ files:
|
|
337
340
|
- lib/cucumber/formatter/progress.rb
|
338
341
|
- lib/cucumber/formatter/rerun.rb
|
339
342
|
- lib/cucumber/formatter/unicode.rb
|
343
|
+
- lib/cucumber/formatter/usage.rb
|
340
344
|
- lib/cucumber/formatters/unicode.rb
|
341
345
|
- lib/cucumber/jbehave.rb
|
342
346
|
- lib/cucumber/languages.yml
|
data/gem_tasks/jar.rake
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# http://blog.nicksieger.com/articles/2009/01/10/jruby-1-1-6-gems-in-a-jar
|
2
|
-
|
3
|
-
USE_JRUBY_VERSION = '1.1.6'
|
4
|
-
USE_JBEHAVE_VERSION = '2.1'
|
5
|
-
USE_JUNIT_VERSION = '4.5'
|
6
|
-
USE_HAMCREST_VERSION = '1.1'
|
7
|
-
CUCUMBER_VERSIONED = "cucumber-#{Cucumber::VERSION::STRING}"
|
8
|
-
|
9
|
-
task :jar => [
|
10
|
-
:clean,
|
11
|
-
'jar:download_jruby',
|
12
|
-
'jar:install_gems',
|
13
|
-
'jar:bundle_gems',
|
14
|
-
'jar:download_jars_deps',
|
15
|
-
'jar:unpack_jar_deps',
|
16
|
-
'jar:bundle_jars',
|
17
|
-
'jar:fix_gem_binaries',
|
18
|
-
'jar:test_jar'
|
19
|
-
]
|
20
|
-
|
21
|
-
namespace :jar do
|
22
|
-
task :download_jruby do
|
23
|
-
sh "wget http://dist.codehaus.org/jruby/#{USE_JRUBY_VERSION}/jruby-complete-#{USE_JRUBY_VERSION}.jar -O #{CUCUMBER_VERSIONED}.jar"
|
24
|
-
end
|
25
|
-
|
26
|
-
task :install_gems => :gem do
|
27
|
-
mkdir 'pkg/jar_gems'
|
28
|
-
sh "java -jar #{CUCUMBER_VERSIONED}.jar -S gem install -i ./pkg/jar_gems pkg/#{CUCUMBER_VERSIONED}.gem --no-ri --no-rdoc"
|
29
|
-
end
|
30
|
-
|
31
|
-
task :bundle_gems do
|
32
|
-
sh "jar uf #{CUCUMBER_VERSIONED}.jar -C pkg/jar_gems ."
|
33
|
-
end
|
34
|
-
|
35
|
-
task :download_jars_deps do
|
36
|
-
mkdir 'pkg/jar_deps'
|
37
|
-
sh "wget http://repository.codehaus.org/org/jbehave/jbehave-core/#{USE_JBEHAVE_VERSION}/jbehave-core-#{USE_JBEHAVE_VERSION}.jar -O pkg/jar_deps/jbehave-core-#{USE_JBEHAVE_VERSION}.jar"
|
38
|
-
sh "wget http://mirrors.ibiblio.org/pub/mirrors/maven2/junit/junit/#{USE_JUNIT_VERSION}/junit-#{USE_JUNIT_VERSION}.jar -O pkg/jar_deps/junit-#{USE_JUNIT_VERSION}.jar"
|
39
|
-
sh "wget http://hamcrest.googlecode.com/files/hamcrest-all-#{USE_HAMCREST_VERSION}.jar -O pkg/jar_deps/hamcrest-all-#{USE_HAMCREST_VERSION}.jar"
|
40
|
-
end
|
41
|
-
|
42
|
-
task :unpack_jar_deps do
|
43
|
-
Dir.chdir 'pkg/jar_deps' do
|
44
|
-
Dir['*.jar'].each do |jar|
|
45
|
-
sh "jar xvf #{jar}"
|
46
|
-
rm_rf jar
|
47
|
-
rm_rf 'META-INF'
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
task :bundle_jars do
|
53
|
-
sh "jar uf #{CUCUMBER_VERSIONED}.jar -C pkg/jar_deps ."
|
54
|
-
end
|
55
|
-
|
56
|
-
task :fix_gem_binaries do
|
57
|
-
mkdir_p 'pkg/gem_binaries/META-INF/jruby.home'
|
58
|
-
Dir.chdir 'pkg/gem_binaries/META-INF/jruby.home' do
|
59
|
-
sh "jar xvf ../../../../#{CUCUMBER_VERSIONED}.jar bin"
|
60
|
-
end
|
61
|
-
sh "jar uf #{CUCUMBER_VERSIONED}.jar -C pkg/gem_binaries ."
|
62
|
-
end
|
63
|
-
|
64
|
-
task :test_jar do
|
65
|
-
sh "java -cp examples/jbehave/target/classes -jar #{CUCUMBER_VERSIONED}.jar -S cucumber examples/jbehave/features"
|
66
|
-
end
|
67
|
-
end
|