Sha256: fb17764c22ab2dc8190ac1ab5e677c493699232e479f9065dcc3c0ae10972a43

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

When /^I (?:have )?parsed? the XML:$/ do |string|
  @doc = Dozuki::XML.parse(string)
end

When /^I call "([^"]*)" on the document$/ do |code|
  begin
    @result = @doc.instance_eval(code)
  rescue StandardError => e
    @error = e
  end
end

When /^I call "([^"]*)" on the document with a block$/ do |code|
  @result = @doc.instance_eval(code + "{|res| res}") # returns the variable passed to the block
end

When /^I call "([^"]*)" on the document and collect the results$/ do |code|
  @results = @doc.instance_eval("results = [];" + code + "{|res| results << res}; results;")
end

Then /^the (?:result|block parameter) should be a "([^"]*)"$/ do |type|
  @result.class.to_s.should == type
end

Then /^the (?:result|parameter) should have (\d+) elements$/ do |count|
  @result.children.select{|e| e.is_a?(Nokogiri::XML::Element)}.count.should == count.to_i
end

Then /^the result should have the (.*) "([^"]*)"$/ do |method, value|
  @result.send(method).should == value
end

Then /^the results should contain a node with the text "([^"]*)"$/ do |text|
  @results.any?{|n| n.text == text}.should be_true
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dozuki-0.4.0 features/steps/xml_steps.rb
dozuki-0.3.0 features/steps/xml_steps.rb
dozuki-0.2.0 features/steps/xml_steps.rb
dozuki-0.1.0 features/steps/xml_steps.rb
dozuki-0.0.3 features/steps/xml_steps.rb