polonium 0.1.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/CHANGES +10 -0
- data/README +38 -0
- data/Rakefile +68 -0
- data/lib/polonium.rb +28 -0
- data/lib/polonium/configuration.rb +271 -0
- data/lib/polonium/driver.rb +155 -0
- data/lib/polonium/dsl/selenium_dsl.rb +33 -0
- data/lib/polonium/dsl/test_unit_dsl.rb +58 -0
- data/lib/polonium/element.rb +207 -0
- data/lib/polonium/extensions/module.rb +8 -0
- data/lib/polonium/extensions/testrunnermediator.rb +22 -0
- data/lib/polonium/mongrel_selenium_server_runner.rb +37 -0
- data/lib/polonium/page.rb +84 -0
- data/lib/polonium/selenium_helper.rb +5 -0
- data/lib/polonium/server_runner.rb +33 -0
- data/lib/polonium/tasks/selenium_test_task.rb +21 -0
- data/lib/polonium/test_case.rb +93 -0
- data/lib/polonium/wait_for.rb +40 -0
- data/lib/polonium/webrick_selenium_server_runner.rb +33 -0
- data/spec/polonium/extensions/module_spec.rb +29 -0
- data/spec/polonium/extensions/testrunnermediator_spec.rb +19 -0
- data/spec/polonium/mongrel_selenium_server_runner_spec.rb +35 -0
- data/spec/polonium/selenium_configuration_spec.rb +359 -0
- data/spec/polonium/selenium_driver_spec.rb +104 -0
- data/spec/polonium/selenium_element_spec.rb +551 -0
- data/spec/polonium/selenium_page_spec.rb +249 -0
- data/spec/polonium/selenium_server_runner_spec.rb +42 -0
- data/spec/polonium/selenium_test_case_class_method_spec.rb +41 -0
- data/spec/polonium/selenium_test_case_spec.rb +870 -0
- data/spec/polonium/selenium_test_case_spec_helper.rb +16 -0
- data/spec/polonium/webrick_selenium_server_runner_spec.rb +117 -0
- data/spec/spec_helper.rb +63 -0
- data/spec/spec_suite.rb +6 -0
- metadata +82 -0
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            module SeleniumTestCaseSpec
         | 
| 2 | 
            +
              attr_reader :base_selenium
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              class MySeleniumTestCase < Polonium::TestCase
         | 
| 5 | 
            +
                def initialize(*args)
         | 
| 6 | 
            +
                  @_result = Test::Unit::TestResult.new
         | 
| 7 | 
            +
                  super('test_nothing')
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                def run(result)
         | 
| 11 | 
            +
                  # do nothing
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
                def test_nothing
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
| @@ -0,0 +1,117 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Polonium
         | 
| 4 | 
            +
            describe WebrickSeleniumServerRunner do
         | 
| 5 | 
            +
              attr_reader :configuration
         | 
| 6 | 
            +
              before(:each) do
         | 
| 7 | 
            +
                Object.const_set(:RAILS_ROOT, "foobar")
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              after(:each) do
         | 
| 11 | 
            +
                Object.instance_eval {remove_const :RAILS_ROOT}
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              it "start method should set socket.do_not_reverse_lookup to true and" do
         | 
| 15 | 
            +
                runner = create_runner_that_is_stubbed_so_start_method_works
         | 
| 16 | 
            +
                runner.start
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              it "start method should initialize the HttpServer with parameters" do
         | 
| 20 | 
            +
                runner = create_runner_that_is_stubbed_so_start_method_works
         | 
| 21 | 
            +
                runner.start
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              it "start method should mount and start the server" do
         | 
| 25 | 
            +
                runner = create_runner_that_is_stubbed_so_start_method_works
         | 
| 26 | 
            +
                runner.start
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              it "start method should require the environment and dispatcher" do
         | 
| 30 | 
            +
                runner = create_runner_that_is_stubbed_so_start_method_works
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                mock(runner).require("foobar")
         | 
| 33 | 
            +
                mock(runner).require("dispatcher")
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                runner.environment_path = "foobar"
         | 
| 36 | 
            +
                runner.start
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              it "start method should require environment when rails_root is not set" do
         | 
| 40 | 
            +
                runner = create_runner_that_is_stubbed_so_start_method_works
         | 
| 41 | 
            +
                requires = []
         | 
| 42 | 
            +
                stub(runner).require {|val| requires << val}
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                runner.start
         | 
| 45 | 
            +
                requires.any? {|r| r =~ /\/config\/environment/}.should == true
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              it "start method should trap server.shutdown" do
         | 
| 49 | 
            +
                runner = create_runner_that_is_stubbed_so_start_method_works
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                (class << runner; self; end).class_eval {attr_reader :trap_signal_name}
         | 
| 52 | 
            +
                def runner.trap(signal_name, &block)
         | 
| 53 | 
            +
                  @trap_signal_name = signal_name
         | 
| 54 | 
            +
                  block.call
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
                mock(@mock_server).shutdown.once
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                runner.start
         | 
| 59 | 
            +
                runner.trap_signal_name.should == "INT"
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              it "should shutdown webrick server" do
         | 
| 63 | 
            +
                runner = create_runner_that_is_stubbed_so_start_method_works
         | 
| 64 | 
            +
                runner.start
         | 
| 65 | 
            +
                mock(@mock_server).shutdown.once
         | 
| 66 | 
            +
                runner.stop
         | 
| 67 | 
            +
              end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
              def create_runner_that_is_stubbed_so_start_method_works()
         | 
| 70 | 
            +
                configuration = Polonium::Configuration.new
         | 
| 71 | 
            +
                runner = configuration.create_webrick_runner
         | 
| 72 | 
            +
                class << runner; public :start_server; end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                def runner.require(*args)
         | 
| 75 | 
            +
                end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                mock_socket = "mock_socket"
         | 
| 78 | 
            +
                runner.socket = mock_socket
         | 
| 79 | 
            +
                stub(mock_socket).do_not_reverse_lookup=(true)
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                @mock_server = mock_server = "mock_server"
         | 
| 82 | 
            +
                (class << configuration; self; end).class_eval do
         | 
| 83 | 
            +
                  define_method :create_webrick_server do
         | 
| 84 | 
            +
                    mock_server
         | 
| 85 | 
            +
                  end
         | 
| 86 | 
            +
                end
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                configuration.internal_app_server_port = 4000
         | 
| 89 | 
            +
                configuration.internal_app_server_host = "localhost"
         | 
| 90 | 
            +
                configuration.rails_env = "test"
         | 
| 91 | 
            +
                stub(@mock_server).mount('/')
         | 
| 92 | 
            +
                mock(@mock_server).mount(
         | 
| 93 | 
            +
                  '/',
         | 
| 94 | 
            +
                  DispatchServlet,
         | 
| 95 | 
            +
                  {
         | 
| 96 | 
            +
                    :port            => configuration.internal_app_server_port,
         | 
| 97 | 
            +
                    :ip              => configuration.internal_app_server_host,
         | 
| 98 | 
            +
                    :environment     => configuration.rails_env,
         | 
| 99 | 
            +
                    :server_root     => File.expand_path("#{configuration.rails_root}/public/"),
         | 
| 100 | 
            +
                    :server_type     => WEBrick::SimpleServer,
         | 
| 101 | 
            +
                    :charset         => "UTF-8",
         | 
| 102 | 
            +
                    :mime_types      => WEBrick::HTTPUtils::DefaultMimeTypes,
         | 
| 103 | 
            +
                    :working_directory => File.expand_path(configuration.rails_root.to_s)
         | 
| 104 | 
            +
                  }
         | 
| 105 | 
            +
                )
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                mock(@mock_server).start.once
         | 
| 108 | 
            +
             | 
| 109 | 
            +
                mock_thread_class = "mock_thread_class"
         | 
| 110 | 
            +
                runner.thread_class = mock_thread_class
         | 
| 111 | 
            +
                mock(mock_thread_class).start {|block| block.call}
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                return runner
         | 
| 114 | 
            +
              end
         | 
| 115 | 
            +
             | 
| 116 | 
            +
            end
         | 
| 117 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,63 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            gem 'rspec', ">=1.1.0"
         | 
| 3 | 
            +
            require 'spec'
         | 
| 4 | 
            +
            require 'rr'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            dir = File.dirname(__FILE__)
         | 
| 7 | 
            +
            $LOAD_PATH.unshift(File.expand_path("#{dir}/../lib"))
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            require "tmpdir"
         | 
| 10 | 
            +
            require "hpricot"
         | 
| 11 | 
            +
            require 'tempfile'
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            require "polonium"
         | 
| 14 | 
            +
            require File.dirname(__FILE__) + "/polonium/selenium_test_case_spec_helper"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            Test::Unit.run = true
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            ProcessStub = Struct.new :host, :port, :name, :cmd, :logdir, :is_running unless Object.const_defined?(:ProcessStub)
         | 
| 19 | 
            +
            ProcessStub.class_eval do
         | 
| 20 | 
            +
              def is_running?
         | 
| 21 | 
            +
                self.is_running
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
              def say(msg, options = {})
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
              def run
         | 
| 26 | 
            +
                false
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
              def start
         | 
| 29 | 
            +
                self.is_running = true
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
              def stop
         | 
| 32 | 
            +
                self.is_running = false
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            Spec::Runner.configure do |config|
         | 
| 37 | 
            +
              config.mock_with :rr
         | 
| 38 | 
            +
            end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            module Polonium::WaitFor
         | 
| 41 | 
            +
              def time_class
         | 
| 42 | 
            +
                @time_class ||= FakeTimeClass.new
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              def sleep(time)
         | 
| 46 | 
            +
              end  
         | 
| 47 | 
            +
            end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            class FakeTimeClass
         | 
| 50 | 
            +
              def initialize
         | 
| 51 | 
            +
                @now = Time.now
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
              def now
         | 
| 55 | 
            +
                @now += 1
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
            end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            describe "Selenium", :shared => true do
         | 
| 60 | 
            +
              def result(response_text=nil)
         | 
| 61 | 
            +
                "OK,#{response_text }"
         | 
| 62 | 
            +
              end  
         | 
| 63 | 
            +
            end
         | 
    
        data/spec/spec_suite.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | @@ -0,0 +1,82 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            rubygems_version: 0.9.4
         | 
| 3 | 
            +
            specification_version: 1
         | 
| 4 | 
            +
            name: polonium
         | 
| 5 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 6 | 
            +
              version: 0.1.0
         | 
| 7 | 
            +
            date: 2007-12-20 00:00:00 -08:00
         | 
| 8 | 
            +
            summary: Selenium RC with enhanced assertions that also runs your rails app.
         | 
| 9 | 
            +
            require_paths: 
         | 
| 10 | 
            +
            - lib
         | 
| 11 | 
            +
            email: opensource@pivotallabs.com
         | 
| 12 | 
            +
            homepage: http://pivotallabs.com
         | 
| 13 | 
            +
            rubyforge_project: pivotalrb
         | 
| 14 | 
            +
            description: Selenium RC with enhanced assertions that also runs your rails app.
         | 
| 15 | 
            +
            autorequire: 
         | 
| 16 | 
            +
            default_executable: 
         | 
| 17 | 
            +
            bindir: bin
         | 
| 18 | 
            +
            has_rdoc: true
         | 
| 19 | 
            +
            required_ruby_version: !ruby/object:Gem::Version::Requirement 
         | 
| 20 | 
            +
              requirements: 
         | 
| 21 | 
            +
              - - ">"
         | 
| 22 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 23 | 
            +
                  version: 0.0.0
         | 
| 24 | 
            +
              version: 
         | 
| 25 | 
            +
            platform: ruby
         | 
| 26 | 
            +
            signing_key: 
         | 
| 27 | 
            +
            cert_chain: 
         | 
| 28 | 
            +
            post_install_message: 
         | 
| 29 | 
            +
            authors: 
         | 
| 30 | 
            +
            - Pivotal Labs
         | 
| 31 | 
            +
            files: 
         | 
| 32 | 
            +
            - CHANGES
         | 
| 33 | 
            +
            - README
         | 
| 34 | 
            +
            - Rakefile
         | 
| 35 | 
            +
            - lib/polonium/dsl/selenium_dsl.rb
         | 
| 36 | 
            +
            - lib/polonium/dsl/test_unit_dsl.rb
         | 
| 37 | 
            +
            - lib/polonium/element.rb
         | 
| 38 | 
            +
            - lib/polonium/mongrel_selenium_server_runner.rb
         | 
| 39 | 
            +
            - lib/polonium/extensions/testrunnermediator.rb
         | 
| 40 | 
            +
            - lib/polonium/extensions/module.rb
         | 
| 41 | 
            +
            - lib/polonium/tasks/selenium_test_task.rb
         | 
| 42 | 
            +
            - lib/polonium/page.rb
         | 
| 43 | 
            +
            - lib/polonium/driver.rb
         | 
| 44 | 
            +
            - lib/polonium/webrick_selenium_server_runner.rb
         | 
| 45 | 
            +
            - lib/polonium/server_runner.rb
         | 
| 46 | 
            +
            - lib/polonium/wait_for.rb
         | 
| 47 | 
            +
            - lib/polonium/test_case.rb
         | 
| 48 | 
            +
            - lib/polonium/configuration.rb
         | 
| 49 | 
            +
            - lib/polonium/selenium_helper.rb
         | 
| 50 | 
            +
            - lib/polonium.rb
         | 
| 51 | 
            +
            - spec/spec_helper.rb
         | 
| 52 | 
            +
            - spec/spec_suite.rb
         | 
| 53 | 
            +
            - spec/polonium/selenium_page_spec.rb
         | 
| 54 | 
            +
            - spec/polonium/selenium_server_runner_spec.rb
         | 
| 55 | 
            +
            - spec/polonium/selenium_configuration_spec.rb
         | 
| 56 | 
            +
            - spec/polonium/extensions/module_spec.rb
         | 
| 57 | 
            +
            - spec/polonium/extensions/testrunnermediator_spec.rb
         | 
| 58 | 
            +
            - spec/polonium/selenium_test_case_spec.rb
         | 
| 59 | 
            +
            - spec/polonium/webrick_selenium_server_runner_spec.rb
         | 
| 60 | 
            +
            - spec/polonium/selenium_element_spec.rb
         | 
| 61 | 
            +
            - spec/polonium/selenium_test_case_spec_helper.rb
         | 
| 62 | 
            +
            - spec/polonium/selenium_test_case_class_method_spec.rb
         | 
| 63 | 
            +
            - spec/polonium/selenium_driver_spec.rb
         | 
| 64 | 
            +
            - spec/polonium/mongrel_selenium_server_runner_spec.rb
         | 
| 65 | 
            +
            test_files: []
         | 
| 66 | 
            +
             | 
| 67 | 
            +
            rdoc_options: 
         | 
| 68 | 
            +
            - --main
         | 
| 69 | 
            +
            - README
         | 
| 70 | 
            +
            - --inline-source
         | 
| 71 | 
            +
            - --line-numbers
         | 
| 72 | 
            +
            extra_rdoc_files: 
         | 
| 73 | 
            +
            - README
         | 
| 74 | 
            +
            - CHANGES
         | 
| 75 | 
            +
            executables: []
         | 
| 76 | 
            +
             | 
| 77 | 
            +
            extensions: []
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            requirements: []
         | 
| 80 | 
            +
             | 
| 81 | 
            +
            dependencies: []
         | 
| 82 | 
            +
             |