zedtux / cucumber-timecop Goto Github PK
View Code? Open in Web Editor NEWTimecop steps definition for Cucumber
Timecop steps definition for Cucumber
Could you release a new version of the gem that includes the changes of #3? Thanks!
Hello,
I am getting this failure:
And time is frozen at now # cucumber-timecop-0.0.5/lib/cucumber/timecop.rb:40
undefined method `now' for "BRT":String (NoMethodError)
/home/fornellas/local/gems/22/gems/chronic-0.10.2/lib/chronic/parser.rb:54:in `initialize'
/home/fornellas/local/gems/22/gems/chronic-0.10.2/lib/chronic.rb:90:in `new'
/home/fornellas/local/gems/22/gems/chronic-0.10.2/lib/chronic.rb:90:in `parse'
/home/fornellas/local/gems/22/gems/cucumber-timecop-0.0.5/lib/cucumber/timecop.rb:30:in `parse_time'
/home/fornellas/local/gems/22/gems/cucumber-timecop-0.0.5/lib/cucumber/timecop.rb:24:in `freeze_time_at'
/home/fornellas/local/gems/22/gems/cucumber-timecop-0.0.5/lib/cucumber/timecop.rb:41:in `block in <top (required)>'
It seems like, here is the cause:
https://github.com/zedtux/cucumber-timecop/blob/master/lib/cucumber/timecop.rb#L50
It sets Chronic.time_class to Time.now.zone in my case (no Rails). It tries to do something like:
https://github.com/mojombo/chronic/blob/master/lib/chronic.rb#L47
but it does not work:
irb(main):002:0> Chronic.time_class
=> Time
irb(main):003:0> Chronic.parse 'now'
=> 2015-10-13 12:33:55 -0300
irb(main):004:0> Chronic.time_class = Time.now.zone
=> "BRT"
irb(main):005:0> Chronic.parse 'now'
NoMethodError: undefined method `now' for "BRT":String
from /home/fornellas/local/gems/22/gems/chronic-0.10.2/lib/chronic/parser.rb:54:in `initialize'
from /home/fornellas/local/gems/22/gems/chronic-0.10.2/lib/chronic.rb:90:in `new'
from /home/fornellas/local/gems/22/gems/chronic-0.10.2/lib/chronic.rb:90:in `parse'
from (irb):5
from /opt/ruby22/bin/irb:11:in `<main>'
I guess the appropriate fix, for no Rails would be to maintain Chronic's original value:
https://github.com/mojombo/chronic/blob/master/lib/chronic.rb#L80
with:
Chronic.time_class = defined?(Rails) ? Time.zone : ::Time
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.