-
Notifications
You must be signed in to change notification settings - Fork 0
/
xml-extractor_spec.rb
32 lines (26 loc) · 1.13 KB
/
xml-extractor_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# encoding: UTF-8
require 'spec_helper'
include Rosette::Extractors
describe XmlExtractor do
FIXTURE_MANIFEST.each_pair do |extractor_name, expected_results|
describe extractor_name do
let(:extractor) do
capitalized_name = Rosette::Core::StringUtils.camelize(extractor_name.to_s)
XmlExtractor.const_get("#{capitalized_name}Extractor").new
end
expected_results.each_pair do |expected_file, expected_phrases|
it "extracts phrases correctly from #{expected_file}" do
source_file = File.join(FIXTURE_DIR, expected_file)
extractor.extract_each_from(File.read(source_file)).each do |actual_phrase, line_number|
expected_phrase_index = expected_phrases.find_index { |phrase| phrase['meta_key'] == actual_phrase.meta_key }
expected_phrase = expected_phrases[expected_phrase_index]
expect(expected_phrase).to_not be_nil
expect(expected_phrase['key']).to eq(actual_phrase.key)
expected_phrases.delete_at(expected_phrase_index)
end
expect(expected_phrases).to be_empty
end
end
end
end
end