features/step_definitions/edtf_steps.rb in edtf-0.0.6 vs features/step_definitions/edtf_steps.rb in edtf-0.0.7
- old
+ new
@@ -10,11 +10,11 @@
Then /^the EDTF String should be "([^"]*)"$/i do |edtf|
@string.should == edtf
end
When /^I parse the string "([^"]*)"$/ do |string|
- @date = EDTF.parse(string)
+ @date = EDTF.parse!(string)
end
Then /^the year should be "([^"]*)"$/ do |year|
@date.year.should == year.to_i
end
@@ -70,11 +70,15 @@
Then /^the interval should include the date "([^"]*)"$/ do |date|
@date.should include(Date.parse(date))
end
+Then /^the interval should cover the date "([^"]*)"$/ do |date|
+ @date.should cover(Date.parse(date))
+end
+
Then /^the date should be uncertain\? "([^"]*)"$/ do |arg1|
@date.uncertain?.should == !!(arg1 =~ /y(es)?/i)
end
Then /^the year should be uncertain\? "([^"]*)"$/ do |arg1|
@@ -106,6 +110,36 @@
end
Then /^the unspecified string code be "([^"]*)"$/ do |arg1|
@date.unspecified.to_s.should == arg1
+end
+
+When /^I parse the following strings an error should be raised:$/ do |table|
+ table.raw.each do |row|
+ expect { Date.edtf!(row[0]) }.to raise_error(ArgumentError)
+ end
+end
+
+When /^the year is uncertain: "([^"]*)"$/ do |arg1|
+ @date.uncertain!(:year) if arg1 =~ /y(es)?/i
+end
+
+When /^the month is uncertain: "([^"]*)"$/ do |arg1|
+ @date.uncertain!(:month) if arg1 =~ /y(es)?/i
+end
+
+When /^the day is uncertain: "([^"]*)"$/ do |arg1|
+ @date.uncertain!(:day) if arg1 =~ /y(es)?/i
+end
+
+When /^the year is approximate: "([^"]*)"$/ do |arg1|
+ @date.approximate!(:year) if arg1 =~ /y(es)?/i
+end
+
+When /^the month is approximate: "([^"]*)"$/ do |arg1|
+ @date.approximate!(:month) if arg1 =~ /y(es)?/i
+end
+
+When /^the day is approximate "([^"]*)"$/ do |arg1|
+ @date.approximate!(:day) if arg1 =~ /y(es)?/i
end