cucumber-in-the-yard 1.5.2 → 1.5.3

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 CHANGED
@@ -1,3 +1,12 @@
1
+ === 1.5.3 / 2010-10-26
2
+
3
+ * FIX - Step Definition YARD handler regex was poorly formed and raised exceptions
4
+ when it contained a forward-slash (even if escaped).
5
+ * FIX - Step highlighting was causing 'Out Of Memory' issues because
6
+ gsub could not handle nil values.
7
+ * FIX - Step highlighting failed to replace matches properly causing for corrupted
8
+ HTML span values to appear in the highlighted step definitions
9
+
1
10
  === 1.5.2 / 2010-10-26
2
11
 
3
12
  * FIX - Step Transform YARD handler regex was poorly formed and raised exceptions
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ task :gendoc do
8
8
  `yardoc -e lib/city.rb -p lib/templates 'example/**/*' --debug`
9
9
  end
10
10
 
11
- Echoe.new('cucumber-in-the-yard', '1.5.2') do |g|
11
+ Echoe.new('cucumber-in-the-yard', '1.5.3') do |g|
12
12
  g.author = "Franklin Webber"
13
13
  g.email = "franklin.webber@gmail.com"
14
14
  g.url = "http://github.com/burtlo/Cucumber-In-The-Yard"
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{cucumber-in-the-yard}
5
- s.version = "1.5.2"
5
+ s.version = "1.5.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Franklin Webber"]
@@ -24,7 +24,19 @@ Feature: Customer Logout Feature
24
24
  When a customer logs in as username 'frank' with password 'default'
25
25
  And visits the customer update page
26
26
  Then I expect the customer is able able to post to their profile
27
-
27
+
28
+ @optional_parameters
29
+ Scenario: Optional Parameter Step Definition
30
+ # This step definition has some optional parameters
31
+ Given a project
32
+ And an inactive project
33
+ And a project with the name 'optional', start date 10/26/2010, nicknamed 'norman'
34
+
35
+ @highlighting
36
+ Scenario: Highlighting
37
+ Given a duck that has a bill
38
+ Then I expect the duck to quack
39
+
28
40
  @product
29
41
  Scenario Outline: Customers that bought a product are included in their product groups
30
42
  Given that <Customer> is a valid customer
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  CUSTOMER = /(?:(?:an?|the) customer|#{TEDDY_BEAR})/
4
2
 
5
3
  TEDDY_BEAR = /teddy bear/
@@ -49,6 +47,27 @@ And /^edits their the (biography) to state:$/ do |section,text|
49
47
  pending "text_field not present for #{section} #{bio} for this release"
50
48
  end
51
49
 
50
+ #
51
+ # Complicated step definition with optional parameters
52
+ #
53
+ Given /^(?:I create )?an? (?:(active|deactive|inactive|simulated)d?)? ?project(?:[\s,]*(?:with)? ?(?:an?|the)? (?:(?:the size? (?:at|of)? ?(\d+)|named? (?:of )?'([^']+)'|start date (?:of )?((?:(?:\d{1,2}[\/-]){2}(?:\d\d){1,2}))|end date (?:of )?((?:(?:\d{1,2}[\/-]){2}(?:\d\d){1,2}))|user range (?:of )?(\d+-\d+)|description (?:of )?'([^']+)'|nicknamed? (?:of )?'([^']+)')[,\s]*)* ?)?$/ do |state,size,name,start_date,end_date,user_range,description,nickname|
54
+ pending "#{state} #{size} #{name} #{start_date} #{end_date} #{user_range} #{description} #{nickname}"
55
+ end
56
+
57
+
58
+ #
59
+ # The highlighting replacement uses a span which had trouble when blindly using
60
+ # a gsub replacement.
61
+ #
62
+ Given /(a|\d+) ducks? that ha(?:s|ve) (a|\d+) bills?/ do |duck_count,bills_count|
63
+ pending
64
+ end
65
+
66
+ Then /I expect the (duck|bird) to (\w+)/ do |animal,verb|
67
+ pending
68
+ end
69
+
70
+
52
71
  #
53
72
  # Some details about the helper method that might be picked up in the documentation.
54
73
  #
@@ -7,7 +7,7 @@
7
7
 
8
8
  <% if step.definition %>
9
9
  <span class="defined">
10
- <%= highlight_matches(step) %>
10
+ <%= highlight_matches(step) %>
11
11
  <div class="details">
12
12
  <a href="<%= url_for step.definition %>">?</a>
13
13
  </div>
@@ -33,8 +33,13 @@ def highlight_matches(step)
33
33
  value = h(step.value)
34
34
 
35
35
  if step.definition
36
- step.value.match(%r{#{step.definition.compare_value}}).to_a[1..-1].each do |match|
37
- value.gsub!(h(match),"<span class='match'>#{h(match)}</span>")
36
+ matches = step.value.match(%r{#{step.definition.compare_value}})
37
+
38
+ if matches
39
+ matches[1..-1].reverse.each_with_index do |match,index|
40
+ next if match == nil
41
+ value[matches.begin((matches.size - 1) - index)..(matches.end((matches.size - 1) - index) - 1)] = "<span class='match'>#{match}</span>"
42
+ end
38
43
  end
39
44
  end
40
45
 
@@ -29,13 +29,7 @@ module YARD::CodeObjects::Cucumber
29
29
  def transformed?
30
30
  !@transforms.empty?
31
31
  end
32
-
33
- def compare_values
34
-
35
- @scenario.example_hash.collect do |stub,replacements|
36
- replacements.collect {|replace| value.gsub("<#{stub}>",replace) }
37
- end.flatten
38
- end
32
+
39
33
  end
40
34
 
41
35
  end
@@ -12,18 +12,20 @@ module YARD::CodeObjects
12
12
  @value = format_source(value)
13
13
  @constants = {}
14
14
  @steps = []
15
+ @compare_value = nil
15
16
  end
16
17
 
17
18
  def compare_value
18
- base_value = value.gsub(/^\/|\/$/,'')
19
- @constants.each do |name,value|
20
- base_value.gsub!(/\#\{\s*#{name.to_s}\s*\}/,value.gsub(/^\/|\/$/,''))
19
+ unless @compare_value
20
+ @compare_value = value.gsub(/^\/|\/$/,'')
21
+ @constants.each do |name,value|
22
+ @compare_value.gsub!(/\#\{\s*#{name.to_s}\s*\}/,value.gsub(/^\/|\/$/,''))
23
+ end
21
24
  end
22
- base_value
25
+ @compare_value
23
26
  end
24
27
 
25
28
  def _value_constants(data=@value)
26
- #Hash[*data.scan(/\#\{([^\}]+)\}/).flatten.collect {|value| [value.strip,nil]}.flatten]
27
29
  data.scan(/\#\{([^\}]+)\}/).flatten.collect { |value| value.strip }
28
30
  end
29
31
 
@@ -61,11 +61,9 @@ module YARD
61
61
  #log.debug "Looking at step #{step_value} against #{stepdef}"
62
62
 
63
63
  if stepdef.compare_value =~ /.+\#\{[^\}]+\}.+/
64
- log.warn "Step definition has packed constant #{stepdef.compare_value}"
64
+ log.warn "Step definition still has a unpacked constant #{stepdef.compare_value}"
65
65
  else
66
- if %r{#{stepdef.compare_value}}.match(step_value)
67
- return stepdef
68
- end
66
+ return stepdef if %r{#{stepdef.compare_value}}.match(step_value)
69
67
  end
70
68
  end
71
69
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  class StepDefinitionHandler < YARD::Handlers::Ruby::Legacy::Base
4
4
  #TODO: This needs to become language independent.
5
- MATCH = /^((When|Given|And|Then)\s*(\/[^\/]+\/).+)$/
5
+ MATCH = /^((When|Given|And|Then)\s*(\/.+\/)\s+do(?:\s\|.+\|)?\s*)$/
6
6
  handles MATCH
7
7
 
8
8
  @@unique_name = 0
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-in-the-yard
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
- - 2
10
- version: 1.5.2
9
+ - 3
10
+ version: 1.5.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Franklin Webber