step_master 0.0.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 +3 -0
- data/Manifest.txt +12 -0
- data/PostInstall.txt +1 -0
- data/README.rdoc +53 -0
- data/Rakefile +26 -0
- data/lib/step_master/matcher.rb +126 -0
- data/lib/step_master/possible.rb +21 -0
- data/lib/step_master/step_item.rb +31 -0
- data/lib/step_master/step_variable.rb +27 -0
- data/lib/step_master.rb +8 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/step_helper/matcher_spec.rb +276 -0
- data/test/test_helper.rb +3 -0
- data/test/test_step_master.rb +11 -0
- metadata +80 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
PostInstall.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
lib/step_master.rb
|
7
|
+
lib/step_master/matcher.rb
|
8
|
+
lib/step_master/possible.rb
|
9
|
+
lib/step_master/step_item.rb
|
10
|
+
lib/step_master/step_variable.rb
|
11
|
+
spec/spec_helper.rb
|
12
|
+
spec/step_helper/matcher_spec.rb
|
data/PostInstall.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
For more information on step_master, see http://github.com/clearwavebuild/step_master
|
data/README.rdoc
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
= StepMaster
|
2
|
+
|
3
|
+
http://github.com/clearwavebuild/step_master
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Provide a simple and easy way to find and auto-complete gherkin steps, when writing cucumber features
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
none
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
require 'step_master'
|
16
|
+
|
17
|
+
matcher = StepMaster::Matcher.new
|
18
|
+
matcher << "Given /^I like pie$/ do"
|
19
|
+
matcher << "Given /^I like cake$/ do"
|
20
|
+
|
21
|
+
matcher.complete("Given I like") #=> ["pie", "cake"]
|
22
|
+
|
23
|
+
|
24
|
+
== REQUIREMENTS:
|
25
|
+
|
26
|
+
none
|
27
|
+
|
28
|
+
== INSTALL:
|
29
|
+
|
30
|
+
sudo gem install clearwavebuild-step_master -s http://gems.github.com
|
31
|
+
|
32
|
+
== LICENSE:
|
33
|
+
|
34
|
+
Copyright (c) 2009 Clearwave Inc
|
35
|
+
|
36
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
37
|
+
a copy of this software and associated documentation files (the
|
38
|
+
'Software'), to deal in the Software without restriction, including
|
39
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
40
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
41
|
+
permit persons to whom the Software is furnished to do so, subject to
|
42
|
+
the following conditions:
|
43
|
+
|
44
|
+
The above copyright notice and this permission notice shall be
|
45
|
+
included in all copies or substantial portions of the Software.
|
46
|
+
|
47
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
48
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
49
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
50
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
51
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
52
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
53
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/step_master'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'step_master' do
|
14
|
+
self.developer 'Jim Holmes', '32bitkid@gmail.com'
|
15
|
+
self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
16
|
+
self.rubyforge_name = self.name # TODO this is default value
|
17
|
+
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'newgem/tasks'
|
22
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
23
|
+
|
24
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
25
|
+
# remove_task :default
|
26
|
+
# task :default => [:spec, :features]
|
@@ -0,0 +1,126 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'step_master/step_item'
|
4
|
+
require 'step_master/step_variable'
|
5
|
+
require 'step_master/possible'
|
6
|
+
|
7
|
+
# Provide a simple and easy way to find and auto-complete gherkin steps,
|
8
|
+
# when writing cucumber features
|
9
|
+
# See StepMaster for usage details.
|
10
|
+
module StepMaster
|
11
|
+
|
12
|
+
# This class collects raw steps as strings.
|
13
|
+
#
|
14
|
+
# The complete method returns a list of all possible
|
15
|
+
# steps that start with a given string (taking into
|
16
|
+
# account captures and imbedded regexps).
|
17
|
+
#
|
18
|
+
# The is_match? method lets you check if a string exactly
|
19
|
+
# matches to a step definition
|
20
|
+
#
|
21
|
+
class Matcher
|
22
|
+
|
23
|
+
STEP_REGEX = /^\s*(Given|Then|When)\s*\(?\s*\/\^?(.*)\/(\w*)\s*\)?\s*(?:do|\{)\s*(\|[^\|]+\|)?/.freeze
|
24
|
+
ARG_NAMES_REGEX = /\|(.*)\|/
|
25
|
+
ARG_TEXT_REGEX = /\(.*?[^\\]\)\??/
|
26
|
+
NON_CAPTURE_REGEX = /\(\?\:/
|
27
|
+
CHUNK_REGEX = /\S+|\s\??/
|
28
|
+
|
29
|
+
attr_reader :match_table
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
@match_table = Possible.new
|
33
|
+
end
|
34
|
+
|
35
|
+
# Insert a Ruby Step definition into the Match Table
|
36
|
+
#
|
37
|
+
# ==== Examples
|
38
|
+
# matcher << "Given /^this is a step$/ do"
|
39
|
+
#
|
40
|
+
def <<(value)
|
41
|
+
raise "#{value.inspect} is not a step" unless value =~ STEP_REGEX
|
42
|
+
|
43
|
+
full_line = $&
|
44
|
+
step_type = $1
|
45
|
+
regex = $2.chomp("$")
|
46
|
+
regex_options = $3
|
47
|
+
args = $4
|
48
|
+
|
49
|
+
arg_names = (args =~ ARG_NAMES_REGEX) ? $1.split(/\s*,\s*/) : []
|
50
|
+
arg_regexs = regex.chomp("$").scan(ARG_TEXT_REGEX)
|
51
|
+
|
52
|
+
arg_objects = arg_regexs.collect do |x|
|
53
|
+
is_non_capture = (x =~ NON_CAPTURE_REGEX) != nil
|
54
|
+
StepVariable.new(x, regex_options, (is_non_capture) ? nil : arg_names.shift)
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
elements = if arg_regexs.length > 0
|
59
|
+
regex.split(Regexp.union(arg_regexs.collect { |x|
|
60
|
+
Regexp.new(Regexp.escape(x))
|
61
|
+
})).collect { |x|
|
62
|
+
x.scan(CHUNK_REGEX).collect { |i| StepItem.new(i, regex_options) }
|
63
|
+
}.zip(arg_objects).flatten.compact.unshift(StepItem.new(" ", regex_options)).unshift(StepItem.new(step_type, regex_options))
|
64
|
+
else
|
65
|
+
regex.scan(CHUNK_REGEX).unshift(" ").unshift(step_type).collect { |i| StepItem.new(i, regex_options) }
|
66
|
+
end
|
67
|
+
|
68
|
+
elements.inject(@match_table) { |parent, i| parent[i] ||= Possible.new }.terminal!(full_line)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns all possible outcomes of a string.
|
72
|
+
#
|
73
|
+
# ==== Parameters
|
74
|
+
# * +string+ - The string to try to auto complete
|
75
|
+
# * +options+ - :easy => true will replace captures with the variable names in the step definition
|
76
|
+
#
|
77
|
+
# ==== Examples
|
78
|
+
# matcher.complete("Given this")
|
79
|
+
# matcher.complete("Given this", :easy => true)
|
80
|
+
#
|
81
|
+
def complete(string, options = {})
|
82
|
+
possible_strings find_possible(string), options
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns true if the string matches exactly to a step definition
|
86
|
+
#
|
87
|
+
# ==== Examples
|
88
|
+
# matcher << "Given /^this$/ do"
|
89
|
+
# matcher.is_match?("Given this") #=> true
|
90
|
+
# matcher.is_match?("Given that") #=> false
|
91
|
+
#
|
92
|
+
def is_match?(string)
|
93
|
+
find_possible(string).any?{ |x| x.terminal? }
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
def find_possible(input, against = @match_table)
|
98
|
+
return against.keys.collect do |x|
|
99
|
+
if input =~ x.to_regexp
|
100
|
+
new_input = $'
|
101
|
+
unless new_input.empty?
|
102
|
+
find_possible new_input, against[x]
|
103
|
+
else
|
104
|
+
against[x]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end.flatten.compact
|
108
|
+
end
|
109
|
+
|
110
|
+
def possible_strings(possible, options={}, so_far = [], collection = [])
|
111
|
+
if possible.is_a?(Array)
|
112
|
+
possible.each { |a| possible_strings(a, options, so_far, collection) }
|
113
|
+
else
|
114
|
+
possible.each do |k,v|
|
115
|
+
str = k.to_s(options)
|
116
|
+
|
117
|
+
here = (so_far + [str])
|
118
|
+
|
119
|
+
collection << here.join("") if v.terminal?
|
120
|
+
possible_strings(v, options, here, collection)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
collection
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module StepMaster
|
2
|
+
class Possible < ::Hash
|
3
|
+
EMPTY = Possible.new
|
4
|
+
|
5
|
+
def terminal!(result)
|
6
|
+
@terminal = result.freeze
|
7
|
+
end
|
8
|
+
|
9
|
+
def terminal?
|
10
|
+
!@terminal.nil?
|
11
|
+
end
|
12
|
+
|
13
|
+
def result
|
14
|
+
@terminal
|
15
|
+
end
|
16
|
+
|
17
|
+
def inspect
|
18
|
+
super << ((terminal? )? "["+result+"]" : "")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module StepMaster
|
2
|
+
class StepItem
|
3
|
+
attr_reader :text, :options
|
4
|
+
|
5
|
+
def initialize(text, opts)
|
6
|
+
@text = text.freeze
|
7
|
+
@options = 0
|
8
|
+
@options |= (opts.match(/i/) ? Regexp::IGNORECASE : 0)
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_regexp
|
12
|
+
@regex = Regexp.new("^" << text, options).freeze
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s(options = {})
|
16
|
+
text
|
17
|
+
end
|
18
|
+
|
19
|
+
def inspect
|
20
|
+
text.inspect
|
21
|
+
end
|
22
|
+
|
23
|
+
def eql?(o)
|
24
|
+
o.is_a?(StepItem) && self.text.eql?(o.text)
|
25
|
+
end
|
26
|
+
|
27
|
+
def hash
|
28
|
+
text.hash
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'step_master/step_item'
|
2
|
+
|
3
|
+
module StepMaster
|
4
|
+
class StepVariable < StepItem
|
5
|
+
ARG_TEXT_REGEX = /\(.*?[^\\]\)/
|
6
|
+
|
7
|
+
attr_reader :name
|
8
|
+
|
9
|
+
def initialize(text, options, name)
|
10
|
+
super(text, options)
|
11
|
+
@name = name.freeze
|
12
|
+
|
13
|
+
raise "#{@text.inspect} is not a variable!" unless @text =~ ARG_TEXT_REGEX
|
14
|
+
@easy = @name.nil? ? @text : $` + "<" + @name + ">" + $'
|
15
|
+
|
16
|
+
@easy.freeze
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s(options = {})
|
20
|
+
options[:easy] ? @easy : super()
|
21
|
+
end
|
22
|
+
|
23
|
+
def inspect
|
24
|
+
"#{text.inspect}:#{name.inspect}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/step_master.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,276 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "spec_helper")
|
2
|
+
|
3
|
+
module StepMaster
|
4
|
+
|
5
|
+
VALID_STEP = "Given /^nothing$/ do"
|
6
|
+
|
7
|
+
describe Matcher do
|
8
|
+
before(:each) do
|
9
|
+
@matcher = Matcher.new
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#<<" do
|
13
|
+
it "accepts a string" do
|
14
|
+
@matcher << VALID_STEP
|
15
|
+
end
|
16
|
+
|
17
|
+
it "not throw an exception when it recieves a valid step" do
|
18
|
+
lambda {
|
19
|
+
@matcher << VALID_STEP
|
20
|
+
}.should_not raise_error(Exception)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should not like a step it can't parse" do
|
24
|
+
lambda {
|
25
|
+
@matcher << "This is not a step"
|
26
|
+
}.should raise_error(%q["This is not a step" is not a step])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#is_match?" do
|
31
|
+
|
32
|
+
describe "with a terminal and longer step" do
|
33
|
+
before :each do
|
34
|
+
@matcher << "Given /^I want pie$/ do"
|
35
|
+
@matcher << "Given /^I want pie in the morning$/ do"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should match to 'I want pie'" do
|
39
|
+
@matcher.is_match?("Given I want pie").should be_true
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should not match to 'I want pie in" do
|
43
|
+
@matcher.is_match?("Given I want pie in").should be_false
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should match to 'I want pie in the morning" do
|
47
|
+
@matcher.is_match?("Given I want pie in the morning").should be_true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "with a simple regex variable" do
|
52
|
+
before :each do
|
53
|
+
@matcher << 'Given /^I want (\w{3})$/ do |something|'
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should match \"Given I want pie\"" do
|
57
|
+
@matcher.is_match?("Given I want pie").should be_true
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should not match \"Given I want !@@\"" do
|
61
|
+
@matcher.is_match?("Given I want !@@").should be_false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "with regex with quotes around it" do
|
66
|
+
before :each do
|
67
|
+
@matcher << 'Given /^I want "([^\"]*)"$/ do |something|'
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should match \"Given I want \"pie\"\"" do
|
71
|
+
@matcher.is_match?("Given I want \"pie\"").should be_true
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should match \"Given I want \"123\"\"" do
|
75
|
+
@matcher.is_match?("Given I want \"!@@\"").should be_true
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
describe "#complete" do
|
82
|
+
it "accepts a string" do
|
83
|
+
@matcher.complete("Given")
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should be able to match a simple step" do
|
87
|
+
@matcher << VALID_STEP
|
88
|
+
@matcher.complete("Given").should include(" nothing")
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "with two simple steps given" do
|
92
|
+
before(:each) do
|
93
|
+
@matcher << "Given /^this$/ do"
|
94
|
+
@matcher << "Given /^that$/ do"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should return 2 results when search for 'Given'" do
|
98
|
+
@matcher.complete("Given").should have(2).results
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should return 'this' when search for 'Given'" do
|
102
|
+
@matcher.complete("Given").should include(" this")
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should return 'that' when search for 'Given'" do
|
106
|
+
@matcher.complete("Given").should include(" that")
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should return no results when search for 'Given this'" do
|
110
|
+
@matcher.complete("Given this").should have(0).results
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "with some simple branching steps" do
|
115
|
+
before(:each) do
|
116
|
+
@matcher << "Given /^I want pie$/ do"
|
117
|
+
@matcher << "Given /^I want cake$/ do"
|
118
|
+
@matcher << "Given /^I can swim$/ do"
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should return 3 results when search for 'Given'" do
|
122
|
+
@matcher.complete("Given").should have(3).results
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should include 'I want pie' when searched for 'Given'" do
|
126
|
+
@matcher.complete("Given").should include(" I want pie")
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should include 'I want cake' when searched for 'Given'" do
|
130
|
+
@matcher.complete("Given").should include(" I want cake")
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should include 'I can swim' when searched for 'Given'" do
|
134
|
+
@matcher.complete("Given").should include(" I can swim")
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should return 2 results when search for 'Given I want'" do
|
138
|
+
@matcher.complete("Given I want").should have(2).results
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should include 'pie' when searched for 'Given'" do
|
142
|
+
@matcher.complete("Given I want").should include(" pie")
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should include 'cake' when searched for 'Given'" do
|
146
|
+
@matcher.complete("Given I want").should include(" cake")
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should return 1 result when search for 'Given I can'" do
|
150
|
+
@matcher.complete("Given I can").should have(1).results
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should include 'swim' when searched for 'Given'" do
|
154
|
+
@matcher.complete("Given I can").should include(" swim")
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "with a terminal and longer step" do
|
159
|
+
before :each do
|
160
|
+
@matcher << "Given /^I want pie$/ do"
|
161
|
+
@matcher << "Given /^I want pie in the morning$/ do"
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should include 2 results when I search for 'Given'" do
|
165
|
+
@matcher.complete('Given').should have(2).results
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should include 'I want pie'" do
|
169
|
+
@matcher.complete("Given").should include(" I want pie")
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should include 'I want pie in the morning'" do
|
173
|
+
@matcher.complete("Given").should include(" I want pie in the morning")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "with a simple regex variable" do
|
178
|
+
before :each do
|
179
|
+
@matcher << 'Given /^I want (\w{3})$/ do |something|'
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should auto complete" do
|
183
|
+
@matcher.complete("Given").should have(1).result
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should complete with variables names " do
|
187
|
+
m = @matcher.complete("Given", :easy => true)
|
188
|
+
m.should have(1).result
|
189
|
+
m.should include(" I want <something>")
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe "with regex with quotes around it" do
|
194
|
+
before :each do
|
195
|
+
@matcher << 'Given /^I want "([^\"]*)"$/ do |something|'
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should auto complete" do
|
199
|
+
@matcher.complete("Given").should have(1).result
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should complete with variables names " do
|
203
|
+
m = @matcher.complete("Given", :easy => true)
|
204
|
+
m.should have(1).result
|
205
|
+
m.should include(" I want \"<something>\"")
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
describe "with more complex capture that could include spaces" do
|
210
|
+
before :each do
|
211
|
+
@matcher << 'Given /^I want "([^\"]*)" for dinner$/ do |something|'
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should handle more than one word inside quotes" do
|
215
|
+
@matcher.complete("Given I want \"steak and potatoes\"").should have(1).result
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe "with multiple arguments" do
|
220
|
+
before :each do
|
221
|
+
@matcher << 'Given /^I want "([^\"]*)" in the "([^\"]*)"$/ do |food, time_of_day|'
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should complete with variables names " do
|
225
|
+
m = @matcher.complete("Given", :easy => true)
|
226
|
+
m.should have(1).result
|
227
|
+
m.should include(" I want \"<food>\" in the \"<time_of_day>\"")
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe "with non captures" do
|
232
|
+
|
233
|
+
it "should correctly match one variables name" do
|
234
|
+
@matcher << %q[Given /^I want "(?:[^\"]*)" in the "([^\"]*)"$/ do |time_of_day|]
|
235
|
+
m = @matcher.complete("Given", :easy => true)
|
236
|
+
m.should have(1).result
|
237
|
+
m.should include(%q[ I want "(?:[^\"]*)" in the "<time_of_day>"])
|
238
|
+
end
|
239
|
+
|
240
|
+
it "should correctly match two variables name" do
|
241
|
+
@matcher << %q[Given /^I (\w{4}) "(?:[^\"]*)" in the "([^\"]*)"$/ do |type, time_of_day|]
|
242
|
+
m = @matcher.complete("Given", :easy => true)
|
243
|
+
m.should have(1).result
|
244
|
+
m.should include(%q[ I <type> "(?:[^\"]*)" in the "<time_of_day>"])
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
|
249
|
+
describe "with an optional space" do
|
250
|
+
before :each do
|
251
|
+
@matcher << %q~Given /^(?:a )?provider ?location (?:named |called )?"([^\"]*)" exists$/i do |name|~
|
252
|
+
end
|
253
|
+
|
254
|
+
it "should correctly auto-complete" do
|
255
|
+
@matcher.complete("Given provider location").should have(1).result
|
256
|
+
@matcher.complete("Given a provider location").should have(1).result
|
257
|
+
@matcher.complete("Given providerlocation").should have(1).result
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
describe "with an case insensitive switch" do
|
262
|
+
before :each do
|
263
|
+
@matcher << %q~Given /^(?:a )?provider ?location (?:named |called )?"([^\"]*)" exists$/i do |name|~
|
264
|
+
end
|
265
|
+
|
266
|
+
it "should correctly auto-complete" do
|
267
|
+
@matcher.complete("Given provider location").should have(1).result
|
268
|
+
@matcher.complete("Given a Provider Location").should have(1).result
|
269
|
+
@matcher.complete("Given ProviderLocation").should have(1).result
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: step_master
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jim Holmes
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-14 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.3.3
|
24
|
+
version:
|
25
|
+
description: Provide a simple and easy way to find and auto-complete gherkin steps, when writing cucumber features
|
26
|
+
email:
|
27
|
+
- 32bitkid@gmail.com
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- PostInstall.txt
|
36
|
+
files:
|
37
|
+
- History.txt
|
38
|
+
- Manifest.txt
|
39
|
+
- PostInstall.txt
|
40
|
+
- README.rdoc
|
41
|
+
- Rakefile
|
42
|
+
- lib/step_master.rb
|
43
|
+
- lib/step_master/matcher.rb
|
44
|
+
- lib/step_master/possible.rb
|
45
|
+
- lib/step_master/step_item.rb
|
46
|
+
- lib/step_master/step_variable.rb
|
47
|
+
- spec/spec_helper.rb
|
48
|
+
- spec/step_helper/matcher_spec.rb
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://github.com/clearwavebuild/step_master
|
51
|
+
licenses: []
|
52
|
+
|
53
|
+
post_install_message: PostInstall.txt
|
54
|
+
rdoc_options:
|
55
|
+
- --main
|
56
|
+
- README.rdoc
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project: step_master
|
74
|
+
rubygems_version: 1.3.5
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: Provide a simple and easy way to find and auto-complete gherkin steps, when writing cucumber features
|
78
|
+
test_files:
|
79
|
+
- test/test_step_master.rb
|
80
|
+
- test/test_helper.rb
|