Class: Ripple::Generators::TestGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/rails/generators/ripple/test/test_generator.rb

Instance Method Summary collapse

Methods inherited from Base

source_root

Instance Method Details

#create_cucumber_fileObject

Cucumber



21
22
23
24
25
26
# File 'lib/rails/generators/ripple/test/test_generator.rb', line 21

def create_cucumber_file
  if File.directory?(Rails.root + "features/support")
    template 'test_server.rb', 'features/support/ripple.rb'
    insert_into_file 'features/support/ripple.rb', "\n\nAfter do\n  Ripple::TestServer.clear\nend", :after => "Ripple::TestServer.setup"
  end
end

#create_rspec_fileObject

RSpec



29
30
31
32
33
34
35
36
# File 'lib/rails/generators/ripple/test/test_generator.rb', line 29

def create_rspec_file
  if File.file?(Rails.root + 'spec/spec_helper.rb')
    template 'test_server.rb', 'spec/support/ripple.rb'
    inject_into_file 'spec/spec_helper.rb', :after => /R[Ss]pec\.configure do \|config\|/ do
      "\n  config.after(:each) do\n    Ripple::TestServer.clear\n  end\n"
    end
  end
end

#create_test_unit_fileObject

Test::Unit



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rails/generators/ripple/test/test_generator.rb', line 39

def create_test_unit_file
  if File.file?(Rails.root + 'test/test_helper.rb')
    template 'test_server.rb', 'test/ripple_test_helper.rb'
    inject_into_file "test/test_helper.rb", :before => "class ActiveSupport::TestCase" do
      "# Setup in-memory test server for Riak\nrequire File.expand_path('../ripple_test_helper.rb', __FILE__)\n\n"
    end
    inject_into_class "test/test_helper.rb", ActiveSupport::TestCase do
      "  teardown { Ripple::TestServer.clear }\n\n"
    end
  end
end