scholar_steps.rb 1.07 KB
Newer Older
Sylvester Keil's avatar
Sylvester Keil committed
1

Sylvester Keil's avatar
Sylvester Keil committed
2
Given(/^I have a "([^"]*)" directory/) do |dir|
3 4 5
  FileUtils.mkdir(dir)
end

Sylvester Keil's avatar
Sylvester Keil committed
6
Given(/^I have a (?:page|file) "([^"]*)":$/) do |file, string|
Sylvester Keil's avatar
Sylvester Keil committed
7
  File.open(file, 'w') do |f|
Sylvester Keil's avatar
Sylvester Keil committed
8
    f.write(string)
Sylvester Keil's avatar
Sylvester Keil committed
9 10
  end
end
Sylvester Keil's avatar
Sylvester Keil committed
11

Sylvester Keil's avatar
Sylvester Keil committed
12
Given(/^I have a scholar configuration with:$/) do |table|
Sylvester Keil's avatar
Sylvester Keil committed
13
  File.open('_config.yml', 'a') do |f|
14 15 16 17 18 19 20
    f.write("scholar:\n")
    table.hashes.each do |row|
      f.write("  #{row["key"]}: #{row["value"]}\n")
    end
  end
end

21 22 23 24 25 26 27 28
Given(/^I have the following BibTeX options:$/) do |table|
  File.open('_config.yml', 'a') do |f|
    f.write("  bibtex_options:\n")
    table.hashes.each do |row|
      f.write("    #{row["key"]}: #{row["value"]}\n")
    end
  end
end
29

Sylvester Keil's avatar
Sylvester Keil committed
30 31 32 33 34 35 36 37 38
Given(/^I have the following BibTeX filters:$/) do |table|
  File.open('_config.yml', 'a') do |f|
    f.write("  bibtex_filters:\n")
    table.raw.flatten.each do |row|
      f.write("    - #{row}\n")
    end
  end
end

Sylvester Keil's avatar
Sylvester Keil committed
39
Then(/^"(.*)" should come before "(.*)" in "(.*)"$/) do |p1, p2, file|
Sylvester Keil's avatar
Sylvester Keil committed
40
  data = File.open(file).readlines.join('')
Sylvester Keil's avatar
Sylvester Keil committed
41

Sylvester Keil's avatar
Sylvester Keil committed
42 43 44 45 46 47
  m1 = data.match(p1)
  m2 = data.match(p2)

  assert m1.offset(0)[0] < m2.offset(0)[0]
end