Skip to content

Commit

Permalink
Fixed parser so it parses attachment 1 in [cucumber#177 state:open]
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Jan 30, 2009
1 parent 136361d commit 24d399c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 25 deletions.
2 changes: 2 additions & 0 deletions Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Stock.java
examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Trader.java
examples/jbehave/src/main/java/cukes/jbehave/examples/trader/persistence/TraderPersister.java
examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java
examples/jbehave/target/maven-archiver/pom.properties
examples/selenium/Rakefile
examples/selenium/features/search.feature
examples/selenium/features/step_definitons/stories_steps.rb
Expand All @@ -137,6 +138,7 @@ examples/test_unit/features/test_unit.feature
examples/tickets/Rakefile
examples/tickets/cucumber.yml
examples/tickets/features/172.feature
examples/tickets/features/177-1.feature
examples/tickets/features/180.feature
examples/tickets/features/lib/eatting_machine.rb
examples/tickets/features/lib/pantry.rb
Expand Down
29 changes: 29 additions & 0 deletions examples/tickets/features/177-1.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Users want to know that nobody can masquerade as them. We want to extend trust
only to visitors who present the appropriate credentials. Everyone wants this
identity verification to be as secure and convenient as possible.

Feature: Logging in
As an anonymous user with an account
I want to log in to my account
So that I can be myself

#
# Log in: get form
#
Scenario: Anonymous user can get a login form.
Given I am logged out
When I go to "/login"
Then I should be at the "sessions/new" page

#
# Log in successfully, but don't remember me
#
Scenario: Anonymous user can log in
Given an "activated" user named "reggie" exists
And I am logged out
When I go to "/login"
And I fill in "Login" with "reggie"
And I fill in "Password" with "password"
And I press "Log in"
Then I should be at the "dashboard/index" page

26 changes: 5 additions & 21 deletions lib/cucumber/parser/feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ def comment_line
elements[0]
end

def white
elements[1]
end
end

module Comment1
Expand All @@ -358,21 +361,7 @@ def _nt_comment
r2 = _nt_comment_line
s1 << r2
if r2
s3, i3 = [], index
loop do
r4 = _nt_eol
if r4
s3 << r4
else
break
end
end
if s3.empty?
self.index = i3
r3 = nil
else
r3 = SyntaxNode.new(input, i3...index, s3)
end
r3 = _nt_white
s1 << r3
end
if s1.last
Expand Down Expand Up @@ -1206,12 +1195,7 @@ def _nt_line_to_eol
break
end
end
if s0.empty?
self.index = i0
r0 = nil
else
r0 = SyntaxNode.new(input, i0...index, s0)
end
r0 = SyntaxNode.new(input, i0...index, s0)

node_cache[:line_to_eol][start_index] = r0

Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/parser/feature.tt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module Cucumber
end

rule comment
(comment_line eol+)* {
(comment_line white)* {
def build
Ast::Comment.new(text_value)
end
Expand Down Expand Up @@ -137,7 +137,7 @@ module Cucumber
end

rule line_to_eol
(!eol .)+
(!eol .)*
end

rule py_string
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/parser/treetop_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def parse_file(file)
class SyntaxError < StandardError
def initialize(parser, file, line_offset)
tf = parser.terminal_failures
expected = tf.size == 1 ? tf[0].expected_string.inspect : "one of #{tf.map{|f| f.expected_string}.uniq*', '}"
expected = tf.size == 1 ? tf[0].expected_string.inspect : "one of #{tf.map{|f| f.expected_string.inspect}.uniq*', '}"
line = parser.failure_line + line_offset
message = "#{file}:#{line}:#{parser.failure_column}: Parse error, expected #{expected}."
super(message)
Expand Down
2 changes: 1 addition & 1 deletion spec/cucumber/parser/feature_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def parse_example_file(file)
@st4
Scenario: Second}).to_sexp.should ==
[:feature, "Feature: hi",
[:comment, "# FC\n"],
[:comment, "# FC\n "],
[:tag, "ft"],
[:scenario, 6, 'Scenario:', 'First',
[:tag, "st1"], [:tag, "st2"],
Expand Down

0 comments on commit 24d399c

Please sign in to comment.