features/step_definitions/edtf_steps.rb in edtf-0.0.3 vs features/step_definitions/edtf_steps.rb in edtf-0.0.4
- old
+ new
@@ -1,80 +1,98 @@
+Given /^the date "([^"]*)"(?: with precision set to "([^"]*)")?$/ do |date, precision|
+ @date = Date.parse(date)
+ @date.precision = precision unless precision.nil?
+end
+
+When /^I convert the date$/ do
+ @string = @date.edtf
+end
+
+Then /^the EDTF String should be "([^"]*)"$/i do |edtf|
+ @string.should == edtf
+end
+
When /^I parse the string "([^"]*)"$/ do |string|
- @edtf = EDTF.parse(string)
+ @date = EDTF.parse(string)
end
Then /^the year should be "([^"]*)"$/ do |year|
- @edtf.year.should == year.to_i
+ @date.year.should == year.to_i
end
Then /^the month should be "([^"]*)"$/ do |month|
- @edtf.month.should == month.to_i
+ @date.month.should == month.to_i
end
Then /^the day should be "([^"]*)"$/ do |day|
- @edtf.day.should == day.to_i
+ @date.day.should == day.to_i
end
Then /^the hours should be "([^"]*)"$/ do |hours|
- @edtf.hour.should == hours.to_i
+ @date.hour.should == hours.to_i
end
Then /^the year should be "([^"]*)" \(UTC\)$/ do |year|
- @edtf.to_time.utc.year.should == year.to_i
+ @date.to_time.utc.year.should == year.to_i
end
Then /^the month should be "([^"]*)" \(UTC\)$/ do |month|
- @edtf.to_time.utc.month.should == month.to_i
+ @date.to_time.utc.month.should == month.to_i
end
Then /^the day should be "([^"]*)" \(UTC\)$/ do |day|
- @edtf.to_time.utc.day.should == day.to_i
+ @date.to_time.utc.day.should == day.to_i
end
Then /^the hours should be "([^"]*)" \(UTC\)$/ do |hours|
- @edtf.to_time.utc.hour.should == hours.to_i
+ @date.to_time.utc.hour.should == hours.to_i
end
Then /^the minutes should be "([^"]*)"$/ do |minutes|
- @edtf.min.should == minutes.to_i
+ @date.min.should == minutes.to_i
end
Then /^the seconds should be "([^"]*)"$/ do |seconds|
- @edtf.sec.should == seconds.to_i
+ @date.sec.should == seconds.to_i
end
Then /^the duration should range from "([^"]*)" to "([^"]*)"$/ do |from,to|
- [@edtf.begin.year.to_s, @edtf.end.year.to_s].should == [from,to]
+ [@date.begin.year.to_s, @date.end.year.to_s].should == [from,to]
end
Then /^the interval should start at "([^"]*)"$/ do |date|
- @edtf.begin.to_s.should == date
+ @date.begin.to_s.should == date
end
Then /^the interval should end at "([^"]*)"$/ do |date|
- @edtf.end.to_s.should == date
+ @date.end.to_s.should == date
end
+Then /^the interval should include the date "([^"]*)"$/ do |date|
+ @date.should include(Date.parse(date))
+end
+
+
Then /^the date should be uncertain\? "([^"]*)"$/ do |arg1|
- @edtf.uncertain?.should == !!(arg1 =~ /y(es)?/i)
+ @date.uncertain?.should == !!(arg1 =~ /y(es)?/i)
end
Then /^the year should be uncertain\? "([^"]*)"$/ do |arg1|
- @edtf.uncertain?(:year).should == !!(arg1 =~ /y(es)?/i)
+ @date.uncertain?(:year).should == !!(arg1 =~ /y(es)?/i)
end
Then /^the month should be uncertain\? "([^"]*)"$/ do |arg1|
- @edtf.uncertain?(:month).should == !!(arg1 =~ /y(es)?/i)
+ @date.uncertain?(:month).should == !!(arg1 =~ /y(es)?/i)
end
Then /^the day should be uncertain\? "([^"]*)"$/ do |arg1|
- @edtf.uncertain?(:day).should == !!(arg1 =~ /y(es)?/i)
+ @date.uncertain?(:day).should == !!(arg1 =~ /y(es)?/i)
end
Then /^the date should be approximate\? "([^"]*)"$/ do |arg1|
- @edtf.approximate?.should == !!(arg1 =~ /y(es)?/i)
+ @date.approximate?.should == !!(arg1 =~ /y(es)?/i)
end
Then /^the unspecified string code be "([^"]*)"$/ do |arg1|
- @edtf.unspecified.to_s.should == arg1
+ @date.unspecified.to_s.should == arg1
end