Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replace Timecop dependency with a simple stub

  • Loading branch information...
commit c2dac5bc62c8d5fa19473fdc9d67211a04c93c7a 1 parent 95961d5
@jasoncodes jasoncodes authored
View
1  Gemfile
@@ -2,5 +2,4 @@ source 'http://rubygems.org'
gemspec
-gem 'timecop', :require => false
gem 'generator_spec', :require => false
View
1  gemfiles/rails3_1.gemfile
@@ -2,7 +2,6 @@
source "http://rubygems.org"
-gem "timecop", :require=>false
gem "generator_spec", :require=>false
gem "rails", "~> 3.1.0"
View
1  gemfiles/rails3_2.gemfile
@@ -2,7 +2,6 @@
source "http://rubygems.org"
-gem "timecop", :require=>false
gem "generator_spec", :require=>false
gem "rails", "~> 3.2.0"
View
1  gemfiles/rails4_0.gemfile
@@ -2,7 +2,6 @@
source "http://rubygems.org"
-gem "timecop", :require=>false
gem "generator_spec", :require=>false
gem "rails", "~> 4.0.2"
View
36 spec/lib/generators/postmarkdown/post_generator_spec.rb
@@ -14,35 +14,35 @@ module Postmarkdown
context 'with the slug parameter' do
it 'creates a file for the slug and the current date' do
- Timecop.freeze(Time.utc(2012, 1, 1, 10, 20, 30)) do
- run_generator %w(test-post)
+ Time.zone.stub(:now).and_return Time.utc(2012, 1, 1, 10, 20, 30)
- Dir.glob('tmp/app/posts/*').should == ['tmp/app/posts/2012-01-01-102030-test-post.markdown']
+ run_generator %w(test-post)
- Post.all.count.should == 1
+ Dir.glob('tmp/app/posts/*').should == ['tmp/app/posts/2012-01-01-102030-test-post.markdown']
- post = Post.first
- post.slug.should == 'test-post'
- post.date.should == Date.parse('2012-01-01')
- post.title.should == 'Test post'
- end
+ Post.all.count.should == 1
+
+ post = Post.first
+ post.slug.should == 'test-post'
+ post.date.should == Date.parse('2012-01-01')
+ post.title.should == 'Test post'
end
end
context 'with the slug parameter including an underscore' do
it 'creates the correct file and sets the right values' do
- Timecop.freeze(Time.utc(2012, 1, 1, 10, 20, 30)) do
- run_generator %w(test-post_with_underscores)
+ Time.zone.stub(:now).and_return Time.utc(2012, 1, 1, 10, 20, 30)
- Dir.glob('tmp/app/posts/*').should == ['tmp/app/posts/2012-01-01-102030-test-post_with_underscores.markdown']
+ run_generator %w(test-post_with_underscores)
- Post.all.count.should == 1
+ Dir.glob('tmp/app/posts/*').should == ['tmp/app/posts/2012-01-01-102030-test-post_with_underscores.markdown']
- post = Post.first
- post.slug.should == 'test-post_with_underscores'
- post.date.should == Date.parse('2012-01-01')
- post.title.should == 'Test post_with_underscores'
- end
+ Post.all.count.should == 1
+
+ post = Post.first
+ post.slug.should == 'test-post_with_underscores'
+ post.date.should == Date.parse('2012-01-01')
+ post.title.should == 'Test post_with_underscores'
end
end
View
2  spec/spec_helper.rb
@@ -14,7 +14,6 @@
require 'rspec/rails'
require 'capybara/rails'
-require 'timecop'
require 'generator_spec/test_case'
Dir[File.expand_path('lib/generators/postmarkdown/*.rb')].each { |f| require f }
@@ -26,7 +25,6 @@
config.order = :random
config.after do
- Timecop.return
FileUtils.rm_rf('spec/tmp/app/posts/.')
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.