cellophane 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +130 -85
- data/VERSION +1 -1
- data/cellophane.gemspec +3 -2
- data/features/support/cellophane_steps.rb +4 -0
- data/features/version.feature +13 -0
- data/lib/cellophane/main.rb +4 -1
- data/lib/cellophane/options.rb +5 -0
- metadata +4 -3
data/README.textile
CHANGED
@@ -6,32 +6,65 @@ h3. Installation
|
|
6
6
|
|
7
7
|
@gem install cellophane@
|
8
8
|
|
9
|
-
h3.
|
9
|
+
h3. Configuration
|
10
10
|
|
11
|
-
|
11
|
+
h4. Project-specific File
|
12
12
|
|
13
|
-
|
13
|
+
Cellophane can be configured project by project through the use of a @.cellophane.yaml@ file that lives in the root of your project. Configurable options are:
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
- app
|
18
|
-
- config
|
19
|
-
- cuke
|
20
|
-
- features
|
21
|
-
- steps
|
22
|
-
- support
|
23
|
-
- db
|
24
|
-
- lib
|
25
|
-
- etc, etc
|
26
|
-
</pre>
|
15
|
+
*Directive*
|
16
|
+
@cuke_command@
|
27
17
|
|
28
|
-
|
18
|
+
*Explanation*
|
19
|
+
Tells Cellophane how to call Cucumber. Defaults to @cucumber@.
|
29
20
|
|
30
|
-
|
31
|
-
|
32
|
-
|
21
|
+
*Examples*
|
22
|
+
@cuke_command: bundle exec cucumber@
|
23
|
+
@cuke_command: script/cucumber@
|
24
|
+
@cuke_command: cuke@ (as in a shell alias)
|
33
25
|
|
34
|
-
|
26
|
+
*Directive*
|
27
|
+
@cucumber@
|
28
|
+
|
29
|
+
*Explanation*
|
30
|
+
Options you want to pass to Cucumber by default.
|
31
|
+
|
32
|
+
*Example*
|
33
|
+
@cucumber: --format progress --no-profile@
|
34
|
+
|
35
|
+
*Notes*
|
36
|
+
Anything defined by @cucumber@ in the configuration file will be overwritten by the @-c/--cucumber@ command line switch (see below).
|
37
|
+
|
38
|
+
*Directive*
|
39
|
+
@feature_path@
|
40
|
+
|
41
|
+
*Explanation*
|
42
|
+
Root location of your feature files. Defaults @features@.
|
43
|
+
|
44
|
+
*Example*
|
45
|
+
@feature_path: cuke/features@
|
46
|
+
|
47
|
+
*Notes*
|
48
|
+
The path is relative to your project's root.
|
49
|
+
|
50
|
+
*Directive*
|
51
|
+
@step_path@
|
52
|
+
|
53
|
+
*Explanation*
|
54
|
+
Location of your step definitions. Defaults to @features/step_definitions@. It can be defined in two ways:
|
55
|
+
|
56
|
+
# a path relative to the project root
|
57
|
+
# nested in each feature directory
|
58
|
+
|
59
|
+
*Examples*
|
60
|
+
@step_path: cuke/steps@
|
61
|
+
<pre>
|
62
|
+
step_path:
|
63
|
+
nested_in: step_definition
|
64
|
+
</pre>
|
65
|
+
|
66
|
+
*Notes*
|
67
|
+
Use the first method if your step defitions follow the structure of your features. For example:
|
35
68
|
|
36
69
|
<pre>
|
37
70
|
my_project
|
@@ -58,127 +91,137 @@ my_project
|
|
58
91
|
- etc, etc
|
59
92
|
</pre>
|
60
93
|
|
61
|
-
|
62
|
-
|
63
|
-
To use this structure in Cucumber requires explicitly requiring the files/directories with every run. To run all of the features in @cuke/features/admin/reports@, I would enter the command
|
94
|
+
Use the second method if each feature directory has its own step definitions directory:
|
64
95
|
|
65
96
|
<pre>
|
66
|
-
|
97
|
+
my_project
|
98
|
+
- app
|
99
|
+
- config
|
100
|
+
- features
|
101
|
+
- admin
|
102
|
+
- step_definitions
|
103
|
+
- user
|
104
|
+
- step_definitions
|
105
|
+
- visitor
|
106
|
+
- step_definitions
|
107
|
+
- support
|
108
|
+
- db
|
109
|
+
- lib
|
110
|
+
- etc, etc
|
67
111
|
</pre>
|
68
112
|
|
69
|
-
|
113
|
+
*Directive*
|
114
|
+
@requires@
|
115
|
+
|
116
|
+
*Explanation*
|
117
|
+
Other directories or files that Cucumber needs to require. It is an array.
|
118
|
+
|
119
|
+
*Examples*
|
120
|
+
@requires: [cuke/support, cuke/steps/shared]@
|
70
121
|
|
71
122
|
<pre>
|
72
|
-
|
123
|
+
requires:
|
124
|
+
- cuke/support
|
125
|
+
- cuke/steps/shared
|
73
126
|
</pre>
|
74
127
|
|
75
|
-
|
128
|
+
*Notes*
|
129
|
+
@requires@ are passed to Cucumber as defined, so absolute paths are respected.
|
76
130
|
|
77
|
-
|
131
|
+
h4. Command Line
|
78
132
|
|
79
|
-
Cellophane
|
133
|
+
Cellophane has the following command line options:
|
80
134
|
|
81
135
|
<pre>
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
136
|
+
Usage: cellophane [options] PATTERN
|
137
|
+
-r, --regexp PATTERN is a regular expression. Default is false.
|
138
|
+
-t, --tags TAGS Tags to include/exclude.
|
139
|
+
-c, --cucumber OPTIONS Options to pass to cucumber.
|
140
|
+
-p, --print Echo the command instead of calling cucumber.
|
141
|
+
-d, --debug Require ruby-debug.
|
142
|
+
-v, --version Display the version.
|
143
|
+
-h, --help Display this screen.
|
86
144
|
</pre>
|
87
145
|
|
88
|
-
|
146
|
+
PATTERN is the pattern of feature files that you are interested in. By default PATTERN is a glob, but by using the @-r/--regexp@ switch, you can pass a Ruby regular expression instead (no slashes necessary). When using a glob, you can specify that files matching the pattern are to be excluded by preceeding the pattern with a tilde (~). You can also combine include and exclude patterns in the same call. See below for examples.
|
89
147
|
|
90
|
-
@
|
148
|
+
If you need to pass something through to Cucumber, such as a formatter, use the @-c/--cucumber@ switch. Depending on what it is you are passing through, you might need to enclose it in quotes. Do keep in mind that @-c/--cucumber@ on the command line overrides that defined in the YAML file.
|
91
149
|
|
92
|
-
|
93
|
-
# a hash that indicates steps are nested under the feature directories
|
150
|
+
@-d/--debug@ is only useful for Cellophane development and will have no effect on Cucumber.
|
94
151
|
|
95
|
-
|
152
|
+
h3. History
|
96
153
|
|
97
|
-
|
98
|
-
feature_path: features
|
99
|
-
step_path: features/step_definitions
|
100
|
-
</pre>
|
154
|
+
By default, Cucumber expects features to live in @features@ and step definitions to live in @features/step_definitions@. When running a feature, all step definitions are loaded unless you explicitly require just the ones you want. If you structure your project differently, you have to require files explicitly, which gets old real fast.
|
101
155
|
|
102
|
-
|
156
|
+
After some experimenting with different directory structures, I settled on the following for my own projects:
|
103
157
|
|
104
158
|
<pre>
|
105
159
|
my_project
|
106
160
|
- app
|
107
161
|
- config
|
108
|
-
-
|
109
|
-
-
|
162
|
+
- cuke
|
163
|
+
- features
|
164
|
+
- steps
|
110
165
|
- support
|
111
166
|
- db
|
112
167
|
- lib
|
113
168
|
- etc, etc
|
114
169
|
</pre>
|
115
170
|
|
116
|
-
|
117
|
-
|
118
|
-
For the second style,
|
171
|
+
It's based on the structure of the @spec@ directory and I find that it fits my brain pretty well. There are three organizational strategies that I found myself following:
|
119
172
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
nested_in: step_definitions
|
124
|
-
</pre>
|
173
|
+
# separation of features in subdirectories
|
174
|
+
# keeping feature specific steps in files that are named according to the feature
|
175
|
+
# keeping all shared steps in files that are named in a more generalized fashion
|
125
176
|
|
126
|
-
|
177
|
+
For example, a project my look like this:
|
127
178
|
|
128
179
|
<pre>
|
129
180
|
my_project
|
130
181
|
- app
|
131
182
|
- config
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
183
|
+
- cuke
|
184
|
+
- features
|
185
|
+
- admin
|
186
|
+
- reports
|
187
|
+
- user_maintenance
|
188
|
+
- user
|
189
|
+
- communication
|
190
|
+
- profile
|
191
|
+
- steps
|
192
|
+
- admin
|
193
|
+
- reports
|
194
|
+
- user_maintenance
|
195
|
+
- user
|
196
|
+
- communication
|
197
|
+
- profile
|
139
198
|
- support
|
140
199
|
- db
|
141
200
|
- lib
|
142
201
|
- etc, etc
|
143
202
|
</pre>
|
144
203
|
|
145
|
-
@
|
204
|
+
If the features in @cuke/features/admin/reports@ had any steps that were specific to them, they would live @cuke/steps/admin/reports@. Any steps that are shared between two or more features would go in files in @cuke/support@.
|
205
|
+
|
206
|
+
To use this structure in Cucumber requires explicitly requiring the files/directories with every run. To run all of the features in @cuke/features/admin/reports@, I would enter the command
|
146
207
|
|
147
208
|
<pre>
|
148
|
-
|
209
|
+
cucumber -r cuke/support -r cuke/steps/admin/reports cuke/features/admin/reports
|
149
210
|
</pre>
|
150
211
|
|
151
|
-
|
152
|
-
|
153
|
-
Other configurable options:
|
154
|
-
|
155
|
-
@cuke_command@ can be set to whatever command you use to invoke cucumber. By default, it is simply @cucumber@, but you could also use @bundler exec cucumber@, @script/cucumber@, or an alias you might have defined.
|
156
|
-
|
157
|
-
h3. Operation
|
158
|
-
|
159
|
-
Cellophane has the following command line options:
|
212
|
+
I got weary of doing that all the time, so I experimented with aliases and profiles, neither of which really met my needs. So I created Cellophane. With it, the same features could be as easy as:
|
160
213
|
|
161
214
|
<pre>
|
162
|
-
|
163
|
-
-r, --regexp PATTERN is a regular expression. Default is false.
|
164
|
-
-t, --tags TAGS Tags to include/exclude.
|
165
|
-
-c, --cucumber OPTIONS Options to pass to cucumber.
|
166
|
-
-p, --print Echo the command instead of calling cucumber.
|
167
|
-
-d, --debug Require ruby-debug.
|
168
|
-
-h, --help Display this screen.
|
215
|
+
cellophane admin/*
|
169
216
|
</pre>
|
170
217
|
|
171
|
-
|
172
|
-
|
173
|
-
If you need to pass something through to Cucumber, such as a formatter, use the @-c/--cucumber@ switch. Depending on what it is you are passing through, you might need to enclose it in quotes. Do keep in mind that @-c/--cucumber@ on the command line overrides that defined in the YAML file.
|
174
|
-
|
175
|
-
@-d/--debug@ is only useful for Cellophane development and will have no effect on Cucumber.
|
218
|
+
As time went on, more patterns began to emerge from my workflow, and with them, Cellophane gained abilities.
|
176
219
|
|
177
220
|
h3. Examples and Notes
|
178
221
|
|
179
222
|
h4. Features
|
180
223
|
|
181
|
-
|
224
|
+
Using the example project above:
|
182
225
|
|
183
226
|
<pre>
|
184
227
|
# run all features
|
@@ -207,6 +250,8 @@ h4. Step Definitions
|
|
207
250
|
|
208
251
|
Cellophane does assume that your steps are defined in files that follow the naming of your features. For each feature file that is found, Cellophane will look for a step file with the same name and automatically require it. To require shared step definitions, put them in a folder and include that folder in the @requires@ section of @.cellophane.yaml@.
|
209
252
|
|
253
|
+
For example, if you have a feature defined in @<feature path>/admin/user/account_maintenance.feature@, Cellophane will automatically require a step definition file located in @<step path>/admin/user/account_maintenance_steps.rb@. Unless you are using nested step definitions in @.cellophane.yaml@ (@step_path: {nested_in: steps }@, in which case Cellophane will automatically require @<feature path>/admin/user/steps/account_maintenance_steps.rb@ if it exists.
|
254
|
+
|
210
255
|
h4. Tags
|
211
256
|
|
212
257
|
You don't need to use @. You can you want, but it's not necessary.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/cellophane.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cellophane}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Phillip Koebbe"]
|
12
|
-
s.date = %q{2011-01-
|
12
|
+
s.date = %q{2011-01-11}
|
13
13
|
s.default_executable = %q{cellophane}
|
14
14
|
s.description = %q{Cellophane is a thin wrapper around Cucumber, making it easier to be creative when running features.}
|
15
15
|
s.email = %q{phillip@livingdoor.net}
|
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
"features/support/cellophane_steps.rb",
|
38
38
|
"features/support/env.rb",
|
39
39
|
"features/tags.feature",
|
40
|
+
"features/version.feature",
|
40
41
|
"lib/cellophane/main.rb",
|
41
42
|
"lib/cellophane/options.rb",
|
42
43
|
"lib/cellophane/parser.rb"
|
@@ -40,4 +40,8 @@ Given /^a project options file with the following options$/ do |lines|
|
|
40
40
|
|
41
41
|
# already in the project dir
|
42
42
|
File.open(Cellophane::PROJECT_OPTIONS_FILE, 'w') { |f| f.write(contents) }
|
43
|
+
end
|
44
|
+
|
45
|
+
Given /^the current version should be displayed$/ do
|
46
|
+
@command.should =~ /#{Cellophane::VERSION}/
|
43
47
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: Version
|
2
|
+
|
3
|
+
@1
|
4
|
+
Scenario: Short switch
|
5
|
+
|
6
|
+
Given Cellophane is called with "-v"
|
7
|
+
Then the current version should be displayed
|
8
|
+
|
9
|
+
@2
|
10
|
+
Scenario: Long switch
|
11
|
+
|
12
|
+
Given Cellophane is called with "--version"
|
13
|
+
Then the current version should be displayed
|
data/lib/cellophane/main.rb
CHANGED
@@ -4,6 +4,7 @@ require 'cellophane/options'
|
|
4
4
|
|
5
5
|
module Cellophane
|
6
6
|
|
7
|
+
VERSION = '0.1.2'
|
7
8
|
PROJECT_OPTIONS_FILE = '.cellophane.yaml'
|
8
9
|
|
9
10
|
class Main
|
@@ -28,12 +29,14 @@ module Cellophane
|
|
28
29
|
|
29
30
|
def run
|
30
31
|
puts @message and return if @message
|
31
|
-
@options[:print] ? puts(@command) : system("#{@command}\n\n")
|
32
|
+
@options[:print] || @options[:version] ? puts(@command) : system("#{@command}\n\n")
|
32
33
|
end
|
33
34
|
|
34
35
|
private
|
35
36
|
|
36
37
|
def generate_command
|
38
|
+
return "cellophane #{Cellophane::VERSION}" if @options[:version]
|
39
|
+
|
37
40
|
cuke_cmd = "#{@options[:cuke_command]} #{@options[:cucumber]}"
|
38
41
|
|
39
42
|
features = []
|
data/lib/cellophane/options.rb
CHANGED
@@ -34,6 +34,11 @@ module Cellophane
|
|
34
34
|
require 'ruby-debug'
|
35
35
|
end
|
36
36
|
|
37
|
+
# This displays the help screen, all programs are assumed to have this option.
|
38
|
+
opts.on( '-v', '--version', 'Display the version.' ) do
|
39
|
+
merged_options[:version] = true
|
40
|
+
end
|
41
|
+
|
37
42
|
# This displays the help screen, all programs are assumed to have this option.
|
38
43
|
opts.on( '-h', '--help', 'Display this screen.' ) do
|
39
44
|
puts opts
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Phillip Koebbe
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-11 00:00:00 -06:00
|
18
18
|
default_executable: cellophane
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- features/support/cellophane_steps.rb
|
47
47
|
- features/support/env.rb
|
48
48
|
- features/tags.feature
|
49
|
+
- features/version.feature
|
49
50
|
- lib/cellophane/main.rb
|
50
51
|
- lib/cellophane/options.rb
|
51
52
|
- lib/cellophane/parser.rb
|