Permalink
Browse files

We wanna continue to support rails-2.*, plus rails-3.* generate sligh…

…tly diff artifacts.
  • Loading branch information...
1 parent b5a4c98 commit 08b843d3bc3b9b3515e4c5a14da546e1ea120e84 @ngty committed Nov 9, 2010
@@ -0,0 +1,17 @@
+class CrossStubGenerator < Rails::Generator::Base
+
+ def manifest
+ record do |m|
+ m.file 'config/initializers/cross-stub.rb', 'config/initializers/cross-stub.rb'
+ m.file 'features/support/cross-stub.rb', 'features/support/cross-stub.rb'
+ m.gsub_file 'config/environments/cucumber.rb', /\z/, "config.gem 'cross-stub', :lib => false, :version => '>=0.2.4' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cross-stub'))\n"
+ end
+ end
+
+ protected
+
+ def banner
+ "Usage: #{$0} cross_stub"
+ end
+
+end
@@ -1,9 +1,8 @@
class CrossStubGenerator < Rails::Generators::Base
source_root File.expand_path("../templates", __FILE__)
- def install_cross_stub
+ def generate
copy_file 'config/initializers/cross-stub.rb', 'config/initializers/cross-stub.rb'
copy_file 'features/support/cross-stub.rb', 'features/support/cross-stub.rb'
- gsub_file 'config/environments/cucumber.rb', /\z/, "config.gem 'cross-stub', :version => '>=0.2.0'\n"
end
end
@@ -0,0 +1,13 @@
+if Rails.env.test?
+ ActionDispatch::Callbacks.before do
+ # /////////////////////////////////////////////////////////////////////////////////
+ # NOTE: By default, we use file-based cache store for cross-stub. Alternatively,
+ # u may wanna try out the other cache stores. Adding new cache store support is
+ # super easy, w.r.t actual implementation & testing, just drop me a note at
+ # http://github.com/ngty/cross-stub & i'll do it for u, of course FOC lah !!
+ # /////////////////////////////////////////////////////////////////////////////////
+ #CrossStub.refresh :redis => 'localhost:6379/xstub.cache' # requires *redis* gem
+ #CrossStub.refresh :memcache => 'localhost:11211/xstub.cache' # requires *memcache-client* gem
+ CrossStub.refresh :file => Rails.root.join('tmp', 'crossstub.cache')
+ end
+end
@@ -0,0 +1,17 @@
+require 'cross-stub'
+
+Before do
+ # /////////////////////////////////////////////////////////////////////////////////
+ # NOTE: By default, we use file-based cache store for cross-stub. Alternatively,
+ # u may wanna try out the other cache stores. Adding new cache store support is
+ # super easy, w.r.t actual implementation & testing, just drop me a note at
+ # http://github.com/ngty/cross-stub & i'll do it for u, of course FOC lah !!
+ # /////////////////////////////////////////////////////////////////////////////////
+ #CrossStub.setup :redis => 'localhost:6379/xstub.cache' # requires *redis* gem
+ #CrossStub.setup :memcache => 'localhost:11211/xstub.cache' # requires *memcache-client* gem
+ CrossStub.setup :file => File.join(RAILS_ROOT, 'tmp', 'xstub.cache')
+end
+
+After do
+ CrossStub.clear
+end

0 comments on commit 08b843d

Please sign in to comment.