timecop-console 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +3 -0
- data/README.rdoc +29 -26
- data/Rakefile +15 -0
- data/app/controllers/timecop_console/main_controller.rb +39 -0
- data/config/routes.rb +4 -0
- data/lib/timecop_console/controller_methods.rb +34 -0
- data/lib/timecop_console/engine.rb +9 -0
- data/lib/timecop_console/version.rb +17 -0
- data/lib/timecop_console.rb +6 -5
- data/spec/controllers/main_controller_spec.rb +33 -0
- data/spec/controllers/sample_controller_spec.rb +33 -0
- data/spec/dummy_app/Gemfile +5 -0
- data/spec/dummy_app/Gemfile.lock +93 -0
- data/spec/dummy_app/README.rdoc +261 -0
- data/spec/dummy_app/Rakefile +7 -0
- data/spec/dummy_app/app/assets/images/rails.png +0 -0
- data/spec/dummy_app/app/assets/javascripts/application.js +13 -0
- data/spec/dummy_app/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy_app/app/controllers/application_controller.rb +3 -0
- data/spec/dummy_app/app/controllers/sample_controller.rb +2 -0
- data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_app/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy_app/config/application.rb +65 -0
- data/spec/dummy_app/config/boot.rb +6 -0
- data/spec/dummy_app/config/environment.rb +5 -0
- data/spec/dummy_app/config/environments/development.rb +26 -0
- data/spec/dummy_app/config/environments/production.rb +51 -0
- data/spec/dummy_app/config/environments/test.rb +35 -0
- data/spec/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_app/config/initializers/inflections.rb +15 -0
- data/spec/dummy_app/config/initializers/mime_types.rb +5 -0
- data/spec/dummy_app/config/initializers/secret_token.rb +7 -0
- data/spec/dummy_app/config/initializers/session_store.rb +8 -0
- data/spec/dummy_app/config/initializers/wrap_parameters.rb +10 -0
- data/spec/dummy_app/config/locales/en.yml +5 -0
- data/spec/dummy_app/config/routes.rb +3 -0
- data/spec/dummy_app/config.ru +4 -0
- data/spec/dummy_app/db/seeds.rb +7 -0
- data/spec/dummy_app/doc/README_FOR_APP +2 -0
- data/spec/dummy_app/log/development.log +91 -0
- data/spec/dummy_app/log/test.log +232 -0
- data/spec/dummy_app/public/404.html +26 -0
- data/spec/dummy_app/public/422.html +26 -0
- data/spec/dummy_app/public/500.html +25 -0
- data/spec/dummy_app/public/favicon.ico +0 -0
- data/spec/dummy_app/public/index.html +241 -0
- data/spec/dummy_app/public/robots.txt +5 -0
- data/spec/dummy_app/script/rails +6 -0
- data/spec/spec_helper.rb +10 -0
- metadata +152 -58
- data/VERSION.yml +0 -4
- data/lib/timecop-console/controllers/timecop_controller.rb +0 -21
- data/lib/timecop-console/routes.rb +0 -16
- data/lib/timecop-console/timecop_controller_methods.rb +0 -33
- data/test/geminstaller.yml +0 -6
- data/test/test_helper.rb +0 -9
- data/test/timecop_console_test.rb +0 -29
metadata
CHANGED
@@ -1,75 +1,169 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: timecop-console
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- John Trupiano
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
date: 2012-11-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &70274154688200 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
17
22
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements:
|
20
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70274154688200
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: timecop
|
27
|
+
requirement: &70274154687580 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
21
30
|
- - ~>
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
24
|
-
|
25
|
-
|
26
|
-
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.5'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70274154687580
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec-rails
|
38
|
+
requirement: &70274154687200 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70274154687200
|
47
|
+
description: TimecopConsole manipulates Time.now using Timecop gem.
|
48
|
+
email:
|
49
|
+
- jtrupiano@gmail.com
|
27
50
|
executables: []
|
28
|
-
|
29
51
|
extensions: []
|
30
|
-
|
31
|
-
|
32
|
-
-
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- Gemfile
|
33
55
|
- LICENSE
|
34
|
-
files:
|
35
56
|
- README.rdoc
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
- lib/
|
40
|
-
- lib/
|
41
|
-
- lib/
|
57
|
+
- Rakefile
|
58
|
+
- app/controllers/timecop_console/main_controller.rb
|
59
|
+
- config/routes.rb
|
60
|
+
- lib/timecop_console/controller_methods.rb
|
61
|
+
- lib/timecop_console/engine.rb
|
62
|
+
- lib/timecop_console/version.rb
|
42
63
|
- lib/timecop_console.rb
|
43
|
-
-
|
44
|
-
-
|
45
|
-
-
|
46
|
-
-
|
47
|
-
|
48
|
-
|
64
|
+
- spec/controllers/main_controller_spec.rb
|
65
|
+
- spec/controllers/sample_controller_spec.rb
|
66
|
+
- spec/dummy_app/app/assets/images/rails.png
|
67
|
+
- spec/dummy_app/app/assets/javascripts/application.js
|
68
|
+
- spec/dummy_app/app/assets/stylesheets/application.css
|
69
|
+
- spec/dummy_app/app/controllers/application_controller.rb
|
70
|
+
- spec/dummy_app/app/controllers/sample_controller.rb
|
71
|
+
- spec/dummy_app/app/helpers/application_helper.rb
|
72
|
+
- spec/dummy_app/app/views/layouts/application.html.erb
|
73
|
+
- spec/dummy_app/config/application.rb
|
74
|
+
- spec/dummy_app/config/boot.rb
|
75
|
+
- spec/dummy_app/config/environment.rb
|
76
|
+
- spec/dummy_app/config/environments/development.rb
|
77
|
+
- spec/dummy_app/config/environments/production.rb
|
78
|
+
- spec/dummy_app/config/environments/test.rb
|
79
|
+
- spec/dummy_app/config/initializers/backtrace_silencers.rb
|
80
|
+
- spec/dummy_app/config/initializers/inflections.rb
|
81
|
+
- spec/dummy_app/config/initializers/mime_types.rb
|
82
|
+
- spec/dummy_app/config/initializers/secret_token.rb
|
83
|
+
- spec/dummy_app/config/initializers/session_store.rb
|
84
|
+
- spec/dummy_app/config/initializers/wrap_parameters.rb
|
85
|
+
- spec/dummy_app/config/locales/en.yml
|
86
|
+
- spec/dummy_app/config/routes.rb
|
87
|
+
- spec/dummy_app/config.ru
|
88
|
+
- spec/dummy_app/db/seeds.rb
|
89
|
+
- spec/dummy_app/doc/README_FOR_APP
|
90
|
+
- spec/dummy_app/Gemfile
|
91
|
+
- spec/dummy_app/Gemfile.lock
|
92
|
+
- spec/dummy_app/log/development.log
|
93
|
+
- spec/dummy_app/log/test.log
|
94
|
+
- spec/dummy_app/public/404.html
|
95
|
+
- spec/dummy_app/public/422.html
|
96
|
+
- spec/dummy_app/public/500.html
|
97
|
+
- spec/dummy_app/public/favicon.ico
|
98
|
+
- spec/dummy_app/public/index.html
|
99
|
+
- spec/dummy_app/public/robots.txt
|
100
|
+
- spec/dummy_app/Rakefile
|
101
|
+
- spec/dummy_app/README.rdoc
|
102
|
+
- spec/dummy_app/script/rails
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
homepage: https://github.com/jtrupiano/timecop-console
|
105
|
+
licenses: []
|
49
106
|
post_install_message:
|
50
|
-
rdoc_options:
|
51
|
-
|
52
|
-
- --charset=UTF-8
|
53
|
-
require_paths:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
54
109
|
- lib
|
55
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ! '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 1.3.6
|
67
122
|
requirements: []
|
68
|
-
|
69
|
-
|
70
|
-
rubygems_version: 1.3.1
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 1.8.17
|
71
125
|
signing_key:
|
72
|
-
specification_version:
|
73
|
-
summary: Expose Timecop's capabilities to the UI in your rails app, allowing QA to
|
74
|
-
|
75
|
-
|
126
|
+
specification_version: 3
|
127
|
+
summary: Expose Timecop's capabilities to the UI in your rails app, allowing QA to
|
128
|
+
take advantage of it.
|
129
|
+
test_files:
|
130
|
+
- spec/controllers/main_controller_spec.rb
|
131
|
+
- spec/controllers/sample_controller_spec.rb
|
132
|
+
- spec/dummy_app/app/assets/images/rails.png
|
133
|
+
- spec/dummy_app/app/assets/javascripts/application.js
|
134
|
+
- spec/dummy_app/app/assets/stylesheets/application.css
|
135
|
+
- spec/dummy_app/app/controllers/application_controller.rb
|
136
|
+
- spec/dummy_app/app/controllers/sample_controller.rb
|
137
|
+
- spec/dummy_app/app/helpers/application_helper.rb
|
138
|
+
- spec/dummy_app/app/views/layouts/application.html.erb
|
139
|
+
- spec/dummy_app/config/application.rb
|
140
|
+
- spec/dummy_app/config/boot.rb
|
141
|
+
- spec/dummy_app/config/environment.rb
|
142
|
+
- spec/dummy_app/config/environments/development.rb
|
143
|
+
- spec/dummy_app/config/environments/production.rb
|
144
|
+
- spec/dummy_app/config/environments/test.rb
|
145
|
+
- spec/dummy_app/config/initializers/backtrace_silencers.rb
|
146
|
+
- spec/dummy_app/config/initializers/inflections.rb
|
147
|
+
- spec/dummy_app/config/initializers/mime_types.rb
|
148
|
+
- spec/dummy_app/config/initializers/secret_token.rb
|
149
|
+
- spec/dummy_app/config/initializers/session_store.rb
|
150
|
+
- spec/dummy_app/config/initializers/wrap_parameters.rb
|
151
|
+
- spec/dummy_app/config/locales/en.yml
|
152
|
+
- spec/dummy_app/config/routes.rb
|
153
|
+
- spec/dummy_app/config.ru
|
154
|
+
- spec/dummy_app/db/seeds.rb
|
155
|
+
- spec/dummy_app/doc/README_FOR_APP
|
156
|
+
- spec/dummy_app/Gemfile
|
157
|
+
- spec/dummy_app/Gemfile.lock
|
158
|
+
- spec/dummy_app/log/development.log
|
159
|
+
- spec/dummy_app/log/test.log
|
160
|
+
- spec/dummy_app/public/404.html
|
161
|
+
- spec/dummy_app/public/422.html
|
162
|
+
- spec/dummy_app/public/500.html
|
163
|
+
- spec/dummy_app/public/favicon.ico
|
164
|
+
- spec/dummy_app/public/index.html
|
165
|
+
- spec/dummy_app/public/robots.txt
|
166
|
+
- spec/dummy_app/Rakefile
|
167
|
+
- spec/dummy_app/README.rdoc
|
168
|
+
- spec/dummy_app/script/rails
|
169
|
+
- spec/spec_helper.rb
|
data/VERSION.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
|
2
|
-
# Because we want to use the session, we need to inherit from ApplicationController
|
3
|
-
# This is currently very brittle....need to think this one through further.
|
4
|
-
require_dependency 'application' if Object.const_defined?(:RAILS_ENV)
|
5
|
-
class TimecopController < ApplicationController
|
6
|
-
|
7
|
-
# verify :method => 'post'
|
8
|
-
skip_filter :handle_timecop_offset
|
9
|
-
|
10
|
-
def update
|
11
|
-
year, month, day, hour, min, sec = params[:year], params[:month], params[:day], params[:hour], params[:min], params[:sec]
|
12
|
-
session[:timecop_adjusted_time] = Time.local(year, month, day, hour, min, sec)
|
13
|
-
render :status => 200, :nothing => true
|
14
|
-
end
|
15
|
-
|
16
|
-
def reset
|
17
|
-
session[:timecop_adjusted_time] = nil
|
18
|
-
render :status => 200, :nothing => true
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module ActionController
|
2
|
-
module Routing #:nodoc:
|
3
|
-
class RouteSet #:nodoc:
|
4
|
-
alias_method :draw_without_timecop_routes, :draw
|
5
|
-
def draw
|
6
|
-
draw_without_timecop_routes do |map|
|
7
|
-
|
8
|
-
map.update_time '/timecop/update', :controller => 'timecop', :action => 'update'
|
9
|
-
map.reset_time '/timecop/reset', :controller => 'timecop', :action => 'reset'
|
10
|
-
|
11
|
-
yield map if block_given?
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# Defines extensions applied to ActionController::Base to support our time travel
|
2
|
-
module TimecopControllerMethods
|
3
|
-
|
4
|
-
def self.included(base)
|
5
|
-
base.class_eval do
|
6
|
-
around_filter :handle_timecop_offset
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
# to be used as an around_filter
|
11
|
-
def handle_timecop_offset
|
12
|
-
# Establish now
|
13
|
-
if !session[:timecop_adjusted_time].nil?
|
14
|
-
puts "***** Time traveling to #{session[:timecop_adjusted_time].to_s}"
|
15
|
-
Timecop.travel(session[:timecop_adjusted_time])
|
16
|
-
else
|
17
|
-
Timecop.return
|
18
|
-
end
|
19
|
-
|
20
|
-
# Run the intended action
|
21
|
-
yield
|
22
|
-
|
23
|
-
# we want to continue to slide time forward, even if it's only 3 seconds at a time.
|
24
|
-
# this ensures that subsequent calls during the same "time travel" actually pass time
|
25
|
-
if !session[:timecop_adjusted_time].nil?
|
26
|
-
puts "====== Resetting session to: #{Time.now + 3}"
|
27
|
-
session[:timecop_adjusted_time] = Time.now + 3 # slide it forward a couple of seconds
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
private :handle_timecop_offset
|
32
|
-
|
33
|
-
end
|
data/test/geminstaller.yml
DELETED
data/test/test_helper.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'actionpack'
|
3
|
-
require 'action_controller'
|
4
|
-
# require 'action_controller/assertions/routing_assertions'
|
5
|
-
|
6
|
-
require "timecop-console/timecop_controller_methods"
|
7
|
-
|
8
|
-
# We need this defined for the session key
|
9
|
-
class ApplicationController < ActionController::Base
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
require 'timecop_console'
|
14
|
-
class SampleController < ActionController::Base
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
class TimecopConsoleTest < Test::Unit::TestCase
|
19
|
-
|
20
|
-
should "add around_filter to SampleController" do
|
21
|
-
assert SampleController.around_filter.any?{|filter| filter.around? && filter.method == :handle_timecop_offset}, "before_filter should have been applied"
|
22
|
-
end
|
23
|
-
|
24
|
-
# should "recognize the new routes" do
|
25
|
-
# assert_recognizes({:controller => 'timecop', :action => 'update'})
|
26
|
-
# assert_recognizes({:controller => 'timecop', :action => 'reset'})
|
27
|
-
# end
|
28
|
-
|
29
|
-
end
|