mainline 1.0.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/.loadpath ADDED
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <loadpath>
3
+ <pathentry path="" type="src"/>
4
+ <pathentry path="org.rubypeople.rdt.launching.RUBY_CONTAINER" type="con"/>
5
+ </loadpath>
data/.project ADDED
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>mainline</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.rubypeople.rdt.core.rubybuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ </buildSpec>
14
+ <natures>
15
+ <nature>org.rubypeople.rdt.core.rubynature</nature>
16
+ </natures>
17
+ </projectDescription>
data/History.txt ADDED
@@ -0,0 +1,3 @@
1
+ === 1.0.0 2010-02-03
2
+
3
+ * Initial release as gem
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Mike Gaffney
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,25 @@
1
+ .loadpath
2
+ .project
3
+ History.txt
4
+ MIT-LICENSE
5
+ Manifest.txt
6
+ README.rdoc
7
+ Rakefile
8
+ init.rb
9
+ lib/mainline.rb
10
+ lib/mainline/config.rb
11
+ lib/mainline/connection_pool.rb
12
+ lib/mainline/core.rb
13
+ lib/mainline/integration_test.rb
14
+ lib/mainline/nil_server.rb
15
+ lib/mainline/server.rb
16
+ mainline.gemspec
17
+ rails/init.rb
18
+ script/console
19
+ script/destroy
20
+ script/generate
21
+ tasks/rspec.rake
22
+ test/test_config.rb
23
+ test/test_core.rb
24
+ test/test_helper.rb
25
+ test/test_nil_server.rb
data/README.rdoc ADDED
@@ -0,0 +1,73 @@
1
+ = mainline
2
+
3
+ * http://github.com/gaffo/mainline
4
+
5
+ == DESCRIPTION:
6
+
7
+ Mainline is a rails plugin which exposes your rails app via webrick to allow
8
+ testing with browser automators such as Selenium or Watir. Mainline allows
9
+ your rails actions to run in the same transaction as your unit tests so you
10
+ can use fixtures, factories, or whatever.
11
+
12
+ == SYNOPSIS:
13
+
14
+ Currently mainline only supports one integration session at a time.
15
+
16
+ To install it as a plugin:
17
+
18
+ script/plugins install git://github.com/gaffo/mainline.git
19
+
20
+ And to enable it you need to do a:
21
+
22
+ Mainline.enable, or the block form (if you need to configure things).
23
+
24
+ For example, to enable Mainline and specify a port:
25
+
26
+ Webrat.configure do |config|
27
+ config.mode = :rails
28
+ config.open_error_files = false # Set to true if you want error pages to pop up in the browser
29
+ Mainline.enable { |config| config.port = 3030 }
30
+ end
31
+
32
+ When using webrat, it's best to do somthing like this if you are just running selenium.
33
+
34
+ Webrat.configure do |config|
35
+ config.application_framework = :external
36
+ Mainline.enable
37
+ end
38
+
39
+ However if you need to run in selenium and non selenium and need to configure
40
+ ports (for build boxes), you should use somthing like this (pulled from my own config):
41
+
42
+ Webrat.configure do |config|
43
+ if ENV['WEBRAT_INTEGRATION_MODE'] == 'selenium'
44
+ config.mode = :selenium
45
+ config.application_framework = :external
46
+ config.application_port = ENV['WEBRAT_APPLICATION_PORT'] || 3001
47
+ config.selenium_server_port = ENV['WEBRAT_SELENIUM_PORT'] || 4444
48
+ Mainline.enable do |mainline_config|
49
+ mainline_config.port = ENV['WEBRAT_APPLICATION_PORT'] || 3001
50
+ end
51
+ else
52
+ config.mode = :rails
53
+ end
54
+ end
55
+
56
+
57
+ == LINKS:
58
+
59
+ * **Code:** <http://github.com/gaffo/mainline>
60
+ * **Docs:** <http://rdocul.us/repos/mainline/master/index.html>
61
+ * **Bugs:** <http://gaffo.lighthouseapp.com/projects/24578-mainline/overview>
62
+
63
+ == INSTALL:
64
+
65
+ via gem:
66
+
67
+ gem install mainline
68
+ script/generate mainline
69
+
70
+ via plugin
71
+
72
+ script/plugin install git://github.com/gaffo/mainline.git
73
+ script/generate mainline
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/mainline'
6
+
7
+ Hoe.plugin :newgem
8
+
9
+ # Generate all the Rake tasks
10
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
11
+ $hoe = Hoe.spec 'mainline' do
12
+ self.developer 'Mike Gaffney', 'mike@uberu.com'
13
+ self.developer 'Dr Nic Williams', 'drnicwilliams@gmail.com'
14
+ self.extra_deps << ['rack']
15
+ end
16
+
17
+ require 'newgem/tasks'
18
+ Dir['tasks/**/*.rake'].each { |t| load t }
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'mainline'
@@ -0,0 +1,11 @@
1
+ module Mainline
2
+ class Config
3
+
4
+ # the port that mainline is going to open on
5
+ attr_accessor :port
6
+
7
+ def initialize # :nodoc:
8
+ self.port = 3001
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ # The code below makes rails into a single db connection beast
2
+ # This is kinda dangerous and a better solution needs to be had
3
+ # Likely exposing callbacks from integration session
4
+ class ActiveRecord::ConnectionAdapters::ConnectionPool
5
+ private
6
+ def current_connection_id #:nodoc:
7
+ '1'
8
+ end
9
+ end
@@ -0,0 +1,40 @@
1
+ require "mainline/config"
2
+ require "mainline/server"
3
+ require "mainline/nil_server"
4
+
5
+ module Mainline
6
+
7
+ # Configures Mainline. If this is not done, Mainline will not be activated
8
+ def self.enable(configuration = Mainline.configuration)
9
+ configuration ||= Mainline::Config.new
10
+ yield configuration if block_given?
11
+ @@configuration = configuration
12
+ end
13
+
14
+ def self.configuration # :nodoc:
15
+ defined?(@@configuration) ? @@configuration : nil
16
+ end
17
+
18
+ class Core
19
+
20
+ def initialize(configuration)
21
+ @config = configuration
22
+ end
23
+
24
+ def start
25
+ unless @server
26
+ if @config
27
+ @server = Mainline::Server.new(@config)
28
+ else
29
+ @server = Mainline::NilServer.new(@config)
30
+ end
31
+ Thread.new do
32
+ @server.start
33
+ end
34
+ end
35
+ end
36
+
37
+ end
38
+
39
+
40
+ end
@@ -0,0 +1,7 @@
1
+ class ActionController::IntegrationTest
2
+ setup :start_mainline_server
3
+ def start_mainline_server
4
+ @@mainline ||= Mainline::Core.new(Mainline.configuration)
5
+ @@mainline.start
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ module Mainline
2
+ class NilServer
3
+ def initialize(config)
4
+
5
+ end
6
+
7
+ def start
8
+ # puts "Mainline is not starting it because it has not been configured."
9
+ # puts "Please do a Mainline.configure in your test_helper | spec_helper"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ module Mainline
2
+ class Server
3
+ def initialize(config)
4
+ @config = config
5
+ end
6
+
7
+ def start
8
+ options = {:Port => @config.port, :Host => "0.0.0.0"}
9
+
10
+ @server = Rack::Handler::WEBrick
11
+ require RAILS_ROOT + "/config/environment"
12
+ inner_app = ActionController::Dispatcher.new
13
+ inner_app.send(:build_middleware_stack)
14
+ app = Rack::Builder.new { run inner_app }.to_app
15
+ @server.run(app, options.merge(:AccessLog => []))
16
+ end
17
+ end
18
+ end
data/lib/mainline.rb ADDED
@@ -0,0 +1,32 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'webrick'
5
+ require 'rack'
6
+
7
+ module Mainline
8
+
9
+ VERSION = "1.0.0"
10
+
11
+ def initialize()
12
+ @started = false
13
+ end
14
+
15
+ def start
16
+ return if @started
17
+ Thread.new do
18
+ @server = Mainline::Server.new(@config)
19
+ @server.start
20
+ end
21
+ @started = true
22
+ end
23
+
24
+ end
25
+
26
+ require 'mainline/core'
27
+
28
+ if ENV['RAILS_ENV'] && ENV['RAILS_ENV'] =~ /^(test|selenium|cucumber)/
29
+ require 'mainline/connection_pool'
30
+ require 'mainline/integration_test'
31
+ end
32
+
data/mainline.gemspec ADDED
@@ -0,0 +1,48 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{mainline}
5
+ s.version = "1.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Mike Gaffney", "Dr Nic Williams"]
9
+ s.cert_chain = ["/home/mgaffney/.gem/gem-public_cert.pem"]
10
+ s.date = %q{2010-02-03}
11
+ s.description = %q{Mainline is a rails plugin which exposes your rails app via webrick to allow
12
+ testing with browser automators such as Selenium or Watir. Mainline allows
13
+ your rails actions to run in the same transaction as your unit tests so you
14
+ can use fixtures, factories, or whatever.}
15
+ s.email = ["mike@uberu.com", "drnicwilliams@gmail.com"]
16
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
17
+ s.files = [".loadpath", ".project", "History.txt", "MIT-LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "init.rb", "lib/mainline.rb", "lib/mainline/config.rb", "lib/mainline/connection_pool.rb", "lib/mainline/core.rb", "lib/mainline/integration_test.rb", "lib/mainline/nil_server.rb", "lib/mainline/server.rb", "rails/init.rb", "script/console", "script/destroy", "script/generate", "spec/mainline_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake", "test/mainline/config_test.rb", "test/mainline/core_test.rb", "test/mainline/nil_server_test.rb", "test/test_helper.rb", "test/test_config.rb", "test/test_nil_server.rb", "test/test_core.rb"]
18
+ s.homepage = %q{http://github.com/gaffo/mainline}
19
+ s.rdoc_options = ["--main", "README.rdoc"]
20
+ s.require_paths = ["lib"]
21
+ s.rubyforge_project = %q{mainline}
22
+ s.rubygems_version = %q{1.3.5}
23
+ s.signing_key = %q{/home/mgaffney/.gem/gem-private_key.pem}
24
+ s.summary = %q{Mainline is a rails plugin which exposes your rails app via webrick to allow testing with browser automators such as Selenium or Watir}
25
+ s.test_files = ["test/test_config.rb", "test/test_nil_server.rb", "test/test_helper.rb", "test/test_core.rb"]
26
+
27
+ if s.respond_to? :specification_version then
28
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
29
+ s.specification_version = 3
30
+
31
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
32
+ s.add_runtime_dependency(%q<rack>, [">= 0"])
33
+ s.add_development_dependency(%q<rubyforge>, [">= 2.0.3"])
34
+ s.add_development_dependency(%q<gemcutter>, [">= 0.3.0"])
35
+ s.add_development_dependency(%q<hoe>, [">= 2.5.0"])
36
+ else
37
+ s.add_dependency(%q<rack>, [">= 0"])
38
+ s.add_dependency(%q<rubyforge>, [">= 2.0.3"])
39
+ s.add_dependency(%q<gemcutter>, [">= 0.3.0"])
40
+ s.add_dependency(%q<hoe>, [">= 2.5.0"])
41
+ end
42
+ else
43
+ s.add_dependency(%q<rack>, [">= 0"])
44
+ s.add_dependency(%q<rubyforge>, [">= 2.0.3"])
45
+ s.add_dependency(%q<gemcutter>, [">= 0.3.0"])
46
+ s.add_dependency(%q<hoe>, [">= 2.5.0"])
47
+ end
48
+ end
data/rails/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'mainline'
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/mainline.rb'}"
9
+ puts "Loading mainline gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
data/tasks/rspec.rake ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+
3
+ require 'mainline/config'
4
+
5
+ class Mainline::ConfigTest < Test::Unit::TestCase
6
+
7
+ def test_default_port
8
+ config = Mainline::Config.new
9
+ assert_equal(3001, config.port)
10
+ end
11
+
12
+ end
data/test/test_core.rb ADDED
@@ -0,0 +1,35 @@
1
+ require 'test_helper'
2
+
3
+ require 'mainline/core'
4
+ require 'mainline/server'
5
+ require 'mainline/nil_server'
6
+
7
+ class Mainline::CoreTest < Test::Unit::TestCase
8
+
9
+ def test_server_doesnt_start_when_not_configured
10
+ config = mock("Mainline::Config")
11
+ Mainline::NilServer.any_instance.expects(:start).times(1)
12
+ Mainline::Core.new(nil).start
13
+ end
14
+
15
+ def test_mainline_with_config_starts_server
16
+ config = mock("Mainline::Config")
17
+ mock_server = mock("Mainline::Server")
18
+ Mainline::Server.expects(:new).with(config).returns(mock_server)
19
+ mock_server.expects(:start)
20
+
21
+ Mainline::Core.new(config).start
22
+ end
23
+
24
+ def test_configed_mainline_doesnt_start_server_twice
25
+ config = mock("Mainline::Config")
26
+ mock_server = mock("Mainline::Server")
27
+ Mainline::Server.expects(:new).with(config).returns(mock_server)
28
+ mock_server.expects(:start)
29
+
30
+ mainline = Mainline::Core.new(config)
31
+ mainline.start
32
+ mainline.start
33
+ end
34
+
35
+ end
@@ -0,0 +1,5 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
2
+
3
+ require 'test/unit'
4
+ require 'rubygems'
5
+ require 'mocha'
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+
3
+ require 'mainline/nil_server'
4
+
5
+ class Mainline::NilServerTest < Test::Unit::TestCase
6
+
7
+ def test_can_create
8
+ server = Mainline::NilServer.new(nil)
9
+ server.start
10
+ end
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mainline
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Gaffney
8
+ - Dr Nic Williams
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2010-02-03 00:00:00 -06:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rack
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: rubyforge
28
+ type: :development
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 2.0.3
35
+ version:
36
+ - !ruby/object:Gem::Dependency
37
+ name: gemcutter
38
+ type: :development
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 0.3.0
45
+ version:
46
+ - !ruby/object:Gem::Dependency
47
+ name: hoe
48
+ type: :development
49
+ version_requirement:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.5.0
55
+ version:
56
+ description: |-
57
+ Mainline is a rails plugin which exposes your rails app via webrick to allow
58
+ testing with browser automators such as Selenium or Watir. Mainline allows
59
+ your rails actions to run in the same transaction as your unit tests so you
60
+ can use fixtures, factories, or whatever.
61
+ email:
62
+ - mike@uberu.com
63
+ - drnicwilliams@gmail.com
64
+ executables: []
65
+
66
+ extensions: []
67
+
68
+ extra_rdoc_files:
69
+ - History.txt
70
+ - Manifest.txt
71
+ files:
72
+ - .loadpath
73
+ - .project
74
+ - History.txt
75
+ - MIT-LICENSE
76
+ - Manifest.txt
77
+ - README.rdoc
78
+ - Rakefile
79
+ - init.rb
80
+ - lib/mainline.rb
81
+ - lib/mainline/config.rb
82
+ - lib/mainline/connection_pool.rb
83
+ - lib/mainline/core.rb
84
+ - lib/mainline/integration_test.rb
85
+ - lib/mainline/nil_server.rb
86
+ - lib/mainline/server.rb
87
+ - mainline.gemspec
88
+ - rails/init.rb
89
+ - script/console
90
+ - script/destroy
91
+ - script/generate
92
+ - tasks/rspec.rake
93
+ - test/test_config.rb
94
+ - test/test_core.rb
95
+ - test/test_helper.rb
96
+ - test/test_nil_server.rb
97
+ has_rdoc: true
98
+ homepage: http://github.com/gaffo/mainline
99
+ licenses: []
100
+
101
+ post_install_message:
102
+ rdoc_options:
103
+ - --main
104
+ - README.rdoc
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: "0"
112
+ version:
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: "0"
118
+ version:
119
+ requirements: []
120
+
121
+ rubyforge_project: mainline
122
+ rubygems_version: 1.3.5
123
+ signing_key:
124
+ specification_version: 3
125
+ summary: Mainline is a rails plugin which exposes your rails app via webrick to allow testing with browser automators such as Selenium or Watir
126
+ test_files:
127
+ - test/test_config.rb
128
+ - test/test_nil_server.rb
129
+ - test/test_helper.rb
130
+ - test/test_core.rb