Skip to content

Commit

Permalink
Adds feature for braced strings issue
Browse files Browse the repository at this point in the history
  • Loading branch information
inukshuk committed Jun 9, 2011
1 parent c899093 commit 5515e8f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
42 changes: 42 additions & 0 deletions features/issues/braced_strings.feature
@@ -0,0 +1,42 @@
Feature: BibTeX Braced Strings
As a hacker who works with bibliographies
I want to be able to parse BibTeX files containing string definitions using braced expressions
Because applications such as BibDesk produce that format

Scenario: A BibTeX file with string assignments
When I parse the following file:
"""
Simple strings:
@string{ foo1 = {foo} }
@string{ foo2 = {foo}}
@string{ foo3 ={foo}}
@string{foo4={foo}}
@string{ foo5 = {"foo" bar} }
@string{ foo6 = {"foo" bar{"}} }
@string{ foo7 = {"foo" bar\} foo} }
@string{ foo8 = {"foo" bar\{ foo} }
Compound strings:
@string{ foo8 = foo1 }
@string{ foo9 = foo1 # {bar} }
@string{ foo10 = {foo } # {bar} }
"""
Then my bibliography should contain 9 strings
And my bibliography should contain these strings:
| value |
| foo |
| foo |
| foo |
| foo |
| "foo" bar |
| "foo" bar{"} |
| "foo" bar\} foo |
| "foo" bar\{ foo |
| foo |
| foo1 # "bar" |
| "foo " # "bar" |
When I replace all strings in my bibliography
Then the string "foo9" should be "foobar"
And the string "foo10" should be "foo bar"

10 changes: 9 additions & 1 deletion features/step_definitions/bibtex_steps.rb
Expand Up @@ -71,10 +71,18 @@
end


Then /^my bibliography should contain (\d+) (\w+)$/ do |count, type|
assert_equal count.to_i, @bibliography.q("@#{type.chomp!('s')}").length
end

Then /^my bibliography should contain (\d+) (\w+) published in (\d+)$/ do |count, type, year|
assert_equal @bibliography.q("@#{type.chomp!('s')}[year=#{year}]").length, count.to_i
assert_equal count.to_i, @bibliography.q("@#{type.chomp!('s')}[year=#{year}]").length
end

Then /^my bibliography should contain an? (\w+) with id "([^"]*)"$/ do |type, id|
assert_equal @bibliography[id.to_sym].type, type.to_sym
end

Then /^the string "([^"]*)" should be "([^"]*)"$/ do |key, value|
assert_equal value, @bibliography.strings[key].to_s
end

0 comments on commit 5515e8f

Please sign in to comment.