├── .gitignore
├── All.iml
├── ChangeLog
├── README
├── Selenium Grid.ipr
├── Selenium Grid.iws
├── agent
├── Agent.iml
├── build.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── thoughtworks
│ │ └── selenium
│ │ └── grid
│ │ └── agent
│ │ ├── AgentConfiguration.java
│ │ ├── AgentRegistry.java
│ │ ├── AgentResource.java
│ │ ├── AgentServer.java
│ │ ├── Classpath.java
│ │ ├── JVMHandle.java
│ │ ├── JVMLauncher.java
│ │ ├── RemoteControlCommand.java
│ │ ├── RemoteControlConfiguration.java
│ │ └── RouteResolver.java
│ └── test
│ ├── functional
│ └── java
│ │ └── com
│ │ └── thoughtworks
│ │ └── selenium
│ │ └── grid
│ │ └── agent
│ │ └── JMVMLauncherTest.java
│ └── unit
│ └── java
│ └── com
│ └── thoughtworks
│ └── selenium
│ └── grid
│ └── agent
│ ├── AgentConfigurationTest.java
│ ├── AgentRegistryTest.java
│ ├── AgentResourceTest.java
│ ├── ClasspathTest.java
│ ├── JVMLauncherTest.java
│ ├── RemoteControlCommandTest.java
│ ├── RemoteControlConfigurationTest.java
│ └── RouteResolverTest.java
├── build.xml
├── demo
├── Demo.iml
├── build.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── thoughtworks
│ └── selenium
│ └── grid
│ └── demo
│ ├── AmazonCommentTestBase.java
│ ├── WebTestForASingleBrowser.java
│ └── WebTestInvolvingMultiEnvironments.java
├── doc
├── Philosophy.html
├── resources
│ ├── DELL Server.jpg
│ ├── Multiple Environments Demo Setup.svg
│ ├── Multiple Machine Demo Setup.svg
│ ├── Rakefile
│ ├── Requesting a Specific Environment.svg
│ ├── Selenium Grid Setup.svg
│ ├── Selenium Grid.css
│ ├── Traditional Selenium Setup.svg
│ ├── applelogo.png
│ ├── iMac.jpeg
│ └── macbookpro.jpg
└── website
│ ├── Rakefile
│ ├── build_it_from_source.html
│ ├── diagrams
│ ├── Multiple Environment Demo Setup - Small.png
│ ├── Multiple Environment Demo Setup.png
│ ├── Multiple Machine Demo Setup - Small.png
│ ├── Multiple Machine Demo Setup.png
│ ├── Requesting a Specific Environment - Small.png
│ ├── Requesting a Specific Environment.png
│ ├── Selenium Grid Setup - Small.png
│ ├── Selenium Grid Setup.png
│ ├── Traditional Selenium Setup - Small.png
│ └── Traditional Selenium Setup.png
│ ├── download.html
│ ├── faq.markdown
│ ├── get_started.html
│ ├── give_feedback.html
│ ├── hack.html
│ ├── how_it_works.html
│ ├── images
│ ├── ant_version_osx_screenshot.png
│ ├── background_better.png
│ ├── background_feedback.png
│ ├── background_participate.png
│ ├── background_started.png
│ ├── check_path_osx_screenshot.png
│ ├── dot_profile_editing_osx_screenshot.png
│ ├── dot_profile_osx_screenshot.png
│ ├── install
│ │ ├── linux
│ │ │ ├── linux-ant-install.png
│ │ │ ├── linux-ant-profile-update.png
│ │ │ ├── linux-ant-verify.png
│ │ │ ├── linux-ant-version.png
│ │ │ ├── linux-java-version.png
│ │ │ ├── linux-navigate-path.png
│ │ │ ├── linux-selenium-install.png
│ │ │ └── linux-selenium-sanity-check.png
│ │ └── win
│ │ │ ├── ant-check-path.bmp
│ │ │ ├── ant-update-path.bmp
│ │ │ ├── ant-version.bmp
│ │ │ ├── java-version.bmp
│ │ │ └── selenium-check.bmp
│ ├── install_ant_osx_screenshot.png
│ ├── installing_grid_osx_screenshot.png
│ ├── java_version_osx_screenshot.png
│ ├── sanity_check_osx_screenshot.png
│ └── selenium_grid_logo_large.png
│ ├── index.html
│ ├── javascripts
│ └── shadedborder.js
│ ├── participate.html
│ ├── run_the_demo.html
│ ├── run_the_demo_on_ec2.html
│ ├── setting_up_selenium_grid_on_ec2.html
│ ├── step_by_step_installation_instructions_for_linux.html
│ ├── step_by_step_installation_instructions_for_osx.html
│ ├── step_by_step_installation_instructions_for_windows.html
│ ├── stylesheets
│ ├── document.css
│ ├── faq.css
│ ├── home.css
│ ├── openqa.css
│ └── site.css
│ └── using_selenium_grid_on_ec2.html
├── examples
├── ec2
│ ├── Capfile
│ ├── etc
│ │ ├── background.png
│ │ └── background.svg
│ ├── lib
│ │ └── selenium_grid
│ │ │ └── aws
│ │ │ ├── cloud.rb
│ │ │ ├── ec2.rb
│ │ │ ├── ec2_client.rb
│ │ │ ├── hub.rb
│ │ │ ├── remote_command.rb
│ │ │ └── server.rb
│ ├── test
│ │ └── unit
│ │ │ ├── all_test.rb
│ │ │ ├── cloud_test.rb
│ │ │ ├── ec2_client_test.rb
│ │ │ ├── hub_test.rb
│ │ │ ├── remote_command_test.rb
│ │ │ ├── server_test.rb
│ │ │ └── test_helper.rb
│ └── vnc_password
├── java
│ ├── Java Example.iml
│ ├── build.xml
│ ├── src
│ │ └── com
│ │ │ └── thoughtworks
│ │ │ └── selenium
│ │ │ └── grid
│ │ │ └── examples
│ │ │ └── java
│ │ │ ├── BookTest.java
│ │ │ ├── DesignBooksTest.java
│ │ │ ├── MethodologyBooksTest.java
│ │ │ ├── ProjectManagementBooksTest.java
│ │ │ └── RubyBooksTest.java
│ ├── testng-slow.xml
│ └── testng.xml
└── ruby
│ ├── README
│ ├── Rakefile
│ ├── Ruby Example.iml
│ ├── agile_developer_spec.rb
│ ├── agile_project_manager_spec.rb
│ ├── book_example.rb
│ ├── good_developer_spec.rb
│ ├── lib
│ ├── array_extension.rb
│ ├── multi_process_behaviour_runner.rb
│ ├── rspec_extensions.rb
│ ├── screenshot_formatter.rb
│ ├── selenium_driver_extensions.rb
│ └── spec
│ │ ├── screenshot_formatter.rb
│ │ └── screenshot_saver.rb
│ ├── rubyist_spec.rb
│ ├── spec_helper.rb
│ └── vendor
│ └── selenium-client-1.1
│ ├── README
│ ├── lib
│ ├── selenium.rb
│ └── selenium
│ │ ├── client
│ │ ├── base.rb
│ │ ├── driver.rb
│ │ ├── generated_driver.rb
│ │ ├── selenese_client.rb
│ │ └── selenium_helper.rb
│ │ ├── command_error.rb
│ │ ├── protocol_error.rb
│ │ ├── rspec
│ │ └── screenshot_formatter.rb
│ │ └── screenshot_saver.rb
│ └── test
│ └── all_unit_tests.rb
├── git_exclude
├── hub
├── Hub Tests.iml
├── Hub.iml
├── build.xml
├── lib
│ └── freemarker-2.3.10.jar
├── src
│ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── thoughtworks
│ │ │ └── selenium
│ │ │ └── grid
│ │ │ └── hub
│ │ │ ├── CommandParsingException.java
│ │ │ ├── Environment.java
│ │ │ ├── EnvironmentManager.java
│ │ │ ├── HttpCommandParser.java
│ │ │ ├── HubRegistry.java
│ │ │ ├── HubServer.java
│ │ │ ├── HubServlet.java
│ │ │ ├── management
│ │ │ ├── HubServlet.java
│ │ │ ├── LifecycleManager.java
│ │ │ ├── LifecycleManagerServlet.java
│ │ │ ├── RegistrationManagementServlet.java
│ │ │ ├── RegistrationServlet.java
│ │ │ ├── RemoteControlParser.java
│ │ │ ├── UnregistrationServlet.java
│ │ │ └── console
│ │ │ │ ├── ConsoleController.java
│ │ │ │ ├── ConsoleServlet.java
│ │ │ │ ├── index.html
│ │ │ │ └── mvc
│ │ │ │ ├── Controller.java
│ │ │ │ ├── Page.java
│ │ │ │ ├── RenderingException.java
│ │ │ │ ├── Template.java
│ │ │ │ └── TemplateResolver.java
│ │ │ └── remotecontrol
│ │ │ ├── DynamicRemoteControlPool.java
│ │ │ ├── GlobalRemoteControlPool.java
│ │ │ ├── RemoteControlPool.java
│ │ │ ├── RemoteControlProvisioner.java
│ │ │ ├── RemoteControlProxy.java
│ │ │ └── commands
│ │ │ ├── NewBrowserSessionCommand.java
│ │ │ ├── SeleneseCommand.java
│ │ │ └── TestCompleteCommand.java
│ └── test
│ │ ├── integration
│ │ └── com
│ │ │ └── thoughtworks
│ │ │ └── selenium
│ │ │ └── grid
│ │ │ └── hub
│ │ │ └── remotecontrol
│ │ │ ├── LocalHostResolverTest.java
│ │ │ ├── RequestProxyTest.java
│ │ │ └── SeleniumRCProxyIntegrationTest.java
│ │ └── unit
│ │ └── java
│ │ └── com
│ │ └── thoughtworks
│ │ └── selenium
│ │ └── grid
│ │ ├── AssertionHelper.java
│ │ └── hub
│ │ ├── ConcurrentAction.java
│ │ ├── EnvironmentManagerTest.java
│ │ ├── EnvironmentTest.java
│ │ ├── HttpCommandParserTest.java
│ │ ├── HubRegistryTest.java
│ │ ├── HubServerTest.java
│ │ ├── HubServletTest.java
│ │ ├── ServletParameterAdapterTest.java
│ │ ├── management
│ │ ├── LifecyleManagerServletTest.java
│ │ ├── RegistrationServletTest.java
│ │ ├── RemoteControlParserTest.java
│ │ ├── UnregistrationServletTest.java
│ │ └── console
│ │ │ ├── ConsoleControllerTest.java
│ │ │ ├── ConsoleServletTest.java
│ │ │ └── mvc
│ │ │ ├── ControllerTest.java
│ │ │ ├── PageTest.java
│ │ │ ├── RenderingExceptionTest.java
│ │ │ ├── TemplateResolverTest.java
│ │ │ ├── TemplateTest.java
│ │ │ └── a_template.html
│ │ └── remotecontrol
│ │ ├── GlobalRemoteControlPoolTest.java
│ │ ├── RemoteControlProvisionerTest.java
│ │ ├── RemoteControlProxyTest.java
│ │ └── commands
│ │ ├── NewBrowserSessionCommandTest.java
│ │ ├── SeleneseCommandTest.java
│ │ └── TestCompleteCommandTest.java
└── web
│ └── WEB-INF
│ └── web.xml
├── infrastructure
├── core
│ ├── Core.iml
│ ├── build.xml
│ └── src
│ │ ├── main
│ │ ├── com
│ │ │ └── thoughtworks
│ │ │ │ └── selenium
│ │ │ │ └── grid
│ │ │ │ ├── HttpClient.java
│ │ │ │ ├── HttpParameters.java
│ │ │ │ ├── IOHelper.java
│ │ │ │ ├── Join.java
│ │ │ │ ├── Response.java
│ │ │ │ └── configuration
│ │ │ │ ├── EnvironmentConfiguration.java
│ │ │ │ ├── GridConfiguration.java
│ │ │ │ ├── HubConfiguration.java
│ │ │ │ └── ResourceLocator.java
│ │ └── grid_configuration.yml
│ │ └── test
│ │ └── unit
│ │ └── java
│ │ └── com
│ │ └── thoughtworks
│ │ └── selenium
│ │ └── grid
│ │ ├── HttpClientTest.java
│ │ ├── HttpParametersTest.java
│ │ ├── IOHelperTest.java
│ │ ├── JoinTest.java
│ │ ├── ResponseTest.java
│ │ └── configuration
│ │ ├── EnvironmentConfigurationTest.java
│ │ ├── GridConfigurationTest.java
│ │ ├── HubConfigurationTest.java
│ │ └── ResourceLocatorTest.java
└── webserver
│ ├── WebServer.iml
│ ├── build.xml
│ └── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── thoughtworks
│ │ └── selenium
│ │ └── grid
│ │ └── webserver
│ │ ├── InvalidRouteException.java
│ │ ├── MainServlet.java
│ │ ├── Resource.java
│ │ ├── RouteResolver.java
│ │ └── WebServer.java
│ └── test
│ └── unit
│ └── java
│ └── com
│ └── thoughtworks
│ └── selenium
│ └── grid
│ └── webserver
│ ├── InvalidRouteExceptionTest.java
│ ├── MainServletTest.java
│ └── WebServerTest.java
├── lib
├── build
│ ├── common-build.xml
│ └── pmd-ruleset.xml
├── ruby
│ ├── file_extensions.rb
│ ├── java
│ │ ├── classpath.rb
│ │ └── vm.rb
│ └── tcp_socket_extensions.rb
└── testng.policy
├── project.properties
├── regression-tests
├── Regression Tests.iml
├── build.xml
├── src
│ └── com
│ │ └── thoughtworks
│ │ └── selenium
│ │ └── grid
│ │ └── regressiontests
│ │ ├── CyrilicTests.java
│ │ ├── HugeRequestTests.java
│ │ ├── InactivityTests.java
│ │ └── UnicodeTests.java
└── testng.xml
├── remote-control
├── Remote Control.iml
├── build.xml
├── lib
│ └── selenium-server-1.0-SNAPSHOT.jar
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── thoughtworks
│ │ └── selenium
│ │ └── grid
│ │ └── remotecontrol
│ │ ├── HubRequest.java
│ │ ├── OptionParser.java
│ │ ├── RegistrationRequest.java
│ │ ├── SelfRegisteringRemoteControl.java
│ │ ├── SelfRegisteringRemoteControlLauncher.java
│ │ ├── UnregistrationRequest.java
│ │ └── instrumentation
│ │ ├── EchoRemoteControl.java
│ │ ├── HttpRequestProcessor.java
│ │ ├── Request.java
│ │ ├── Response.java
│ │ └── SimplisticHttpServer.java
│ └── test
│ └── unit
│ └── java
│ └── com
│ └── thoughtworks
│ └── selenium
│ └── grid
│ └── remotecontrol
│ ├── HubRequestTest.java
│ ├── RegistrationRequestTest.java
│ ├── SelfRegisteringRemoteControlTest.java
│ └── UnregistrationRequestTest.java
├── src
├── configuration
│ └── grid_configuration.yml
├── reports
│ └── index.html
└── scripts
│ ├── Capfile
│ ├── Rakefile
│ ├── build.xml
│ ├── kill-rcs.sh
│ ├── launch-rc.sh
│ ├── launch-rcs.sh
│ ├── launch-remote-contols.applescript
│ ├── launch-remote-controls.rb
│ └── testng.xml
├── tools
├── Tools.iml
├── build.xml
└── src
│ ├── main
│ └── com
│ │ └── thoughtworks
│ │ └── selenium
│ │ └── grid
│ │ └── tools
│ │ └── ThreadSafeSeleniumSessionStorage.java
│ └── test
│ └── unit
│ └── java
│ └── com
│ └── thoughtworks
│ └── selenium
│ └── grid
│ └── tools
│ └── ThreadSafeSeleniumSessionStorageTest.java
└── vendor
├── asm-2.2.1.jar
├── asm-3.1.jar
├── asm-tree-2.2.1.jar
├── cglib-2.1_3.jar
├── cglib-nodep-2.1_3.jar
├── cobertura-1.9.jar
├── commons-codec-1.3.jar
├── commons-httpclient-3.0.1.jar
├── commons-logging-1.0.4.jar
├── findbugs-ant.jar
├── findbugs.jar
├── gems
└── mocha-0.5.5
│ ├── COPYING
│ ├── MIT-LICENSE
│ ├── README
│ ├── RELEASE
│ ├── Rakefile
│ ├── examples
│ ├── misc.rb
│ ├── mocha.rb
│ └── stubba.rb
│ ├── lib
│ ├── mocha.rb
│ ├── mocha
│ │ ├── any_instance_method.rb
│ │ ├── auto_verify.rb
│ │ ├── central.rb
│ │ ├── class_method.rb
│ │ ├── deprecation.rb
│ │ ├── exception_raiser.rb
│ │ ├── expectation.rb
│ │ ├── expectation_error.rb
│ │ ├── expectation_list.rb
│ │ ├── infinite_range.rb
│ │ ├── inspect.rb
│ │ ├── instance_method.rb
│ │ ├── is_a.rb
│ │ ├── metaclass.rb
│ │ ├── missing_expectation.rb
│ │ ├── mock.rb
│ │ ├── multiple_yields.rb
│ │ ├── no_yields.rb
│ │ ├── object.rb
│ │ ├── parameter_matchers.rb
│ │ ├── parameter_matchers
│ │ │ ├── all_of.rb
│ │ │ ├── any_of.rb
│ │ │ ├── anything.rb
│ │ │ ├── has_entry.rb
│ │ │ ├── has_key.rb
│ │ │ ├── has_value.rb
│ │ │ ├── includes.rb
│ │ │ ├── instance_of.rb
│ │ │ ├── kind_of.rb
│ │ │ └── regexp_matches.rb
│ │ ├── pretty_parameters.rb
│ │ ├── return_values.rb
│ │ ├── setup_and_teardown.rb
│ │ ├── single_return_value.rb
│ │ ├── single_yield.rb
│ │ ├── standalone.rb
│ │ ├── stub.rb
│ │ ├── test_case_adapter.rb
│ │ └── yield_parameters.rb
│ ├── mocha_standalone.rb
│ └── stubba.rb
│ └── test
│ ├── acceptance
│ ├── expected_invocation_count_acceptance_test.rb
│ ├── mocha_acceptance_test.rb
│ ├── mocked_methods_dispatch_acceptance_test.rb
│ ├── parameter_matcher_acceptance_test.rb
│ ├── standalone_acceptance_test.rb
│ └── stubba_acceptance_test.rb
│ ├── active_record_test_case.rb
│ ├── deprecation_disabler.rb
│ ├── execution_point.rb
│ ├── integration
│ ├── mocha_test_result_integration_test.rb
│ ├── stubba_integration_test.rb
│ └── stubba_test_result_integration_test.rb
│ ├── method_definer.rb
│ ├── test_helper.rb
│ ├── test_runner.rb
│ └── unit
│ ├── any_instance_method_test.rb
│ ├── array_inspect_test.rb
│ ├── auto_verify_test.rb
│ ├── central_test.rb
│ ├── class_method_test.rb
│ ├── date_time_inspect_test.rb
│ ├── expectation_list_test.rb
│ ├── expectation_raiser_test.rb
│ ├── expectation_test.rb
│ ├── hash_inspect_test.rb
│ ├── infinite_range_test.rb
│ ├── metaclass_test.rb
│ ├── missing_expectation_test.rb
│ ├── mock_test.rb
│ ├── multiple_yields_test.rb
│ ├── no_yield_test.rb
│ ├── object_inspect_test.rb
│ ├── object_test.rb
│ ├── parameter_matchers
│ ├── all_of_test.rb
│ ├── any_of_test.rb
│ ├── anything_test.rb
│ ├── has_entry_test.rb
│ ├── has_key_test.rb
│ ├── has_value_test.rb
│ ├── includes_test.rb
│ ├── instance_of_test.rb
│ ├── kind_of_test.rb
│ ├── regexp_matches_test.rb
│ └── stub_matcher.rb
│ ├── pretty_parameters_test.rb
│ ├── return_values_test.rb
│ ├── setup_and_teardown_test.rb
│ ├── single_return_value_test.rb
│ ├── single_yield_test.rb
│ ├── string_inspect_test.rb
│ ├── stub_test.rb
│ └── yield_parameters_test.rb
├── jakarta-oro-2.0.8.jar
├── jaxen-1.1.1.jar
├── jbehave-1.0.1.jar
├── jetty-6.0.2.jar
├── jetty-util-6.0.2.jar
├── jmock-2.2.0.jar
├── jmock-junit4-2.2.0.jar
├── jmock-legacy-2.2.0.jar
├── junit-4.4.jar
├── jyaml-1.3.jar
├── log4j-1.2.9.jar
├── mocha-0.5.5
├── COPYING
├── MIT-LICENSE
├── README
├── RELEASE
├── Rakefile
├── examples
│ ├── misc.rb
│ ├── mocha.rb
│ └── stubba.rb
├── lib
│ ├── mocha.rb
│ ├── mocha
│ │ ├── any_instance_method.rb
│ │ ├── auto_verify.rb
│ │ ├── central.rb
│ │ ├── class_method.rb
│ │ ├── deprecation.rb
│ │ ├── exception_raiser.rb
│ │ ├── expectation.rb
│ │ ├── expectation_error.rb
│ │ ├── expectation_list.rb
│ │ ├── infinite_range.rb
│ │ ├── inspect.rb
│ │ ├── instance_method.rb
│ │ ├── is_a.rb
│ │ ├── metaclass.rb
│ │ ├── missing_expectation.rb
│ │ ├── mock.rb
│ │ ├── multiple_yields.rb
│ │ ├── no_yields.rb
│ │ ├── object.rb
│ │ ├── parameter_matchers.rb
│ │ ├── parameter_matchers
│ │ │ ├── all_of.rb
│ │ │ ├── any_of.rb
│ │ │ ├── anything.rb
│ │ │ ├── has_entry.rb
│ │ │ ├── has_key.rb
│ │ │ ├── has_value.rb
│ │ │ ├── includes.rb
│ │ │ ├── instance_of.rb
│ │ │ ├── kind_of.rb
│ │ │ └── regexp_matches.rb
│ │ ├── pretty_parameters.rb
│ │ ├── return_values.rb
│ │ ├── setup_and_teardown.rb
│ │ ├── single_return_value.rb
│ │ ├── single_yield.rb
│ │ ├── standalone.rb
│ │ ├── stub.rb
│ │ ├── test_case_adapter.rb
│ │ └── yield_parameters.rb
│ ├── mocha_standalone.rb
│ └── stubba.rb
└── test
│ ├── acceptance
│ ├── expected_invocation_count_acceptance_test.rb
│ ├── mocha_acceptance_test.rb
│ ├── mocked_methods_dispatch_acceptance_test.rb
│ ├── parameter_matcher_acceptance_test.rb
│ ├── standalone_acceptance_test.rb
│ └── stubba_acceptance_test.rb
│ ├── active_record_test_case.rb
│ ├── deprecation_disabler.rb
│ ├── execution_point.rb
│ ├── integration
│ ├── mocha_test_result_integration_test.rb
│ ├── stubba_integration_test.rb
│ └── stubba_test_result_integration_test.rb
│ ├── method_definer.rb
│ ├── test_helper.rb
│ ├── test_runner.rb
│ └── unit
│ ├── any_instance_method_test.rb
│ ├── array_inspect_test.rb
│ ├── auto_verify_test.rb
│ ├── central_test.rb
│ ├── class_method_test.rb
│ ├── date_time_inspect_test.rb
│ ├── expectation_list_test.rb
│ ├── expectation_raiser_test.rb
│ ├── expectation_test.rb
│ ├── hash_inspect_test.rb
│ ├── infinite_range_test.rb
│ ├── metaclass_test.rb
│ ├── missing_expectation_test.rb
│ ├── mock_test.rb
│ ├── multiple_yields_test.rb
│ ├── no_yield_test.rb
│ ├── object_inspect_test.rb
│ ├── object_test.rb
│ ├── parameter_matchers
│ ├── all_of_test.rb
│ ├── any_of_test.rb
│ ├── anything_test.rb
│ ├── has_entry_test.rb
│ ├── has_key_test.rb
│ ├── has_value_test.rb
│ ├── includes_test.rb
│ ├── instance_of_test.rb
│ ├── kind_of_test.rb
│ ├── regexp_matches_test.rb
│ └── stub_matcher.rb
│ ├── pretty_parameters_test.rb
│ ├── return_values_test.rb
│ ├── setup_and_teardown_test.rb
│ ├── single_return_value_test.rb
│ ├── single_yield_test.rb
│ ├── string_inspect_test.rb
│ ├── stub_test.rb
│ └── yield_parameters_test.rb
├── objenesis-1.0.jar
├── pmd-4.2.2.jar
├── proxytoys-0.2.1.jar
├── selenium-java-client-driver-1.0-SNAPSHOT.jar
├── servlet-api-2.5-6.1.5.jar
└── testng-5.7-jdk15.jar
/.gitignore:
--------------------------------------------------------------------------------
1 | # git-ls-files --others --exclude-from=.git/info/exclude
2 | # Lines that start with '#' are comments.
3 | # For a project mostly in C, the following would be a good set of
4 | # exclude patterns (uncomment them if you want to use them):
5 | # *.[oa]
6 | # *~
7 | target
8 | doc/website/faq.html
9 | examples/ruby/tmp
10 | test-output
11 | .dotest
12 |
--------------------------------------------------------------------------------
/All.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/ChangeLog:
--------------------------------------------------------------------------------
1 |
2 | Summary of changes from v0.9.3 to v0.9.4
3 | ========================================
4 |
5 | Philippe Hanrigou :
6 |
7 | * Sample parallel test suite using Ruby/RSpec
8 |
9 | * Converted Demo to TestNG
10 |
11 | * Made Selenium Grid work with Selenium 0.9.3 RC.
12 | Latest RC has changed the way the session IDs are set and
13 | is now using GUIDs.
14 |
15 | * Allow custom arguments to be passed to RCs at startup
16 |
17 | ant -DseleniumArgs="..." launch-remote-control
18 |
19 | * Bug Fix: Can handle commands with huge text payload.
20 | Use POST not GET to transfer commands to RCs to be able
21 | to process type commands with a huge text
22 |
23 | * Bug Fix: Properly handle international characters.
24 | Fixed HttpClient wrapper to assume UTF-8 as Charset is
25 | not explicitely set.
26 |
27 | * Introduced JRuby for testing
28 |
29 |
30 | Clinton Bishop:
31 |
32 | * Helped converting some tests to JRuby
33 |
34 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | Thank you for using Selenium Grid
2 |
3 | Have a look at :
4 |
5 | * Website content : ./doc/website/index.html
6 | * Developer documentation: ./doc directory
7 |
8 | If you have any problem contact Philippe Hanrigou:
9 | http://ph7spot.com/about/contact_me
10 |
11 |
--------------------------------------------------------------------------------
/agent/Agent.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/agent/src/main/java/com/thoughtworks/selenium/grid/agent/AgentRegistry.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.agent;
2 |
3 | import org.apache.commons.logging.Log;
4 | import org.apache.commons.logging.LogFactory;
5 |
6 | /*
7 | * Agent application registry.
8 | *
9 | * Provides access to configuration.
10 | */
11 | public class AgentRegistry {
12 |
13 | private static final Log LOGGER = LogFactory.getLog(AgentRegistry.class);
14 | private static AgentRegistry singleton;
15 | private AgentConfiguration agentConfiguration;
16 |
17 | public static synchronized AgentRegistry registry() {
18 | if (null == singleton) {
19 | singleton = new AgentRegistry();
20 | }
21 | return singleton;
22 | }
23 |
24 | public synchronized AgentConfiguration agentConfiguration() {
25 | if (null == agentConfiguration) {
26 | agentConfiguration = new AgentConfiguration();
27 | LOGGER.info("Loaded agent configuration:\n" + agentConfiguration);
28 | }
29 | return agentConfiguration;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/agent/src/main/java/com/thoughtworks/selenium/grid/agent/AgentResource.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.agent;
2 |
3 | import com.thoughtworks.selenium.grid.webserver.Resource;
4 | import com.thoughtworks.selenium.grid.HttpParameters;
5 |
6 | /**
7 | */
8 | public class AgentResource extends Resource {
9 |
10 | public String process(HttpParameters params) {
11 | return "Selenium Grid Agent";
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/agent/src/main/java/com/thoughtworks/selenium/grid/agent/AgentServer.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.agent;
2 |
3 | import com.thoughtworks.selenium.grid.webserver.WebServer;
4 |
5 | /**
6 | * TODO
7 | */
8 | public class AgentServer extends WebServer {
9 |
10 | public AgentServer(int port) {
11 | super(port, RouteResolver.class);
12 | }
13 |
14 | public static void main(String[] args) throws Exception {
15 | final AgentServer server;
16 |
17 | server = new AgentServer(4443);
18 | server.launch();
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/agent/src/main/java/com/thoughtworks/selenium/grid/agent/Classpath.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.agent;
2 |
3 | import com.thoughtworks.selenium.grid.Join;
4 |
5 | import java.util.List;
6 | import java.util.LinkedList;
7 | import java.io.File;
8 |
9 | /**
10 | * Describes a simple Java classpath.
11 | */
12 | public class Classpath {
13 |
14 | private final List entries;
15 |
16 | public Classpath() {
17 | entries = new LinkedList();
18 | }
19 |
20 | public String[] entries() {
21 | return entries.toArray(new String[entries.size()]);
22 | }
23 |
24 | public void add(String newEntry) {
25 | entries.add(newEntry);
26 | }
27 |
28 | public String toString() {
29 | return new Join(entries, File.pathSeparator).toString();
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/agent/src/main/java/com/thoughtworks/selenium/grid/agent/RemoteControlCommand.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.agent;
2 |
3 | import com.thoughtworks.selenium.grid.webserver.Resource;
4 | import com.thoughtworks.selenium.grid.HttpParameters;
5 |
6 | /**
7 | * TODO
8 | */
9 | public class RemoteControlCommand extends Resource {
10 |
11 | public String process(HttpParameters params) {
12 | return null;
13 | }
14 |
15 | public RemoteControlConfiguration parseRemoteControlConfiguration(HttpParameters httpParameters) {
16 | final RemoteControlConfiguration configuration;
17 |
18 | configuration = new RemoteControlConfiguration();
19 | if (null != httpParameters.get("port")) {
20 | final Integer port;
21 | port = Integer.parseInt(httpParameters.get("port"));
22 |
23 | configuration.setPort(port);
24 | }
25 |
26 | return configuration;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/agent/src/main/java/com/thoughtworks/selenium/grid/agent/RemoteControlConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.agent;
2 |
3 | /**
4 | * Configuration used by Agent to launch a new Remote Control.
5 | */
6 | public class RemoteControlConfiguration {
7 |
8 | private int port;
9 |
10 | public RemoteControlConfiguration() {
11 | this.port = 4444;
12 | }
13 |
14 | public int port() {
15 | return port;
16 | }
17 |
18 | public void setPort(int newPortNumber) {
19 | this.port = newPortNumber;
20 | }
21 |
22 | public String host() {
23 | return "0.0.0.0";
24 | }
25 |
26 | public String environment() {
27 | return "*chrome";
28 | }
29 |
30 | public String additionalSeleniumArgs() {
31 | return null;
32 | }
33 |
34 | public String hubURL() {
35 | return "http://localhost:4444";
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/agent/src/main/java/com/thoughtworks/selenium/grid/agent/RouteResolver.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.agent;
2 |
3 | import com.thoughtworks.selenium.grid.webserver.Resource;
4 | import com.thoughtworks.selenium.grid.webserver.InvalidRouteException;
5 |
6 | import javax.servlet.http.HttpServletRequest;
7 |
8 | /**
9 | * Resolve an HTTP request to a specific controller.
10 | */
11 | public class RouteResolver implements com.thoughtworks.selenium.grid.webserver.RouteResolver {
12 |
13 | public Resource resolve(HttpServletRequest request) {
14 | final String path;
15 | path = request.getPathInfo();
16 |
17 | if ("/".equals(path)) {
18 | return new AgentResource();
19 | } else if ("/remote-controls".equals(path) && "POST".equals(request.getMethod())) {
20 | return new RemoteControlCommand();
21 | }
22 | throw new InvalidRouteException(request.getPathInfo());
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/agent/src/test/unit/java/com/thoughtworks/selenium/grid/agent/AgentRegistryTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.agent;
2 |
3 | import static org.junit.Assert.assertNotNull;
4 | import static org.junit.Assert.assertSame;
5 | import org.junit.Test;
6 |
7 | public class AgentRegistryTest {
8 |
9 | @Test
10 | public void registryReturnsAValidInstance() {
11 | assertNotNull(AgentRegistry.registry());
12 | }
13 |
14 | public void registryReturnsASingletonInstance() {
15 | assertSame(AgentRegistry.registry(), AgentRegistry.registry());
16 | }
17 |
18 | @Test
19 | public void agentConfigurationReturnsAValidInstance() {
20 | assertNotNull(AgentRegistry.registry().agentConfiguration());
21 | }
22 |
23 | @Test
24 | public void agentConfigurationReturnsAUniqueInstance() {
25 | assertSame(AgentRegistry.registry().agentConfiguration(),
26 | AgentRegistry.registry().agentConfiguration());
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/agent/src/test/unit/java/com/thoughtworks/selenium/grid/agent/AgentResourceTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.agent;
2 |
3 | import org.junit.Test;
4 | import org.junit.Assert;
5 | import com.thoughtworks.selenium.grid.HttpParameters;
6 |
7 | public class AgentResourceTest {
8 |
9 | @Test
10 | public void processReturnAHardCodedString() {
11 | Assert.assertEquals("Selenium Grid Agent", new AgentResource().process(new HttpParameters()));
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/agent/src/test/unit/java/com/thoughtworks/selenium/grid/agent/RemoteControlCommandTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.agent;
2 |
3 | import org.junit.Test;
4 | import org.junit.Assert;
5 | import static org.junit.Assert.assertEquals;
6 | import com.thoughtworks.selenium.grid.HttpParameters;
7 |
8 | public class RemoteControlCommandTest {
9 |
10 | @Test
11 | public void portIs4444WhenNotSpecifiedAsAParameter() {
12 | final RemoteControlConfiguration configuration;
13 |
14 | configuration = new RemoteControlCommand().parseRemoteControlConfiguration(new HttpParameters());
15 | assertEquals(4444, configuration.port());
16 | }
17 |
18 | @Test
19 | public void portIsCanBeSpecifiedAsAParameter() {
20 | final RemoteControlConfiguration configuration;
21 | final HttpParameters httpParameters;
22 |
23 | httpParameters = new HttpParameters();
24 | httpParameters.put("port", "2424");
25 | configuration = new RemoteControlCommand().parseRemoteControlConfiguration(httpParameters);
26 | assertEquals(2424, configuration.port());
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/demo/Demo.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/thoughtworks/selenium/grid/demo/AmazonCommentTestBase.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.demo;
2 |
3 | import static com.thoughtworks.selenium.grid.tools.ThreadSafeSeleniumSessionStorage.session;
4 | import static org.testng.AssertJUnit.assertEquals;
5 | import static org.testng.AssertJUnit.assertTrue;
6 |
7 | /**
8 | * Base class for Amazon Web Acceptance tests
9 | */
10 | public abstract class AmazonCommentTestBase {
11 |
12 | protected void runAmazonScenario() throws Exception {
13 | session().open("/");
14 | session().type("twotabsearchtextbox", "refactoring");
15 | session().click("navGoButtonPanel");
16 | session().waitForPageToLoad("60000");
17 | assertTrue(session().getLocation().startsWith("http://www.amazon.com/s/ref="));
18 | session().click("link=Refactoring: Improving the Design of Existing Code (The Addison-Wesley Object Technology Series)");
19 | session().waitForPageToLoad("60000");
20 | assertEquals("1", session().getValue("name=quantity"));
21 | assertTrue(session().isTextPresent("excellent"));
22 | assertTrue(session().isTextPresent("Hidden Treasure"));
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/doc/resources/DELL Server.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/resources/DELL Server.jpg
--------------------------------------------------------------------------------
/doc/resources/Rakefile:
--------------------------------------------------------------------------------
1 | def export_png(file, width, postfix)
2 | sh "inkscape --export-png=\"../website/diagrams/#{file}#{postfix}.png\" --export-width=#{width} --export-background-opacity=0 \"#{file}.svg\""
3 | end
4 |
5 | def export_diagram(file)
6 | export_png file, 700, " - Small"
7 | export_png file, 1024, ""
8 | end
9 |
10 | task :default => :export
11 |
12 | task :export do
13 | export_diagram "Requesting a Specific Environment"
14 | export_diagram "Multiple Environments Demo Setup"
15 | export_diagram "Selenium Grid Setup"
16 | export_diagram "Multiple Machine Demo Setup"
17 | export_diagram "Traditional Selenium Setup"
18 | end
19 |
--------------------------------------------------------------------------------
/doc/resources/applelogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/resources/applelogo.png
--------------------------------------------------------------------------------
/doc/resources/iMac.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/resources/iMac.jpeg
--------------------------------------------------------------------------------
/doc/resources/macbookpro.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/resources/macbookpro.jpg
--------------------------------------------------------------------------------
/doc/website/Rakefile:
--------------------------------------------------------------------------------
1 | #
2 | # Generate documentation to be published on Selenium Grid website
3 | #
4 |
5 | task :default => [ :generate_faq, :copy_stylesheets, :copy_images, :copy_pages]
6 |
7 | OUTPUT_DIR = "../../../website/src/main/webapp"
8 |
9 | task :copy_images do
10 | mkdir_p File.join(OUTPUT_DIR, "images")
11 | cp Dir["images/*.png"], File.join(OUTPUT_DIR, "images")
12 | mkdir_p File.join(OUTPUT_DIR, "diagrams")
13 | cp Dir["diagrams/*.png"], File.join(OUTPUT_DIR, "diagrams")
14 | end
15 |
16 | task :copy_pages do
17 | cp Dir["./*.html"], OUTPUT_DIR
18 | end
19 |
20 | task :copy_stylesheets do
21 | mkdir_p File.join(OUTPUT_DIR, "stylesheets")
22 | cp Dir["stylesheets/*"], File.join(OUTPUT_DIR, "stylesheets")
23 | end
24 |
25 | task :copy_javascripts do
26 | mkdir_p File.join(OUTPUT_DIR, "javascripts")
27 | cp Dir["javascripts/*"], File.join(OUTPUT_DIR, "javascripts")
28 | end
29 |
30 |
31 | task :generate_faq do
32 | sh "maruku faq.markdown"
33 | end
34 |
35 |
--------------------------------------------------------------------------------
/doc/website/diagrams/Multiple Environment Demo Setup - Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/diagrams/Multiple Environment Demo Setup - Small.png
--------------------------------------------------------------------------------
/doc/website/diagrams/Multiple Environment Demo Setup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/diagrams/Multiple Environment Demo Setup.png
--------------------------------------------------------------------------------
/doc/website/diagrams/Multiple Machine Demo Setup - Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/diagrams/Multiple Machine Demo Setup - Small.png
--------------------------------------------------------------------------------
/doc/website/diagrams/Multiple Machine Demo Setup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/diagrams/Multiple Machine Demo Setup.png
--------------------------------------------------------------------------------
/doc/website/diagrams/Requesting a Specific Environment - Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/diagrams/Requesting a Specific Environment - Small.png
--------------------------------------------------------------------------------
/doc/website/diagrams/Requesting a Specific Environment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/diagrams/Requesting a Specific Environment.png
--------------------------------------------------------------------------------
/doc/website/diagrams/Selenium Grid Setup - Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/diagrams/Selenium Grid Setup - Small.png
--------------------------------------------------------------------------------
/doc/website/diagrams/Selenium Grid Setup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/diagrams/Selenium Grid Setup.png
--------------------------------------------------------------------------------
/doc/website/diagrams/Traditional Selenium Setup - Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/diagrams/Traditional Selenium Setup - Small.png
--------------------------------------------------------------------------------
/doc/website/diagrams/Traditional Selenium Setup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/diagrams/Traditional Selenium Setup.png
--------------------------------------------------------------------------------
/doc/website/images/ant_version_osx_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/ant_version_osx_screenshot.png
--------------------------------------------------------------------------------
/doc/website/images/background_better.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/background_better.png
--------------------------------------------------------------------------------
/doc/website/images/background_feedback.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/background_feedback.png
--------------------------------------------------------------------------------
/doc/website/images/background_participate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/background_participate.png
--------------------------------------------------------------------------------
/doc/website/images/background_started.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/background_started.png
--------------------------------------------------------------------------------
/doc/website/images/check_path_osx_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/check_path_osx_screenshot.png
--------------------------------------------------------------------------------
/doc/website/images/dot_profile_editing_osx_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/dot_profile_editing_osx_screenshot.png
--------------------------------------------------------------------------------
/doc/website/images/dot_profile_osx_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/dot_profile_osx_screenshot.png
--------------------------------------------------------------------------------
/doc/website/images/install/linux/linux-ant-install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install/linux/linux-ant-install.png
--------------------------------------------------------------------------------
/doc/website/images/install/linux/linux-ant-profile-update.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install/linux/linux-ant-profile-update.png
--------------------------------------------------------------------------------
/doc/website/images/install/linux/linux-ant-verify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install/linux/linux-ant-verify.png
--------------------------------------------------------------------------------
/doc/website/images/install/linux/linux-ant-version.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install/linux/linux-ant-version.png
--------------------------------------------------------------------------------
/doc/website/images/install/linux/linux-java-version.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install/linux/linux-java-version.png
--------------------------------------------------------------------------------
/doc/website/images/install/linux/linux-navigate-path.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install/linux/linux-navigate-path.png
--------------------------------------------------------------------------------
/doc/website/images/install/linux/linux-selenium-install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install/linux/linux-selenium-install.png
--------------------------------------------------------------------------------
/doc/website/images/install/linux/linux-selenium-sanity-check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install/linux/linux-selenium-sanity-check.png
--------------------------------------------------------------------------------
/doc/website/images/install/win/ant-check-path.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install/win/ant-check-path.bmp
--------------------------------------------------------------------------------
/doc/website/images/install/win/ant-update-path.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install/win/ant-update-path.bmp
--------------------------------------------------------------------------------
/doc/website/images/install/win/ant-version.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install/win/ant-version.bmp
--------------------------------------------------------------------------------
/doc/website/images/install/win/java-version.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install/win/java-version.bmp
--------------------------------------------------------------------------------
/doc/website/images/install/win/selenium-check.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install/win/selenium-check.bmp
--------------------------------------------------------------------------------
/doc/website/images/install_ant_osx_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/install_ant_osx_screenshot.png
--------------------------------------------------------------------------------
/doc/website/images/installing_grid_osx_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/installing_grid_osx_screenshot.png
--------------------------------------------------------------------------------
/doc/website/images/java_version_osx_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/java_version_osx_screenshot.png
--------------------------------------------------------------------------------
/doc/website/images/sanity_check_osx_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/sanity_check_osx_screenshot.png
--------------------------------------------------------------------------------
/doc/website/images/selenium_grid_logo_large.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/doc/website/images/selenium_grid_logo_large.png
--------------------------------------------------------------------------------
/doc/website/stylesheets/faq.css:
--------------------------------------------------------------------------------
1 | div.maruku_toc ul li a {
2 | font-size: 1.3em;
3 | font-weight: bold;
4 | color: black;
5 | }
6 |
7 | div.maruku_toc ul li ul {
8 | margin: 0 0 1em 0;
9 | }
10 |
11 | div.maruku_toc ul li ul li a {
12 | font-size: 1.1em;
13 | font-weight: normal;
14 | color: #222;
15 | }
16 |
17 | h1 {
18 | font: bold 2em "Lucida Grande", Verdana, sans-serif;
19 | color: #666;
20 | padding: .2em .2em;
21 | margin-left: .5em;
22 | margin-top: 2em;
23 | }
24 |
25 | h2 {
26 | font: bold 1.4em "Lucida Grande", Verdana, sans-serif;
27 | padding: .2em .2em;
28 | border: 0;
29 | border-bottom: solid medium #a20017;
30 | background: none;
31 | margin-left: 1.3em;
32 | }
33 |
34 | h3 {
35 | font: bold 1.2em "Lucida Grande", Verdana, sans-serif;
36 | padding: .2em .2em;
37 | border: 0;
38 | border-bottom: solid thin #444;
39 | color: #a20017;
40 | background: none;
41 | margin-left: 1.8em;
42 | }
43 |
44 | blockquote p {
45 | color: #666;
46 | }
--------------------------------------------------------------------------------
/examples/ec2/etc/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/examples/ec2/etc/background.png
--------------------------------------------------------------------------------
/examples/ec2/lib/selenium_grid/aws/cloud.rb:
--------------------------------------------------------------------------------
1 | module SeleniumGrid
2 | module AWS
3 |
4 | class Cloud
5 | FILE = "cloud.yml"
6 | attr_accessor :hub, :farms
7 |
8 | def self.load
9 | begin
10 | YAML.load(File.read(FILE))
11 | rescue Errno::ENOENT
12 | new
13 | end
14 | end
15 |
16 | def self.update
17 | cloud = self.load
18 | yield cloud
19 | ensure
20 | cloud.write unless cloud.nil?
21 | end
22 |
23 | def write
24 | File.open(FILE, "w") {|file| file.write(self.to_yaml)}
25 | end
26 |
27 | def farms
28 | @farms ||= []
29 | end
30 |
31 | end
32 |
33 | end
34 | end
35 |
36 |
--------------------------------------------------------------------------------
/examples/ec2/lib/selenium_grid/aws/ec2.rb:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require "yaml"
3 | require File.dirname(__FILE__) + '/cloud'
4 | require File.dirname(__FILE__) + '/ec2_client'
5 | require File.dirname(__FILE__) + '/server'
6 | require File.dirname(__FILE__) + '/hub'
7 | require File.dirname(__FILE__) + '/remote_command'
8 |
--------------------------------------------------------------------------------
/examples/ec2/lib/selenium_grid/aws/hub.rb:
--------------------------------------------------------------------------------
1 | module SeleniumGrid
2 | module AWS
3 |
4 | class Hub < Server
5 |
6 | def url
7 | "http://#{public_dns}:4444"
8 | end
9 |
10 | def private_url
11 | "http://#{private_dns}:4444"
12 | end
13 |
14 | def console_url
15 | "#{url}/console"
16 | end
17 |
18 | end
19 |
20 | end
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/examples/ec2/test/unit/all_test.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | Dir['**/*_test.rb'].each {|test_file| require test_file }
--------------------------------------------------------------------------------
/examples/ec2/test/unit/cloud_test.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + "/test_helper"
2 |
3 | unit_tests do
4 |
5 | test "hub is nil on a fresh cloud" do
6 | assert_nil SeleniumGrid::AWS::Cloud.new.hub
7 | end
8 |
9 | test "hub return the latest assigned hub instance" do
10 | cloud = SeleniumGrid::AWS::Cloud.new
11 | cloud.hub = :old_hub
12 | cloud.hub = :new_hub
13 | assert_equal :new_hub, cloud.hub
14 | end
15 |
16 | test "remote_control_farms is empty on a fresh cloud" do
17 | assert_equal [], SeleniumGrid::AWS::Cloud.new.farms
18 | end
19 |
20 | test "remote_control_farms returns all added farms" do
21 | cloud = SeleniumGrid::AWS::Cloud.new
22 | cloud.farms << :a_farm
23 | cloud.farms << :another_farm
24 | assert_equal [:a_farm, :another_farm], cloud.farms
25 | end
26 |
27 | end
--------------------------------------------------------------------------------
/examples/ec2/test/unit/hub_test.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + "/test_helper"
2 |
3 | unit_tests do
4 |
5 | test "url return the public url where the hub can be contacted" do
6 | hub = SeleniumGrid::AWS::Hub.new nil
7 | hub.public_dns = "public.dns"
8 | assert_equal "http://public.dns:4444", hub.url
9 | end
10 |
11 | test "private_url return the private url where the hub can be contacted" do
12 | hub = SeleniumGrid::AWS::Hub.new nil
13 | hub.private_dns = "private.dns"
14 | assert_equal "http://private.dns:4444", hub.private_url
15 | end
16 |
17 | test "console_url return the public url of the hub console" do
18 | hub = SeleniumGrid::AWS::Hub.new nil
19 | hub.public_dns = "public.dns"
20 | assert_equal "http://public.dns:4444/console", hub.console_url
21 | end
22 |
23 |
24 | end
--------------------------------------------------------------------------------
/examples/ec2/test/unit/server_test.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + "/test_helper"
2 |
3 | unit_tests do
4 |
5 | test "refresh_status updates public dns" do
6 | server = SeleniumGrid::AWS::Server.new :an_instance_id
7 | SeleniumGrid::AWS::Server.expects(:describe).with(:an_instance_id).
8 | returns(:public_dns => :new_public_dns)
9 | server.refresh_status
10 | assert_equal :new_public_dns, server.public_dns
11 | end
12 |
13 | test "refresh_status updates private dns" do
14 | server = SeleniumGrid::AWS::Server.new :an_instance_id
15 | SeleniumGrid::AWS::Server.expects(:describe).with(:an_instance_id).
16 | returns(:private_dns => :new_private_dns)
17 | server.refresh_status
18 | assert_equal :new_private_dns, server.private_dns
19 | end
20 |
21 |
22 | end
--------------------------------------------------------------------------------
/examples/ec2/test/unit/test_helper.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + "/../../lib/selenium_grid/aws/ec2"
2 | require "rubygems"
3 | require "dust"
4 | require "mocha"
5 |
--------------------------------------------------------------------------------
/examples/ec2/vnc_password:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/examples/ec2/vnc_password
--------------------------------------------------------------------------------
/examples/java/Java Example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/examples/java/testng-slow.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/java/testng.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/ruby/Ruby Example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/ruby/agile_developer_spec.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2 |
3 | describe "Agile Developer" do
4 | include BookExample
5 |
6 | it "demonstrates integrity and discipline" do
7 | as_described_on_amazon \
8 | :title => "Extreme Programming Explained: Embrace Change",
9 | :anchor => "Extreme Programming Explained: Embrace Change (2nd Edition) (The XP Series)",
10 | :keywords => "Extreme Programming",
11 | :isbn => "0321278658"
12 |
13 | end
14 |
15 | it "is positive and pragmatic" do
16 | as_described_on_amazon \
17 | :title => "The Pragmatic Programmer: From Journeyman to Master",
18 | :anchor => "The Pragmatic Programmer: From Journeyman to Master",
19 | :keywords => "Pragmatic Programmer",
20 | :isbn => "020161622"
21 | end
22 |
23 | end
24 |
25 |
--------------------------------------------------------------------------------
/examples/ruby/agile_project_manager_spec.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2 |
3 | describe "Agile Project Manager" do
4 | include BookExample
5 |
6 | it "regularly ships working software " do
7 | as_described_on_amazon \
8 | :title => "Ship it! A Practical Guide to Successful Software Projects",
9 | :anchor => "Ship it! A Practical Guide to Successful Software Projects",
10 | :keywords => "Ship It",
11 | :isbn => "0974514047"
12 |
13 | end
14 |
15 | it "improves the overall process" do
16 | as_described_on_amazon \
17 | :title => "Agile Retrospectives: Making Good Teams Great",
18 | :anchor => "Agile Retrospectives: Making Good Teams Great",
19 | :keywords => "Agile Retrospectives",
20 | :isbn => "0977616649"
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/examples/ruby/book_example.rb:
--------------------------------------------------------------------------------
1 | module BookExample
2 |
3 | def as_described_on_amazon(options)
4 | @selenium.open "/"
5 | @selenium.select "url", "Books"
6 | @selenium.type "twotabsearchtextbox", options[:keywords]
7 | @selenium.click_and_wait "navGoButtonPanel"
8 | @selenium.is_text_present(options[:title]).should be_true
9 | @selenium.click_and_wait "link=#{options[:anchor]}"
10 | @selenium.field("name=quantity").should == "1"
11 | @selenium.is_text_present("ISBN-10: #{options[:isbn]}").should be_true
12 | @selenium.click_and_wait "link=Explore similar items"
13 | @selenium.wait_for_page_to_load 60000
14 | @selenium.go_back
15 | @selenium.wait_for_page_to_load 60000
16 | @selenium.field("quantity").should == "1"
17 | @selenium.select "quantity", "label=5"
18 | @selenium.click_and_wait "submit.add-to-cart"
19 | @selenium.is_text_present("Added to your\nShopping Cart:").should be_true
20 | @selenium.is_text_present(options[:title]).should be_true
21 | @selenium.is_text_present("quantity: 5").should be_true
22 | end
23 |
24 | end
--------------------------------------------------------------------------------
/examples/ruby/good_developer_spec.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2 |
3 | describe "Good Developer" do
4 | include BookExample
5 |
6 | it "refactors aggressively" do
7 | as_described_on_amazon \
8 | :title => "Refactoring: Improving the Design of Existing Code",
9 | :anchor => "Refactoring: Improving the Design of Existing Code (The Addison-Wesley Object Technology Series)",
10 | :keywords => "Refactoring",
11 | :isbn => "0201485672"
12 |
13 | end
14 |
15 | it "drive its design with tests" do
16 | as_described_on_amazon \
17 | :title => "Test Driven Development: By Example",
18 | :anchor => "Test Driven Development: By Example (The Addison-Wesley Signature Series)",
19 | :keywords => "Test Driven Development",
20 | :isbn => "0321146530"
21 |
22 | end
23 |
24 | end
--------------------------------------------------------------------------------
/examples/ruby/lib/array_extension.rb:
--------------------------------------------------------------------------------
1 | module ArrayExtension
2 |
3 | def /(number_of_buckets)
4 | buckets = (1..number_of_buckets).collect { [] }
5 | while self.any? do
6 | buckets.each do |bucket|
7 | bucket << self.shift if self.any?
8 | end
9 | end
10 | buckets
11 | end
12 |
13 | end
14 |
--------------------------------------------------------------------------------
/examples/ruby/lib/multi_process_behaviour_runner.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path(File.dirname(__FILE__) + '/array_extension')
2 | Array.send :include, ArrayExtension
3 |
4 | class MultiProcessSpecRunner
5 |
6 | def initialize(max_concurrent_processes = 10)
7 | @max_concurrent_processes = max_concurrent_processes
8 | end
9 |
10 | def run(spec_files)
11 | concurrent_processes = [ @max_concurrent_processes, spec_files.size ].min
12 | spec_files_by_process = spec_files / concurrent_processes
13 | concurrent_processes.times do |i|
14 | cmd = "spec #{spec_files_by_process[i].join(' ')}"
15 | puts "Launching #{cmd}"
16 | exec(cmd) if fork == nil
17 | end
18 | success = true
19 | concurrent_processes.times do |i|
20 | pid, status = Process.wait2
21 | puts "Test process ##{i} with pid #{pid} completed with #{status}"
22 | success &&= status.exitstatus.zero?
23 | end
24 |
25 | raise "Build failed" unless success
26 | end
27 |
28 | end
29 |
--------------------------------------------------------------------------------
/examples/ruby/lib/selenium_driver_extensions.rb:
--------------------------------------------------------------------------------
1 | module SeleniumDriverExtensions
2 |
3 | def location
4 | get_location
5 | end
6 |
7 | def field(locator)
8 | get_value locator
9 | end
10 |
11 | def wait_for_element(field_name, time=60000)
12 | script = <<-EOS
13 | var element;
14 | try {
15 | element = selenium.browserbot.findElement('#{field_name}');
16 | } catch(e) {
17 | element = null;
18 | }
19 | element != null
20 | EOS
21 |
22 | wait_for_condition script, time
23 | end
24 |
25 | def wait_for_text(field_name, text, time=60000)
26 | script = <<-EOS
27 | var element;
28 | try {
29 | element = selenium.browserbot.findElement('#{field_name}');
30 | } catch(e) {
31 | element = null;
32 | }
33 | element != null && element.innerHTML == '#{text}'"
34 | EOS
35 |
36 | wait_for_condition script, time
37 | end
38 |
39 | def click_and_wait(locator, timeout=60000)
40 | click locator
41 | wait_for_page_to_load timeout
42 | end
43 |
44 | end
45 |
--------------------------------------------------------------------------------
/examples/ruby/lib/spec/screenshot_saver.rb:
--------------------------------------------------------------------------------
1 | module Spec
2 | module ScreenshotSaver
3 |
4 | def save_screenshot_to(png_path)
5 | dir = File.dirname(png_path)
6 | FileUtils.mkdir_p(dir) unless File.directory?(dir)
7 | if PLATFORM['darwin']
8 | sh "screencapture '#{png_path}'"
9 | elsif image_magick_support?
10 | sh "import -window root '#{png_path}'"
11 | end
12 | end
13 |
14 | def image_magick_support?
15 | @image_magick_support ||= `import --version`.grep /"ImageMagick"/
16 | end
17 |
18 | def sh(command)
19 | system command
20 | STDERR.puts "Warning: Could not capture screenshot with '#{command}'" unless $? == 0
21 | end
22 |
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/examples/ruby/rubyist_spec.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2 |
3 | describe "Good Rubyist" do
4 | include BookExample
5 |
6 | it "embraces Ruby" do
7 | as_described_on_amazon \
8 | :title => "Programming Ruby: The Pragmatic Programmers' Guide, Second Edition",
9 | :anchor => "Programming Ruby: The Pragmatic Programmers' Guide, Second Edition",
10 | :keywords => "Ruby",
11 | :isbn => "0974514055"
12 |
13 | end
14 |
15 | it "has style" do
16 | as_described_on_amazon \
17 | :title => "The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming",
18 | :anchor => "The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming (2nd Edition) (Addison-Wesley Professional Ruby Series)",
19 | :keywords => "Ruby",
20 | :isbn => "0672328844"
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/examples/ruby/vendor/selenium-client-1.1/README:
--------------------------------------------------------------------------------
1 | With Ruby installed on your computer....
2 |
3 | Change directories to ./ruby.
4 | Run selenium_example.rb
5 |
6 | Firefox should open, (you may need to add it to your path)
7 | and ruby will drive the testing with Selenium.
8 |
--------------------------------------------------------------------------------
/examples/ruby/vendor/selenium-client-1.1/lib/selenium/client/driver.rb:
--------------------------------------------------------------------------------
1 | module Selenium
2 | module Client
3 |
4 | class Driver
5 | include Selenium::Client::Base
6 | end
7 |
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/examples/ruby/vendor/selenium-client-1.1/lib/selenium/client/selenium_helper.rb:
--------------------------------------------------------------------------------
1 | # Defines a mixin module that you can use to write Selenium tests
2 | # without typing "@selenium." in front of every command. Every
3 | # call to a missing method will be automatically sent to the @selenium
4 | # object.
5 | module Selenium
6 | module Client
7 |
8 | module SeleniumHelper
9 |
10 | # Overrides standard "open" method with @selenium.open
11 | def open(addr)
12 | @selenium.open(addr)
13 | end
14 |
15 | # Overrides standard "type" method with @selenium.type
16 | def type(inputLocator, value)
17 | @selenium.type(inputLocator, value)
18 | end
19 |
20 | # Overrides standard "select" method with @selenium.select
21 | def select(inputLocator, optionLocator)
22 | @selenium.select(inputLocator, optionLocator)
23 | end
24 |
25 | # Passes all calls to missing methods to @selenium
26 | def method_missing(method_name, *args)
27 | if args.empty?
28 | @selenium.send(method_name)
29 | else
30 | @selenium.send(method_name, *args)
31 | end
32 | end
33 | end
34 |
35 | end
36 | end
--------------------------------------------------------------------------------
/examples/ruby/vendor/selenium-client-1.1/lib/selenium/command_error.rb:
--------------------------------------------------------------------------------
1 | module Selenium
2 | class CommandError < RuntimeError
3 | end
4 | end
--------------------------------------------------------------------------------
/examples/ruby/vendor/selenium-client-1.1/lib/selenium/protocol_error.rb:
--------------------------------------------------------------------------------
1 | module Selenium
2 | class ProtocolError < RuntimeError
3 | end
4 | end
--------------------------------------------------------------------------------
/examples/ruby/vendor/selenium-client-1.1/lib/selenium/screenshot_saver.rb:
--------------------------------------------------------------------------------
1 | module Selenium
2 | module ScreenshotSaver
3 |
4 | def save_screenshot_to(png_path)
5 | dir = File.dirname(png_path)
6 | FileUtils.mkdir_p(dir) unless File.directory?(dir)
7 | if PLATFORM['darwin']
8 | sh "screencapture '#{png_path}'"
9 | elsif image_magick_support?
10 | sh "import -window root '#{png_path}'"
11 | end
12 | end
13 |
14 | def image_magick_support?
15 | @image_magick_support ||= `import --version`.grep /"ImageMagick"/
16 | end
17 |
18 | def sh(command)
19 | system command
20 | STDERR.puts "Warning: Could not capture screenshot with '#{command}'" unless $? == 0
21 | end
22 |
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/examples/ruby/vendor/selenium-client-1.1/test/all_unit_tests.rb:
--------------------------------------------------------------------------------
1 | Dir["#{File.dirname __FILE__}/unit/**/*_test.rb"].each do |test_case|
2 | require test_case
3 | end
4 |
--------------------------------------------------------------------------------
/git_exclude:
--------------------------------------------------------------------------------
1 | # git-ls-files --others --exclude-from=.git/info/exclude
2 | # Lines that start with '#' are comments.
3 | # For a project mostly in C, the following would be a good set of
4 | # exclude patterns (uncomment them if you want to use them):
5 | # *.[oa]
6 | # *~
7 | .svn
8 | .class
9 | target
10 | dist
11 |
--------------------------------------------------------------------------------
/hub/Hub Tests.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/hub/lib/freemarker-2.3.10.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/hub/lib/freemarker-2.3.10.jar
--------------------------------------------------------------------------------
/hub/src/main/java/com/thoughtworks/selenium/grid/hub/CommandParsingException.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub;
2 |
3 | /**
4 | * Signals that a problem was detected while parsing a Selenese request.
5 | */
6 | public class CommandParsingException extends RuntimeException {
7 |
8 | public CommandParsingException(String message) {
9 | super(message);
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/hub/src/main/java/com/thoughtworks/selenium/grid/hub/EnvironmentManager.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | /**
9 | * Keep track of the environments offered by the Selenium farm.
10 | */
11 | public class EnvironmentManager {
12 |
13 | private final Map environmentMap;
14 |
15 | public EnvironmentManager() {
16 | this.environmentMap = new HashMap();
17 | }
18 |
19 | public List environments() {
20 | return new ArrayList(environmentMap.values());
21 | }
22 |
23 | public void addEnvironment(Environment newEnvironment) {
24 | synchronized (environmentMap) {
25 | environmentMap.put(newEnvironment.name(), newEnvironment);
26 | }
27 | }
28 |
29 | public Environment environment(String environmentName) {
30 | synchronized (environmentMap) {
31 | return environmentMap.get(environmentName);
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/hub/src/main/java/com/thoughtworks/selenium/grid/hub/management/HubServlet.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub.management;
2 |
3 | import com.thoughtworks.selenium.grid.hub.HubRegistry;
4 |
5 | import javax.servlet.http.HttpServlet;
6 |
7 | /**
8 | * Base class for all servlets exposed by Selenium Grid Hub.
9 | *
10 | *
11 | * Provides access to the global application registry via a method
12 | * that can easily be overriden in unit tests.
13 | */
14 | public class HubServlet extends HttpServlet {
15 |
16 | /**
17 | * Application Registry (singleton)
18 | *
19 | * @return A valid application registry. Never null.
20 | */
21 | protected HubRegistry registry() {
22 | return HubRegistry.registry();
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/hub/src/main/java/com/thoughtworks/selenium/grid/hub/management/LifecycleManager.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub.management;
2 |
3 | import org.apache.commons.logging.Log;
4 | import org.apache.commons.logging.LogFactory;
5 |
6 | /**
7 | * Manages lifecyle of Hub components
8 | */
9 | public class LifecycleManager {
10 |
11 | private static final Log LOGGER = LogFactory.getLog(LifecycleManager.class);
12 |
13 | public void shutdown() {
14 | LOGGER.info("Shutting down Hub...");
15 | System.exit(0);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/hub/src/main/java/com/thoughtworks/selenium/grid/hub/management/LifecycleManagerServlet.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub.management;
2 |
3 | import org.apache.commons.logging.Log;
4 | import org.apache.commons.logging.LogFactory;
5 |
6 | import javax.servlet.http.HttpServletRequest;
7 | import javax.servlet.http.HttpServletResponse;
8 | import javax.servlet.ServletException;
9 | import java.io.IOException;
10 |
11 | /**
12 | * Servlet in charge of shutting down the Hub.
13 | */
14 | public class LifecycleManagerServlet extends HubServlet {
15 |
16 | private static final Log LOGGER = LogFactory.getLog(LifecycleManagerServlet.class);
17 |
18 | public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
19 | final String action;
20 |
21 | action = request.getParameter("action");
22 | LOGGER.info("Requesting life cycle manager action : '" + action + "'");
23 | if ("shutdown".equals(action)) {
24 | registry().lifecycleManager().shutdown();
25 | }
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/hub/src/main/java/com/thoughtworks/selenium/grid/hub/management/RegistrationManagementServlet.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub.management;
2 |
3 | import javax.servlet.ServletException;
4 | import javax.servlet.http.HttpServletRequest;
5 | import javax.servlet.http.HttpServletResponse;
6 | import java.io.IOException;
7 |
8 |
9 | public abstract class RegistrationManagementServlet extends HubServlet {
10 |
11 | protected void doGet(HttpServletRequest request, HttpServletResponse response)
12 | throws ServletException, IOException {
13 | process(request, response);
14 | }
15 |
16 | protected void doPost(HttpServletRequest request, HttpServletResponse response)
17 | throws ServletException, IOException {
18 | process(request, response);
19 | }
20 |
21 | protected abstract void process(HttpServletRequest request, HttpServletResponse response) throws IOException;
22 |
23 | protected void writeSuccessfulResponse(HttpServletResponse response) throws IOException {
24 | response.setContentType("text/plain");
25 | response.setCharacterEncoding("UTF-8");
26 | response.setStatus(HttpServletResponse.SC_OK);
27 | response.getWriter().print("OK");
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/hub/src/main/java/com/thoughtworks/selenium/grid/hub/management/console/ConsoleServlet.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub.management.console;
2 |
3 | import org.apache.commons.logging.Log;
4 | import org.apache.commons.logging.LogFactory;
5 |
6 | import javax.servlet.ServletException;
7 | import javax.servlet.http.HttpServlet;
8 | import javax.servlet.http.HttpServletRequest;
9 | import javax.servlet.http.HttpServletResponse;
10 | import java.io.IOException;
11 |
12 | import com.thoughtworks.selenium.grid.hub.HubRegistry;
13 |
14 | /**
15 | * Gateway to Selenium Farm.
16 | *
17 | * @author Philippe Hanrigou
18 | */
19 | public class ConsoleServlet extends HttpServlet {
20 |
21 | private static final Log logger = LogFactory.getLog(ConsoleServlet.class);
22 |
23 | protected void doGet(HttpServletRequest request, HttpServletResponse response)
24 | throws ServletException, IOException {
25 |
26 | logger.debug("Rendering console...");
27 | controller().process(response);
28 | }
29 |
30 | protected ConsoleController controller() {
31 | return new ConsoleController(HubRegistry.registry());
32 | }
33 | }
--------------------------------------------------------------------------------
/hub/src/main/java/com/thoughtworks/selenium/grid/hub/management/console/mvc/Page.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub.management.console.mvc;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | /**
7 | * Page to render.
8 | * Associates an HTML template with runtime assigns that can be resolved by the template.
9 | */
10 | public class Page {
11 |
12 | private final String template;
13 | private final Map assigns;
14 |
15 | public Page(String template) {
16 | this.template = template;
17 | this.assigns = new HashMap();
18 | }
19 |
20 | public String template() {
21 | return template;
22 | }
23 |
24 | public Map assigns() {
25 | return assigns;
26 | }
27 |
28 | public void set(String name, Object value) {
29 | this.assigns.put(name, value);
30 | }
31 |
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/hub/src/main/java/com/thoughtworks/selenium/grid/hub/management/console/mvc/RenderingException.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub.management.console.mvc;
2 |
3 | /**
4 | * Signals a problem in template rendering.
5 | */
6 | public class RenderingException extends RuntimeException {
7 |
8 | public RenderingException(Throwable originalProblem) {
9 | super(originalProblem);
10 | }
11 |
12 | public RenderingException(String message) {
13 | super(message);
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/hub/src/main/java/com/thoughtworks/selenium/grid/hub/remotecontrol/DynamicRemoteControlPool.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub.remotecontrol;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Remote control pool that grows/shrinks when remote control
7 | * register/unregister themselves.
8 | */
9 | public interface DynamicRemoteControlPool extends RemoteControlPool {
10 |
11 | void register(RemoteControlProxy newRemoteControl);
12 |
13 | boolean unregister(RemoteControlProxy remoteControl);
14 |
15 | List availableRemoteControls();
16 |
17 | List reservedRemoteControls();
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/hub/src/main/java/com/thoughtworks/selenium/grid/hub/remotecontrol/commands/TestCompleteCommand.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub.remotecontrol.commands;
2 |
3 | import com.thoughtworks.selenium.grid.Response;
4 | import com.thoughtworks.selenium.grid.hub.remotecontrol.RemoteControlPool;
5 | import com.thoughtworks.selenium.grid.HttpParameters;
6 |
7 | import java.io.IOException;
8 |
9 | /**
10 | * Selenese command marking the end of a Selenese session.
11 | */
12 | public class TestCompleteCommand extends SeleneseCommand {
13 |
14 | public TestCompleteCommand(String sessionId, HttpParameters parameters) {
15 | super(sessionId, parameters);
16 | }
17 |
18 |
19 | public Response execute(RemoteControlPool pool) throws IOException {
20 | try {
21 | return super.execute(pool);
22 | } finally {
23 | pool.releaseForSession(sessionId());
24 | }
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/hub/src/test/integration/com/thoughtworks/selenium/grid/hub/remotecontrol/SeleniumRCProxyIntegrationTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub.remotecontrol;
2 |
3 | import static junit.framework.Assert.assertEquals;
4 | import static junit.framework.Assert.assertTrue;
5 | import org.junit.Test;
6 |
7 | import java.io.IOException;
8 |
9 | /**
10 | * TODO
11 | *
12 | * @author: Philippe Hanrigou
13 | */
14 | public class SeleniumRCProxyIntegrationTest {
15 |
16 | private static final int VALID_PORT = 5555;
17 |
18 | @Test
19 | public void forwardGetNewBrowserSessionToRemoteControl() throws IOException {
20 | HttpClient client = new HttpClient();
21 | RemoteControlProxy proxy = new RemoteControlProxy("localhost", VALID_PORT, null, client);
22 | Response response = proxy.forward("cmd=getNewBrowserSession&1=*firefox&2=http://www.google.com");
23 | assertEquals(200, response.statusCode());
24 | assertTrue(response.body().startsWith("OK,"));
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/hub/src/test/unit/java/com/thoughtworks/selenium/grid/AssertionHelper.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid;
2 |
3 | import static junit.framework.Assert.assertEquals;
4 | import static junit.framework.Assert.assertFalse;
5 |
6 | /**
7 | * Helper Class for Custom Assertions.
8 | */
9 | public class AssertionHelper {
10 |
11 | public static void assertNotEquals(Object anObject, Object theOther) {
12 | if (null == anObject) {
13 | assertFalse(null == theOther);
14 | } else {
15 | assertFalse(anObject.equals(theOther));
16 | }
17 | }
18 |
19 | public static void assertSameHashCode(Object anObject, Object another) {
20 | assertEquals(anObject.hashCode(), another.hashCode());
21 | }
22 |
23 | public static void assertDistinctHashCodes(Object anObject, Object another) {
24 | assertNotEquals(anObject.hashCode(), another.hashCode());
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/hub/src/test/unit/java/com/thoughtworks/selenium/grid/hub/HubServerTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub;
2 |
3 | import static junit.framework.Assert.assertEquals;
4 | import org.junit.Test;
5 |
6 |
7 | public class HubServerTest {
8 |
9 | @Test
10 | public void mustDoSomething() {
11 | assertEquals(true, true);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/hub/src/test/unit/java/com/thoughtworks/selenium/grid/hub/management/console/ConsoleServletTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub.management.console;
2 |
3 | import org.jbehave.classmock.UsingClassMock;
4 | import org.jbehave.core.mock.Mock;
5 | import org.junit.Test;
6 |
7 | import javax.servlet.http.HttpServletResponse;
8 | import javax.servlet.ServletException;
9 | import java.io.IOException;
10 |
11 |
12 | public class ConsoleServletTest extends UsingClassMock {
13 |
14 | @Test
15 | public void doGetCallsListActionOnConsoleController() throws IOException, ServletException {
16 | final ConsoleServlet servlet;
17 | final Mock controller;
18 | final Mock response;
19 |
20 | response = mock(HttpServletResponse.class);
21 | controller = mock(ConsoleController.class);
22 | servlet = new ConsoleServlet() {
23 | protected ConsoleController controller() {
24 | return (ConsoleController) controller;
25 | }
26 | };
27 |
28 | controller.expects("process").with(response);
29 |
30 | servlet.doGet(null, (HttpServletResponse) response);
31 | verifyMocks();
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/hub/src/test/unit/java/com/thoughtworks/selenium/grid/hub/management/console/mvc/PageTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub.management.console.mvc;
2 |
3 | import static junit.framework.Assert.assertEquals;
4 | import static junit.framework.Assert.assertTrue;
5 | import org.junit.Test;
6 |
7 | public class PageTest {
8 |
9 | @Test
10 | public void templateIsTheOneProvidedInTheConstructor() {
11 | assertEquals("a template", new Page("a template").template());
12 | }
13 |
14 | @Test
15 | public void assignsAreEmptyAfterCreation() {
16 | assertTrue(new Page(null).assigns().isEmpty());
17 | }
18 |
19 | @Test
20 | public void setAddsAKeyValuePairToAssigns() {
21 | final Page page = new Page(null);
22 | page.set("a name", "a value");
23 | assertEquals("a value", page.assigns().get("a name"));
24 | }
25 |
26 | @Test
27 | public void setAcceptsArbitraryObjectsAsValue() {
28 | final Page page = new Page(null);
29 | final Object anonymousObject = new Object() {};
30 | page.set("a name", anonymousObject);
31 | assertEquals(anonymousObject, page.assigns().get("a name"));
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/hub/src/test/unit/java/com/thoughtworks/selenium/grid/hub/management/console/mvc/RenderingExceptionTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.hub.management.console.mvc;
2 |
3 | import junit.framework.Assert;
4 | import org.junit.Test;
5 |
6 |
7 | @SuppressWarnings({"ThrowableInstanceNeverThrown"})
8 | public class RenderingExceptionTest {
9 |
10 | @Test
11 | public void captureOriginalExceptionWhenBuiltFromAThrowable() {
12 | final Throwable originalException = new Throwable() {};
13 | Assert.assertEquals(originalException, new RenderingException(originalException).getCause());
14 | }
15 |
16 | @Test
17 | public void defineMessageWhenBuiltFromAString() {
18 | Assert.assertEquals("a message", new RenderingException("a message").getMessage());
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/hub/src/test/unit/java/com/thoughtworks/selenium/grid/hub/management/console/mvc/a_template.html:
--------------------------------------------------------------------------------
1 | The Template Content
--------------------------------------------------------------------------------
/hub/web/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/infrastructure/core/Core.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/infrastructure/core/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Selenium Grid Core
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/infrastructure/core/src/main/com/thoughtworks/selenium/grid/Join.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid;
2 |
3 | import java.util.Collection;
4 |
5 | /**
6 | * Returns a string created by converting each element of the array to
7 | * a string, separated by speparator.
8 | */
9 | public class Join extends Object {
10 |
11 | private final Collection collection;
12 | private final String separator;
13 |
14 | public Join(Collection collection, String separator) {
15 | this.collection = collection;
16 | this.separator = separator;
17 | }
18 |
19 | public String toString() {
20 | final StringBuffer joinedString;
21 |
22 | if (collection.isEmpty()) {
23 | return "";
24 | }
25 |
26 | joinedString = new StringBuffer();
27 | for (Object entry : collection) {
28 | joinedString.append(entry.toString());
29 | joinedString.append(separator);
30 | }
31 |
32 | return joinedString.substring(0, joinedString.lastIndexOf(separator));
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/infrastructure/core/src/main/com/thoughtworks/selenium/grid/Response.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid;
2 |
3 |
4 | public class Response {
5 |
6 | private final int statusCode;
7 | private final String body;
8 |
9 |
10 | public Response(String errorMessage) {
11 | this(200, "ERROR: " + errorMessage);
12 | }
13 |
14 | public Response(int statusCode, String body) {
15 | this.statusCode = statusCode;
16 | this.body = body;
17 | }
18 |
19 | public int statusCode() {
20 | return statusCode;
21 | }
22 |
23 | public String body() {
24 | return body;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/infrastructure/core/src/main/com/thoughtworks/selenium/grid/configuration/GridConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.configuration;
2 |
3 | import org.ho.yaml.Yaml;
4 |
5 | import java.io.Reader;
6 | import java.io.StringReader;
7 |
8 | /**
9 | * Selenium Grid Configuration.
10 | */
11 | public class GridConfiguration {
12 |
13 | private HubConfiguration hub;
14 |
15 | public GridConfiguration() {
16 | this.hub = new HubConfiguration();
17 | }
18 |
19 | public HubConfiguration getHub() {
20 | return hub;
21 | }
22 |
23 | public void setHub(HubConfiguration hub) {
24 | this.hub = hub;
25 | }
26 |
27 | public static GridConfiguration parse(String yamlDefinition) {
28 | return parse(new StringReader(yamlDefinition));
29 | }
30 |
31 | public String toYAML() {
32 | return Yaml.dump(this, true);
33 | }
34 |
35 | protected static GridConfiguration parse(Reader yamlDefinition) {
36 | return Yaml.loadType(yamlDefinition, GridConfiguration.class);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/infrastructure/core/src/main/com/thoughtworks/selenium/grid/configuration/HubConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.configuration;
2 |
3 | /**
4 | * Selenium Hub Configuration.
5 | */
6 | public class HubConfiguration {
7 |
8 | private int port;
9 | private EnvironmentConfiguration[] environments;
10 |
11 | public HubConfiguration() {
12 | setPort(4444);
13 | environments = new EnvironmentConfiguration[] {};
14 | }
15 |
16 | public int getPort() {
17 | return port;
18 | }
19 |
20 | public void setPort(int port) {
21 | this.port = port;
22 | }
23 |
24 | public EnvironmentConfiguration[] getEnvironments() {
25 | return environments;
26 | }
27 |
28 | public void setEnvironments(EnvironmentConfiguration[] environments) {
29 | this.environments = environments;
30 | }
31 |
32 | }
--------------------------------------------------------------------------------
/infrastructure/core/src/main/grid_configuration.yml:
--------------------------------------------------------------------------------
1 | hub:
2 | port: 4444
3 | environments:
4 | - name: "*firefox"
5 | browser: "*firefox"
6 | - name: "*chrome"
7 | browser: "*chrome"
8 | - name: "*iexplore"
9 | browser: "*iexplore"
10 | - name: "*iehta"
11 | browser: "*iehta"
12 | - name: "*safari"
13 | browser: "*safari"
14 | - name: "*konqueror"
15 | browser: "*konqueror"
16 |
--------------------------------------------------------------------------------
/infrastructure/core/src/test/unit/java/com/thoughtworks/selenium/grid/HttpClientTest.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/infrastructure/core/src/test/unit/java/com/thoughtworks/selenium/grid/HttpClientTest.java
--------------------------------------------------------------------------------
/infrastructure/core/src/test/unit/java/com/thoughtworks/selenium/grid/ResponseTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid;
2 |
3 | import junit.framework.Assert;
4 | import org.junit.Test;
5 | import com.thoughtworks.selenium.grid.Response;
6 |
7 |
8 | public class ResponseTest {
9 |
10 | @Test
11 | public void defaultStatusCodeIs200() {
12 | Assert.assertEquals(200, new Response("").statusCode());
13 | }
14 |
15 | @Test
16 | public void bodyIsAnErrorMessageWhenNoStatusIsProvided() {
17 | Assert.assertEquals("ERROR: a message", new Response("a message").body());
18 | }
19 |
20 | @Test
21 | public void statusCodeReturnsTheOneProvidedInTheConstructor() {
22 | Assert.assertEquals(123, new Response(123, "").statusCode());
23 | }
24 |
25 | @Test
26 | public void bodyReturnsTheOneProvidedInTheConstructor() {
27 | Assert.assertEquals("some content", new Response(0, "some content").body());
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/infrastructure/core/src/test/unit/java/com/thoughtworks/selenium/grid/configuration/ResourceLocatorTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.configuration;
2 |
3 | import static junit.framework.Assert.assertTrue;
4 | import static junit.framework.Assert.assertNotNull;
5 | import org.junit.Test;
6 |
7 |
8 | public class ResourceLocatorTest {
9 |
10 | @Test
11 | public void retrieveResourcesByAbsolutePath() {
12 | assertNotNull(new ResourceLocator(ResourceLocator.class).retrieveContent("/java/lang/Object.class"));
13 | }
14 |
15 | @Test
16 | public void retrieveResourcesByPathRelativeToRootClass() {
17 | assertNotNull(new ResourceLocator(Math.class).retrieveContent("Object.class"));
18 | }
19 |
20 | @Test(expected = IllegalStateException.class)
21 | public void throwAnIllegalStateExceptionWhenResourceCannotBeFound() {
22 | assertNotNull(new ResourceLocator(Math.class).retrieveContent("does/not/exists.class"));
23 | }
24 |
25 | @Test
26 | public void canRetrieveGridConfigurationFromClasspath() {
27 | final String content = new ResourceLocator(ResourceLocator.class).retrieveContent("/grid_configuration.yml");
28 | assertTrue(content.trim().startsWith("hub:"));
29 | }
30 |
31 | }
--------------------------------------------------------------------------------
/infrastructure/webserver/WebServer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/infrastructure/webserver/src/main/java/com/thoughtworks/selenium/grid/webserver/InvalidRouteException.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.webserver;
2 |
3 | /**
4 | * Indicates that an HTTP route in invalid and/or cannot be resolved.
5 | */
6 | public class InvalidRouteException extends RuntimeException {
7 |
8 | private final String path;
9 |
10 | public InvalidRouteException(String path) {
11 | super();
12 | this.path = path;
13 | }
14 |
15 | public String path() {
16 | return path;
17 | }
18 |
19 | public String toString() {
20 | return "[InvalidRouteException path='" + path + "']";
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/infrastructure/webserver/src/main/java/com/thoughtworks/selenium/grid/webserver/Resource.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.webserver;
2 |
3 | import com.thoughtworks.selenium.grid.HttpParameters;
4 |
5 | /**
6 | */
7 | public abstract class Resource {
8 |
9 | public abstract String process(HttpParameters params);
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/infrastructure/webserver/src/main/java/com/thoughtworks/selenium/grid/webserver/RouteResolver.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.webserver;
2 |
3 | import javax.servlet.http.HttpServletRequest;
4 |
5 | /**
6 | * Resolve an HTTP request to a specific resource.
7 | */
8 | public interface RouteResolver {
9 |
10 | Resource resolve(HttpServletRequest request);
11 |
12 | }
--------------------------------------------------------------------------------
/infrastructure/webserver/src/test/unit/java/com/thoughtworks/selenium/grid/webserver/InvalidRouteExceptionTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.webserver;
2 |
3 | import static org.junit.Assert.assertEquals;
4 | import org.junit.Test;
5 |
6 | public class InvalidRouteExceptionTest {
7 |
8 | @Test
9 | public void pathReturnsThePathThatWasGivenInTheConstructor() {
10 | assertEquals("/a/path", new InvalidRouteException("/a/path").path());
11 | }
12 |
13 | @Test
14 | public void toStringReturnsAHumanFriendlyMessageIncludingThePath() {
15 | assertEquals("[InvalidRouteException path='/a/path']",
16 | new InvalidRouteException("/a/path").toString());
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/lib/ruby/file_extensions.rb:
--------------------------------------------------------------------------------
1 | class File
2 |
3 | def self.native_path(path)
4 | expanded_path = File.expand_path(path)
5 | expanded_path.gsub!('/', '\\') if PLATFORM['win32']
6 | expanded_path
7 | end
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/lib/ruby/java/classpath.rb:
--------------------------------------------------------------------------------
1 | module Java
2 |
3 | class Classpath
4 | require 'pathname'
5 |
6 | def initialize(root_dir)
7 | @root = root_dir
8 | @locations = []
9 | self
10 | end
11 |
12 | def <<(paths)
13 | @locations = (@locations << Dir[@root + '/' + paths]).flatten
14 | self
15 | end
16 |
17 | def definition
18 | @locations.map {|path| File.native_path(path)}.join(self.separator)
19 |
20 | end
21 |
22 | def separator
23 | PLATFORM['win32'] ? ";" : ":"
24 | end
25 |
26 | end
27 |
28 | end
29 |
--------------------------------------------------------------------------------
/lib/ruby/java/vm.rb:
--------------------------------------------------------------------------------
1 | module Java
2 |
3 | class VM
4 |
5 | def run(classname, options)
6 | command = [ "java" ]
7 | command << "-cp \"#{options[:classpath]}\""
8 | command << classname
9 | command << jvm_properties(options[:properties])
10 | command << options[:args].join(' ') if options[:args]
11 | command << ">\"#{options[:log_file]}\" 2>&1" if options[:log_file]
12 |
13 | if options[:background ]
14 | if PLATFORM['win32']
15 | command.unshift("start")
16 | else
17 | command << "&"
18 | end
19 | end
20 |
21 | sh command.join(' ')
22 | end
23 |
24 | def jvm_properties(property_hash)
25 | return "" unless property_hash
26 | property_hash.inject([]) {|memo, (name, value)| memo << "-D#{name}=#{value}" }.join(' ')
27 | end
28 |
29 | end
30 |
31 | end
32 |
--------------------------------------------------------------------------------
/lib/ruby/tcp_socket_extensions.rb:
--------------------------------------------------------------------------------
1 | require 'timeout'
2 | require 'socket'
3 |
4 | class TCPSocket
5 |
6 | def self.wait_for_service(options)
7 | socket = nil
8 | Timeout::timeout(options[:timeout] || 20) do
9 | loop do
10 | begin
11 | socket = TCPSocket.new(options[:host], options[:port])
12 | return
13 | rescue Errno::ECONNREFUSED
14 | puts ".\n"
15 | sleep 2
16 | end
17 | end
18 | end
19 | ensure
20 | socket.close unless socket.nil?
21 | end
22 |
23 | end
--------------------------------------------------------------------------------
/lib/testng.policy:
--------------------------------------------------------------------------------
1 | //
2 | // Java policy file with bulletproof permissions to avoid problems with
3 | // restricted Java environment. On Mac OS X, in particular, the JDK default
4 | // default policy file is quite locked down.
5 | //
6 | // See http://forums.openqa.org/thread.jspa?messageID=35076#35076
7 |
8 | grant {
9 | permission java.security.AllPermission;
10 | };
11 |
12 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | version=1.0.1
2 | selenium.version=1.0-SNAPSHOT
3 | rake=rake
4 |
5 |
--------------------------------------------------------------------------------
/regression-tests/Regression Tests.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/regression-tests/testng.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/remote-control/Remote Control.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/remote-control/lib/selenium-server-1.0-SNAPSHOT.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/remote-control/lib/selenium-server-1.0-SNAPSHOT.jar
--------------------------------------------------------------------------------
/remote-control/src/main/java/com/thoughtworks/selenium/grid/remotecontrol/UnregistrationRequest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.remotecontrol;
2 |
3 | import org.apache.commons.logging.Log;
4 | import org.apache.commons.logging.LogFactory;
5 |
6 | import java.io.IOException;
7 |
8 | /*
9 | * Registration Request to Selenium Grid Hub.
10 | *
11 | * @author Philippe Hanrigou
12 | */
13 | public class UnregistrationRequest extends HubRequest {
14 |
15 | private static final Log logger = LogFactory.getLog(RegistrationRequest.class);
16 |
17 | public UnregistrationRequest(String seleniumHubURL, String host, String port, String environment) {
18 | super(seleniumHubURL + "/registration-manager/unregister", host, port, environment);
19 | }
20 |
21 |
22 | public int execute() throws IOException {
23 | logger.info("Unregistering from " + targetURL());
24 | return super.execute();
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/remote-control/src/main/java/com/thoughtworks/selenium/grid/remotecontrol/instrumentation/HttpRequestProcessor.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.remotecontrol.instrumentation;
2 |
3 | /**
4 | * Process Http Requests
5 | *
6 | * @author Philippe Hanrigou
7 | */
8 | public interface HttpRequestProcessor {
9 |
10 | Response process(Request request);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/remote-control/src/main/java/com/thoughtworks/selenium/grid/remotecontrol/instrumentation/Response.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.remotecontrol.instrumentation;
2 |
3 | import java.io.BufferedWriter;
4 | import java.io.IOException;
5 |
6 | /**
7 | * HTTP Response
8 | *
9 | * @author Philippe Hanrigou
10 | */
11 | public class Response {
12 | private static final String CRLF = "\r\n";
13 | private final String body;
14 |
15 | public Response(String body) {
16 | this.body = body;
17 | }
18 |
19 |
20 | public void write(BufferedWriter writer) throws IOException {
21 | writer.write("HTTP/1.0 200 OK" + CRLF);
22 | writer.write("Server: Selenium Grid Echo Remote Control" + CRLF);
23 | writer.write("Content-type: text/html" + CRLF);
24 |
25 | // Send a blank line to indicate the end of the header lines.
26 | writer.write(CRLF);
27 |
28 | writer.write(body);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/remote-control/src/test/unit/java/com/thoughtworks/selenium/grid/remotecontrol/RegistrationRequestTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.remotecontrol;
2 |
3 | import static junit.framework.Assert.assertEquals;
4 | import org.jbehave.classmock.UsingClassMock;
5 | import org.junit.Test;
6 |
7 | import java.io.IOException;
8 |
9 | /**
10 | * {@link RegistrationRequest} unit test class.
11 | */
12 | public class RegistrationRequestTest extends UsingClassMock {
13 |
14 | @Test
15 | public void postToHubUsingURLProvidedInConstructor() throws IOException {
16 | final HubRequest request = new RegistrationRequest("http://thehub.url:4444", "", "", "");
17 | assertEquals("http://thehub.url:4444/registration-manager/register", request.postMethod().getURI().toString());
18 | }
19 |
20 | }
--------------------------------------------------------------------------------
/remote-control/src/test/unit/java/com/thoughtworks/selenium/grid/remotecontrol/UnregistrationRequestTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.remotecontrol;
2 |
3 | import junit.framework.Assert;
4 | import static junit.framework.Assert.assertEquals;
5 | import org.jbehave.classmock.UsingClassMock;
6 | import org.junit.Test;
7 |
8 | import java.io.IOException;
9 |
10 | /**
11 | * {@link com.thoughtworks.selenium.grid.remotecontrol.UnregistrationRequest} unit test class.
12 | */
13 | public class UnregistrationRequestTest extends UsingClassMock {
14 |
15 | @Test
16 | public void postToHubUsingURLProvidedInConstructor() throws IOException {
17 | final HubRequest request = new UnregistrationRequest("http://thehub.url:4444", "", "", "");
18 | assertEquals("http://thehub.url:4444/registration-manager/unregister", request.postMethod().getURI().toString());
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/src/configuration/grid_configuration.yml:
--------------------------------------------------------------------------------
1 | hub:
2 | port: 4444
3 | environments:
4 | - name: "Firefox on Windows"
5 | browser: "*chrome"
6 | - name: "Firefox on OS X"
7 | browser: "*chrome"
8 | - name: "Firefox on Linux"
9 | browser: "*chrome"
10 | - name: "IE on Windows"
11 | browser: "*iehta"
12 | - name: "Safari on OS X"
13 | browser: "*safari"
14 |
15 | - name: "*firefox"
16 | browser: "*firefox"
17 | - name: "*chrome"
18 | browser: "*chrome"
19 | - name: "*iexplore"
20 | browser: "*iexplore"
21 | - name: "*iehta"
22 | browser: "*iehta"
23 | - name: "*safari"
24 | browser: "*safari"
25 | - name: "*konqueror"
26 | browser: "*konqueror"
27 |
--------------------------------------------------------------------------------
/src/scripts/kill-rcs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | kill `lsof -t -i :5551-5560`
4 |
--------------------------------------------------------------------------------
/src/scripts/launch-rc.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | export PATH=/usr/lib/firefox:${PATH}
4 | ant -Dport=$1 launch-remote-control
5 |
--------------------------------------------------------------------------------
/src/scripts/launch-rcs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | for port in 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 ; do
4 | gnome-terminal --title "RC ${port}" -e "./launch-rc.sh ${port}"
5 | done
6 |
--------------------------------------------------------------------------------
/src/scripts/launch-remote-contols.applescript:
--------------------------------------------------------------------------------
1 | -- AppleScript to launch 10 remote controls starting on port 5000
2 | --
3 | -- launch it with `osascript launch-remote-controls.applescript`
4 | set the_port to 5000
5 | repeat until (the_port = 5010)
6 | log "Lauching remote control on port " & the_port
7 |
8 | tell application "Terminal"
9 | activate
10 | do script with command "cd ~/work/selenium-grid-1.0; ./launch-rc.sh " & the_port & " ; exit"
11 | tell window 1
12 | set title displays shell path to true
13 | set title displays file name to true
14 | set title displays custom title to true
15 | set custom title to "Selenium Remote Control on port " & the_port
16 | set number of columns to 80
17 | set number of rows to 20
18 | end
19 | end tell
20 |
21 | set the_port to the_port + 1
22 | end repeat
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/scripts/launch-remote-controls.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | #
3 | # Launch a collection of remote controls
4 | #
5 |
6 | def launch_on_unix(title, command)
7 | terminal = ENV['TERM'] || "xterm"
8 | system "#{terminal} -t '#{title}' -e '#{command}'"
9 | end
10 |
11 | def launch_in_terminal(title, command)
12 | launch_on_unix(title, command)
13 | end
14 |
15 | first_port = ARGV[0] || 5555
16 | last_port = ARGV[1] || 5555
17 | base_directory = File.expand_path(File.dirname(__FILE__))
18 | (first_port..last_port).each do |port|
19 | launch_in_terminal "Remote Control #{port}", "ant -Dport=#{port} launch-remote-control"
20 | end
21 |
--------------------------------------------------------------------------------
/src/scripts/testng.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/tools/Tools.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/tools/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Selenium Grid Automation Tools
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/tools/src/test/unit/java/com/thoughtworks/selenium/grid/tools/ThreadSafeSeleniumSessionStorageTest.java:
--------------------------------------------------------------------------------
1 | package com.thoughtworks.selenium.grid.tools;
2 |
3 | import org.junit.Test;
4 | public class ThreadSafeSeleniumSessionStorageTest {
5 |
6 | @Test
7 | public void forConvenienceYouCanCloseTheSessionEvenIfThereIsNoCurrentSession() throws Exception {
8 | ThreadSafeSeleniumSessionStorage.closeSeleniumSession();
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/vendor/asm-2.2.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/asm-2.2.1.jar
--------------------------------------------------------------------------------
/vendor/asm-3.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/asm-3.1.jar
--------------------------------------------------------------------------------
/vendor/asm-tree-2.2.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/asm-tree-2.2.1.jar
--------------------------------------------------------------------------------
/vendor/cglib-2.1_3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/cglib-2.1_3.jar
--------------------------------------------------------------------------------
/vendor/cglib-nodep-2.1_3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/cglib-nodep-2.1_3.jar
--------------------------------------------------------------------------------
/vendor/cobertura-1.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/cobertura-1.9.jar
--------------------------------------------------------------------------------
/vendor/commons-codec-1.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/commons-codec-1.3.jar
--------------------------------------------------------------------------------
/vendor/commons-httpclient-3.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/commons-httpclient-3.0.1.jar
--------------------------------------------------------------------------------
/vendor/commons-logging-1.0.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/commons-logging-1.0.4.jar
--------------------------------------------------------------------------------
/vendor/findbugs-ant.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/findbugs-ant.jar
--------------------------------------------------------------------------------
/vendor/findbugs.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/findbugs.jar
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/COPYING:
--------------------------------------------------------------------------------
1 | Copyright Revieworld Ltd. 2006
2 |
3 | You may use, copy and redistribute this library under the same terms as Ruby itself (see http://www.ruby-lang.org/en/LICENSE.txt) or under the MIT license (see MIT-LICENSE file).
4 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/MIT-LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2006 Revieworld Ltd.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/examples/misc.rb:
--------------------------------------------------------------------------------
1 | # Mocking a class method
2 |
3 | product = Product.new
4 | Product.expects(:find).with(1).returns(product)
5 | assert_equal product, Product.find(1)
6 |
7 | # Mocking an instance method on a real object
8 |
9 | product = Product.new
10 | product.expects(:save).returns(true)
11 | assert product.save
12 |
13 | # Stubbing instance methods on real object
14 |
15 | prices = [stub(:pence => 1000), stub(:pence => 2000)]
16 | product = Product.new
17 | product.stubs(:prices).returns(prices)
18 | assert_equal [1000, 2000], product.prices.collect {|p| p.pence}
19 |
20 | # Stubbing an instance method on all instances of a class
21 |
22 | Product.any_instance.stubs(:name).returns('stubbed_name')
23 | product = Product.new
24 | assert_equal 'stubbed_name', product.name
25 |
26 | # Traditional mocking
27 |
28 | object = mock()
29 | object.expects(:expected_method).with(:p1, :p2).returns(:result)
30 | assert_equal :result, object.expected_method(:p1, :p2)
31 |
32 | # Shortcuts
33 |
34 | object = stub(:method1 => :result1, :method2 => :result2)
35 | assert_equal :result1, object.method1
36 | assert_equal :result2, object.method2
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/examples/mocha.rb:
--------------------------------------------------------------------------------
1 | class Enterprise
2 |
3 | def initialize(dilithium)
4 | @dilithium = dilithium
5 | end
6 |
7 | def go(warp_factor)
8 | warp_factor.times { @dilithium.nuke(:anti_matter) }
9 | end
10 |
11 | end
12 |
13 | require 'test/unit'
14 | require 'rubygems'
15 | require 'mocha'
16 |
17 | class EnterpriseTest < Test::Unit::TestCase
18 |
19 | def test_should_boldly_go
20 | dilithium = mock()
21 | dilithium.expects(:nuke).with(:anti_matter).at_least_once # auto-verified at end of test
22 | enterprise = Enterprise.new(dilithium)
23 | enterprise.go(2)
24 | end
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha.rb:
--------------------------------------------------------------------------------
1 | require 'mocha_standalone'
2 | require 'mocha/test_case_adapter'
3 |
4 | require 'test/unit/testcase'
5 |
6 | module Test
7 |
8 | module Unit
9 |
10 | class TestCase
11 |
12 | include Mocha::Standalone
13 | include Mocha::TestCaseAdapter
14 |
15 | end
16 |
17 | end
18 |
19 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/any_instance_method.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/class_method'
2 |
3 | module Mocha
4 |
5 | class AnyInstanceMethod < ClassMethod
6 |
7 | def unstub
8 | remove_new_method
9 | restore_original_method
10 | stubbee.any_instance.reset_mocha
11 | end
12 |
13 | def mock
14 | stubbee.any_instance.mocha
15 | end
16 |
17 | def hide_original_method
18 | stubbee.class_eval "alias_method :#{hidden_method}, :#{method}" if stubbee.method_defined?(method)
19 | end
20 |
21 | def define_new_method
22 | stubbee.class_eval "def #{method}(*args, &block); self.class.any_instance.mocha.method_missing(:#{method}, *args, &block); end"
23 | end
24 |
25 | def remove_new_method
26 | stubbee.class_eval "remove_method :#{method}"
27 | end
28 |
29 | def restore_original_method
30 | stubbee.class_eval "alias_method :#{method}, :#{hidden_method}; remove_method :#{hidden_method}" if stubbee.method_defined?(hidden_method)
31 | end
32 |
33 | end
34 |
35 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/central.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | class Central
4 |
5 | attr_accessor :stubba_methods
6 |
7 | def initialize
8 | self.stubba_methods = []
9 | end
10 |
11 | def stub(method)
12 | unless stubba_methods.include?(method)
13 | method.stub
14 | stubba_methods.push method
15 | end
16 | end
17 |
18 | def verify_all(&block)
19 | unique_mocks.each { |mock| mock.verify(&block) }
20 | end
21 |
22 | def unique_mocks
23 | stubba_methods.inject({}) { |mocks, method| mocks[method.mock.__id__] = method.mock; mocks }.values
24 | end
25 |
26 | def unstub_all
27 | while stubba_methods.size > 0
28 | method = stubba_methods.pop
29 | method.unstub
30 | end
31 | end
32 |
33 | end
34 |
35 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/deprecation.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | class Deprecation
4 |
5 | class << self
6 |
7 | attr_accessor :mode, :messages
8 |
9 | def warning(message)
10 | @messages << message
11 | $stderr.puts "Mocha deprecation warning: #{message}" unless mode == :disabled
12 | $stderr.puts caller.join("\n ") if mode == :debug
13 | end
14 |
15 | end
16 |
17 | self.mode = :enabled
18 | self.messages = []
19 |
20 | end
21 |
22 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/exception_raiser.rb:
--------------------------------------------------------------------------------
1 | module Mocha # :nodoc:
2 |
3 | class ExceptionRaiser # :nodoc:
4 |
5 | def initialize(exception, message)
6 | @exception, @message = exception, message
7 | end
8 |
9 | def evaluate
10 | raise @exception, @exception.to_s if @exception == Interrupt
11 | raise @exception, @message if @message
12 | raise @exception
13 | end
14 |
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/expectation_error.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | class ExpectationError < StandardError
4 | end
5 |
6 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/expectation_list.rb:
--------------------------------------------------------------------------------
1 | module Mocha # :nodoc:
2 |
3 | class ExpectationList
4 |
5 | def initialize
6 | @expectations = []
7 | end
8 |
9 | def add(expectation)
10 | @expectations << expectation
11 | end
12 |
13 | def respond_to?(method_name)
14 | @expectations.any? { |expectation| expectation.method_name == method_name }
15 | end
16 |
17 | def detect(method_name, *arguments)
18 | expectations = @expectations.reverse.select { |expectation| expectation.match?(method_name, *arguments) }
19 | expectation = expectations.detect { |expectation| expectation.invocations_allowed? }
20 | expectation || expectations.first
21 | end
22 |
23 | def similar(method_name)
24 | @expectations.select { |expectation| expectation.method_name == method_name }
25 | end
26 |
27 | def verify(&block)
28 | @expectations.each { |expectation| expectation.verify(&block) }
29 | end
30 |
31 | def to_a
32 | @expectations
33 | end
34 |
35 | def to_set
36 | @expectations.to_set
37 | end
38 |
39 | def size
40 | @expectations.size
41 | end
42 |
43 | end
44 |
45 | end
46 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/infinite_range.rb:
--------------------------------------------------------------------------------
1 | class Range
2 |
3 | def self.at_least(minimum_value)
4 | Range.new(minimum_value, infinite)
5 | end
6 |
7 | def self.at_most(maximum_value)
8 | Range.new(-infinite, maximum_value, false)
9 | end
10 |
11 | def self.infinite
12 | 1/0.0
13 | end
14 |
15 | def mocha_inspect
16 | if first.respond_to?(:to_f) and first.to_f.infinite? then
17 | return "at most #{last}"
18 | elsif last.respond_to?(:to_f) and last.to_f.infinite? then
19 | return "at least #{first}"
20 | else
21 | to_s
22 | end
23 | end
24 |
25 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/inspect.rb:
--------------------------------------------------------------------------------
1 | require 'date'
2 |
3 | class Object
4 | def mocha_inspect
5 | address = self.__id__ * 2
6 | address += 0x100000000 if address < 0
7 | inspect =~ /# ? "#<#{self.class}:0x#{'%x' % address}>" : inspect
8 | end
9 | end
10 |
11 | class String
12 | def mocha_inspect
13 | inspect.gsub(/\"/, "'")
14 | end
15 | end
16 |
17 | class Array
18 | def mocha_inspect
19 | "[#{collect { |member| member.mocha_inspect }.join(', ')}]"
20 | end
21 | end
22 |
23 | class Hash
24 | def mocha_inspect
25 | "{#{collect { |key, value| "#{key.mocha_inspect} => #{value.mocha_inspect}" }.join(', ')}}"
26 | end
27 | end
28 |
29 | class Time
30 | def mocha_inspect
31 | "#{inspect} (#{to_f} secs)"
32 | end
33 | end
34 |
35 | class Date
36 | def mocha_inspect
37 | to_s
38 | end
39 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/instance_method.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/class_method'
2 |
3 | module Mocha
4 |
5 | class InstanceMethod < ClassMethod
6 | end
7 |
8 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/is_a.rb:
--------------------------------------------------------------------------------
1 | class Object
2 |
3 | # :stopdoc:
4 |
5 | alias_method :__is_a__, :is_a?
6 |
7 | # :startdoc:
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/metaclass.rb:
--------------------------------------------------------------------------------
1 | class Object
2 |
3 | def __metaclass__
4 | class << self; self; end
5 | end
6 |
7 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/missing_expectation.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/expectation'
2 |
3 | module Mocha # :nodoc:
4 |
5 | class MissingExpectation < Expectation # :nodoc:
6 |
7 | def initialize(mock, method_name)
8 | super
9 | @invoked_count = true
10 | end
11 |
12 | def verify
13 | msg = error_message(0, 1)
14 | similar_expectations_list = @mock.similar_expectations(@method_name).collect { |expectation| expectation.method_signature }.join("\n")
15 | msg << "\nSimilar expectations:\n#{similar_expectations_list}" unless similar_expectations_list.empty?
16 | error = ExpectationError.new(msg)
17 | error.set_backtrace(filtered_backtrace)
18 | raise error if @invoked_count
19 | end
20 |
21 | def similar_expectations
22 | @mock.similar_expectations(method_name)
23 | end
24 |
25 | end
26 |
27 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/multiple_yields.rb:
--------------------------------------------------------------------------------
1 | module Mocha # :nodoc:
2 |
3 | class MultipleYields # :nodoc:
4 |
5 | attr_reader :parameter_groups
6 |
7 | def initialize(*parameter_groups)
8 | @parameter_groups = parameter_groups
9 | end
10 |
11 | def each
12 | @parameter_groups.each do |parameter_group|
13 | yield(parameter_group)
14 | end
15 | end
16 |
17 | end
18 |
19 | end
20 |
21 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/no_yields.rb:
--------------------------------------------------------------------------------
1 | module Mocha # :nodoc:
2 |
3 | class NoYields # :nodoc:
4 |
5 | def each
6 | end
7 |
8 | end
9 |
10 | end
11 |
12 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/parameter_matchers.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | # Used as parameters for Expectation#with to restrict the parameter values which will match the expectation.
4 | module ParameterMatchers; end
5 |
6 | end
7 |
8 |
9 | Dir[File.expand_path(File.join(File.dirname(__FILE__), 'parameter_matchers', "*.rb"))].each { |lib| require lib }
10 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/parameter_matchers/all_of.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: all_of -> parameter_matcher
6 | #
7 | # Matches if all +matchers+ match.
8 | # object = mock()
9 | # object.expects(:method_1).with(all_of(includes(1), includes(3)))
10 | # object.method_1([1, 3])
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(all_of(includes(1), includes(3)))
15 | # object.method_1([1, 2])
16 | # # error raised, because method_1 was not called with object including 1 and 3
17 | def all_of(*matchers)
18 | AllOf.new(*matchers)
19 | end
20 |
21 | class AllOf # :nodoc:
22 |
23 | def initialize(*matchers)
24 | @matchers = matchers
25 | end
26 |
27 | def ==(parameter)
28 | @matchers.all? { |matcher| matcher == parameter }
29 | end
30 |
31 | def mocha_inspect
32 | "all_of(#{@matchers.map { |matcher| matcher.mocha_inspect }.join(", ") })"
33 | end
34 |
35 | end
36 |
37 | end
38 |
39 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/parameter_matchers/any_of.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: any_of -> parameter_matcher
6 | #
7 | # Matches if any +matchers+ match.
8 | # object = mock()
9 | # object.expects(:method_1).with(any_of(1, 3))
10 | # object.method_1(1)
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(any_of(1, 3))
15 | # object.method_1(3)
16 | # # no error raised
17 | #
18 | # object = mock()
19 | # object.expects(:method_1).with(any_of(1, 3))
20 | # object.method_1(2)
21 | # # error raised, because method_1 was not called with 1 or 3
22 | def any_of(*matchers)
23 | AnyOf.new(*matchers)
24 | end
25 |
26 | class AnyOf # :nodoc:
27 |
28 | def initialize(*matchers)
29 | @matchers = matchers
30 | end
31 |
32 | def ==(parameter)
33 | @matchers.any? { |matcher| matcher == parameter }
34 | end
35 |
36 | def mocha_inspect
37 | "any_of(#{@matchers.map { |matcher| matcher.mocha_inspect }.join(", ") })"
38 | end
39 |
40 | end
41 |
42 | end
43 |
44 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/parameter_matchers/anything.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: anything -> parameter_matcher
6 | #
7 | # Matches any object.
8 | # object = mock()
9 | # object.expects(:method_1).with(anything)
10 | # object.method_1('foo')
11 | # # no error raised
12 | def anything
13 | Anything.new
14 | end
15 |
16 | class Anything # :nodoc:
17 |
18 | def ==(parameter)
19 | return true
20 | end
21 |
22 | def mocha_inspect
23 | "anything"
24 | end
25 |
26 | end
27 |
28 | end
29 |
30 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/parameter_matchers/has_entry.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: has_entry(key, value) -> parameter_matcher
6 | #
7 | # Matches +Hash+ containing entry with +key+ and +value+.
8 | # object = mock()
9 | # object.expects(:method_1).with(has_entry('key_1', 1))
10 | # object.method_1('key_1' => 1, 'key_2' => 2)
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(has_entry('key_1', 1))
15 | # object.method_1('key_1' => 2, 'key_2' => 1)
16 | # # error raised, because method_1 was not called with Hash containing entry: 'key_1' => 1
17 | def has_entry(key, value)
18 | HasEntry.new(key, value)
19 | end
20 |
21 | class HasEntry # :nodoc:
22 |
23 | def initialize(key, value)
24 | @key, @value = key, value
25 | end
26 |
27 | def ==(parameter)
28 | parameter[@key] == @value
29 | end
30 |
31 | def mocha_inspect
32 | "has_entry(#{@key.mocha_inspect}, #{@value.mocha_inspect})"
33 | end
34 |
35 | end
36 |
37 | end
38 |
39 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/parameter_matchers/has_key.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: has_key(key) -> parameter_matcher
6 | #
7 | # Matches +Hash+ containing +key+.
8 | # object = mock()
9 | # object.expects(:method_1).with(has_key('key_1'))
10 | # object.method_1('key_1' => 1, 'key_2' => 2)
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(has_key('key_1'))
15 | # object.method_1('key_2' => 2)
16 | # # error raised, because method_1 was not called with Hash containing key: 'key_1'
17 | def has_key(key)
18 | HasKey.new(key)
19 | end
20 |
21 | class HasKey # :nodoc:
22 |
23 | def initialize(key)
24 | @key = key
25 | end
26 |
27 | def ==(parameter)
28 | parameter.keys.include?(@key)
29 | end
30 |
31 | def mocha_inspect
32 | "has_key(#{@key.mocha_inspect})"
33 | end
34 |
35 | end
36 |
37 | end
38 |
39 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/parameter_matchers/has_value.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: has_value(value) -> parameter_matcher
6 | #
7 | # Matches +Hash+ containing +value+.
8 | # object = mock()
9 | # object.expects(:method_1).with(has_value(1))
10 | # object.method_1('key_1' => 1, 'key_2' => 2)
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(has_value(1))
15 | # object.method_1('key_2' => 2)
16 | # # error raised, because method_1 was not called with Hash containing value: 1
17 | def has_value(value)
18 | HasValue.new(value)
19 | end
20 |
21 | class HasValue # :nodoc:
22 |
23 | def initialize(value)
24 | @value = value
25 | end
26 |
27 | def ==(parameter)
28 | parameter.values.include?(@value)
29 | end
30 |
31 | def mocha_inspect
32 | "has_value(#{@value.mocha_inspect})"
33 | end
34 |
35 | end
36 |
37 | end
38 |
39 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/parameter_matchers/includes.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: includes(item) -> parameter_matcher
6 | #
7 | # Matches any object that responds true to include?(item)
8 | # object = mock()
9 | # object.expects(:method_1).with(includes('foo'))
10 | # object.method_1(['foo', 'bar'])
11 | # # no error raised
12 | #
13 | # object.method_1(['baz'])
14 | # # error raised, because ['baz'] does not include 'foo'.
15 | def includes(item)
16 | Includes.new(item)
17 | end
18 |
19 | class Includes # :nodoc:
20 |
21 | def initialize(item)
22 | @item = item
23 | end
24 |
25 | def ==(parameter)
26 | return parameter.include?(@item)
27 | end
28 |
29 | def mocha_inspect
30 | "includes(#{@item.mocha_inspect})"
31 | end
32 |
33 | end
34 |
35 | end
36 |
37 | end
38 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/parameter_matchers/instance_of.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: instance_of(klass) -> parameter_matcher
6 | #
7 | # Matches any object that is an instance of +klass+
8 | # object = mock()
9 | # object.expects(:method_1).with(instance_of(String))
10 | # object.method_1('string')
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(instance_of(String))
15 | # object.method_1(99)
16 | # # error raised, because method_1 was not called with an instance of String
17 | def instance_of(klass)
18 | InstanceOf.new(klass)
19 | end
20 |
21 | class InstanceOf # :nodoc:
22 |
23 | def initialize(klass)
24 | @klass = klass
25 | end
26 |
27 | def ==(parameter)
28 | parameter.instance_of?(@klass)
29 | end
30 |
31 | def mocha_inspect
32 | "instance_of(#{@klass.mocha_inspect})"
33 | end
34 |
35 | end
36 |
37 | end
38 |
39 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/parameter_matchers/kind_of.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: kind_of(klass) -> parameter_matcher
6 | #
7 | # Matches any object that is a kind of +klass+
8 | # object = mock()
9 | # object.expects(:method_1).with(kind_of(Integer))
10 | # object.method_1(99)
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(kind_of(Integer))
15 | # object.method_1('string')
16 | # # error raised, because method_1 was not called with a kind of Integer
17 | def kind_of(klass)
18 | KindOf.new(klass)
19 | end
20 |
21 | class KindOf # :nodoc:
22 |
23 | def initialize(klass)
24 | @klass = klass
25 | end
26 |
27 | def ==(parameter)
28 | parameter.kind_of?(@klass)
29 | end
30 |
31 | def mocha_inspect
32 | "kind_of(#{@klass.mocha_inspect})"
33 | end
34 |
35 | end
36 |
37 | end
38 |
39 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/parameter_matchers/regexp_matches.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: regexp_matches(regexp) -> parameter_matcher
6 | #
7 | # Matches any object that matches the regular expression, +regexp+.
8 | # object = mock()
9 | # object.expects(:method_1).with(regexp_matches(/e/))
10 | # object.method_1('hello')
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(regexp_matches(/a/))
15 | # object.method_1('hello')
16 | # # error raised, because method_1 was not called with a parameter that matched the
17 | # # regular expression
18 | def regexp_matches(regexp)
19 | RegexpMatches.new(regexp)
20 | end
21 |
22 | class RegexpMatches # :nodoc:
23 |
24 | def initialize(regexp)
25 | @regexp = regexp
26 | end
27 |
28 | def ==(parameter)
29 | parameter =~ @regexp
30 | end
31 |
32 | def mocha_inspect
33 | "regexp_matches(#{@regexp.mocha_inspect})"
34 | end
35 |
36 | end
37 |
38 | end
39 |
40 | end
41 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/pretty_parameters.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/inspect'
2 |
3 | module Mocha
4 |
5 | class PrettyParameters
6 |
7 | def initialize(params)
8 | @params = params
9 | @params_string = params.mocha_inspect
10 | end
11 |
12 | def pretty
13 | remove_outer_array_braces!
14 | remove_outer_hash_braces!
15 | @params_string
16 | end
17 |
18 | def remove_outer_array_braces!
19 | @params_string = @params_string.gsub(/^\[|\]$/, '')
20 | end
21 |
22 | def remove_outer_hash_braces!
23 | @params_string = @params_string.gsub(/^\{|\}$/, '') if @params.size == 1
24 | end
25 |
26 | end
27 |
28 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/return_values.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/single_return_value'
2 |
3 | module Mocha # :nodoc:
4 |
5 | class ReturnValues # :nodoc:
6 |
7 | def self.build(*values)
8 | new(*values.map { |value| SingleReturnValue.new(value) })
9 | end
10 |
11 | attr_accessor :values
12 |
13 | def initialize(*values)
14 | @values = values
15 | end
16 |
17 | def next
18 | case @values.size
19 | when 0: nil
20 | when 1: @values.first.evaluate
21 | else @values.shift.evaluate
22 | end
23 | end
24 |
25 | def +(other)
26 | self.class.new(*(@values + other.values))
27 | end
28 |
29 | end
30 |
31 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/setup_and_teardown.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/central'
2 |
3 | module Mocha
4 |
5 | module SetupAndTeardown
6 |
7 | def setup_stubs
8 | $stubba = Mocha::Central.new
9 | end
10 |
11 | def verify_stubs
12 | $stubba.verify_all { yield if block_given? } if $stubba
13 | end
14 |
15 | def teardown_stubs
16 | if $stubba then
17 | $stubba.unstub_all
18 | $stubba = nil
19 | end
20 | end
21 |
22 | end
23 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/single_return_value.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/is_a'
2 | require 'mocha/deprecation'
3 |
4 | module Mocha # :nodoc:
5 |
6 | class SingleReturnValue # :nodoc:
7 |
8 | def initialize(value)
9 | @value = value
10 | end
11 |
12 | def evaluate
13 | if @value.__is_a__(Proc) then
14 | message = 'use of Expectation#returns with instance of Proc - see Expectation#returns RDoc for alternatives'
15 | Deprecation.warning(message)
16 | @value.call
17 | else
18 | @value
19 | end
20 | end
21 |
22 | end
23 |
24 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/single_yield.rb:
--------------------------------------------------------------------------------
1 | module Mocha # :nodoc:
2 |
3 | class SingleYield # :nodoc:
4 |
5 | attr_reader :parameters
6 |
7 | def initialize(*parameters)
8 | @parameters = parameters
9 | end
10 |
11 | def each
12 | yield(@parameters)
13 | end
14 |
15 | end
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/standalone.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/auto_verify'
2 | require 'mocha/parameter_matchers'
3 | require 'mocha/setup_and_teardown'
4 |
5 | module Mocha
6 |
7 | module Standalone
8 |
9 | include AutoVerify
10 | include ParameterMatchers
11 | include SetupAndTeardown
12 |
13 | def mocha_setup
14 | setup_stubs
15 | end
16 |
17 | def mocha_verify(&block)
18 | verify_mocks(&block)
19 | verify_stubs(&block)
20 | end
21 |
22 | def mocha_teardown
23 | begin
24 | teardown_mocks
25 | ensure
26 | teardown_stubs
27 | end
28 | end
29 |
30 | end
31 |
32 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/stub.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/expectation'
2 |
3 | module Mocha # :nodoc:
4 |
5 | class Stub < Expectation # :nodoc:
6 |
7 | def initialize(mock, method_name, backtrace = nil)
8 | super
9 | @expected_count = Range.at_least(0)
10 | end
11 |
12 | def verify
13 | true
14 | end
15 |
16 | end
17 |
18 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha/yield_parameters.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/no_yields'
2 | require 'mocha/single_yield'
3 | require 'mocha/multiple_yields'
4 |
5 | module Mocha # :nodoc:
6 |
7 | class YieldParameters # :nodoc:
8 |
9 | def initialize
10 | @parameter_groups = []
11 | end
12 |
13 | def next_invocation
14 | case @parameter_groups.size
15 | when 0: NoYields.new
16 | when 1: @parameter_groups.first
17 | else @parameter_groups.shift
18 | end
19 | end
20 |
21 | def add(*parameters)
22 | @parameter_groups << SingleYield.new(*parameters)
23 | end
24 |
25 | def multiple_add(*parameter_groups)
26 | @parameter_groups << MultipleYields.new(*parameter_groups)
27 | end
28 |
29 | end
30 |
31 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/mocha_standalone.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/standalone'
2 | require 'mocha/object'
3 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/lib/stubba.rb:
--------------------------------------------------------------------------------
1 | # for backwards compatibility
2 | require 'mocha'
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/active_record_test_case.rb:
--------------------------------------------------------------------------------
1 | module ActiveRecordTestCase
2 |
3 | def setup_with_fixtures
4 | methods_called << :setup_with_fixtures
5 | end
6 |
7 | alias_method :setup, :setup_with_fixtures
8 |
9 | def teardown_with_fixtures
10 | methods_called << :teardown_with_fixtures
11 | end
12 |
13 | alias_method :teardown, :teardown_with_fixtures
14 |
15 | def self.method_added(method)
16 | case method.to_s
17 | when 'setup'
18 | unless method_defined?(:setup_without_fixtures)
19 | alias_method :setup_without_fixtures, :setup
20 | define_method(:setup) do
21 | setup_with_fixtures
22 | setup_without_fixtures
23 | end
24 | end
25 | when 'teardown'
26 | unless method_defined?(:teardown_without_fixtures)
27 | alias_method :teardown_without_fixtures, :teardown
28 | define_method(:teardown) do
29 | teardown_without_fixtures
30 | teardown_with_fixtures
31 | end
32 | end
33 | end
34 | end
35 |
36 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/deprecation_disabler.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/deprecation'
2 |
3 | module DeprecationDisabler
4 |
5 | def disable_deprecations
6 | original_mode = Mocha::Deprecation.mode
7 | Mocha::Deprecation.mode = :disabled
8 | begin
9 | yield
10 | ensure
11 | Mocha::Deprecation.mode = original_mode
12 | end
13 | end
14 |
15 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/execution_point.rb:
--------------------------------------------------------------------------------
1 | class ExecutionPoint
2 |
3 | attr_reader :backtrace
4 |
5 | def self.current
6 | new(caller)
7 | end
8 |
9 | def initialize(backtrace)
10 | @backtrace = backtrace
11 | end
12 |
13 | def file_name
14 | /\A(.*?):\d+/.match(@backtrace.first)[1]
15 | end
16 |
17 | def line_number
18 | Integer(/\A.*?:(\d+)/.match(@backtrace.first)[1])
19 | end
20 |
21 | def ==(other)
22 | return false unless other.is_a?(ExecutionPoint)
23 | (file_name == other.file_name) and (line_number == other.line_number)
24 | end
25 |
26 | def to_s
27 | "file: #{file_name} line: #{line_number}"
28 | end
29 |
30 | def inspect
31 | to_s
32 | end
33 |
34 | end
35 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/method_definer.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/metaclass'
2 |
3 | class Object
4 |
5 | def define_instance_method(method_symbol, &block)
6 | __metaclass__.send(:define_method, method_symbol, block)
7 | end
8 |
9 | def replace_instance_method(method_symbol, &block)
10 | raise "Cannot replace #{method_symbol} as #{self} does not respond to it." unless self.respond_to?(method_symbol)
11 | define_instance_method(method_symbol, &block)
12 | end
13 |
14 | def define_instance_accessor(*symbols)
15 | symbols.each { |symbol| __metaclass__.send(:attr_accessor, symbol) }
16 | end
17 |
18 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/test_helper.rb:
--------------------------------------------------------------------------------
1 | unless defined?(STANDARD_OBJECT_PUBLIC_INSTANCE_METHODS)
2 | STANDARD_OBJECT_PUBLIC_INSTANCE_METHODS = Object.public_instance_methods
3 | end
4 |
5 | $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
6 | $:.unshift File.expand_path(File.join(File.dirname(__FILE__)))
7 | $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'unit'))
8 | $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'unit', 'parameter_matchers'))
9 | $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'integration'))
10 | $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'acceptance'))
11 |
12 | require 'test/unit'
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/test_runner.rb:
--------------------------------------------------------------------------------
1 | require 'test/unit/testresult'
2 | require 'test/unit/testcase'
3 | require 'mocha/standalone'
4 | require 'mocha/test_case_adapter'
5 |
6 | module TestRunner
7 |
8 | def run_test(test_result = Test::Unit::TestResult.new, &block)
9 | test_class = Class.new(Test::Unit::TestCase) do
10 | include Mocha::Standalone
11 | include Mocha::TestCaseAdapter
12 | define_method(:test_me, &block)
13 | end
14 | test = test_class.new(:test_me)
15 | test.run(test_result) {}
16 | class << test_result
17 | attr_reader :failures, :errors
18 | end
19 | test_result
20 | end
21 |
22 | def assert_passed(test_result)
23 | flunk "Test failed unexpectedly with message: #{test_result.failures.first.message}" if test_result.failure_count > 0
24 | flunk "Test failed unexpectedly with message: #{test_result.errors.first.message}" if test_result.error_count > 0
25 | end
26 |
27 | def assert_failed(test_result)
28 | flunk "Test passed unexpectedly" if test_result.passed?
29 | end
30 |
31 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/array_inspect_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/inspect'
3 |
4 | class ArrayInstanceTest < Test::Unit::TestCase
5 |
6 | def test_should_use_inspect
7 | array = [1, 2]
8 | assert_equal array.inspect, array.mocha_inspect
9 | end
10 |
11 | def test_should_use_mocha_inspect_on_each_item
12 | array = [1, 2, "chris"]
13 | assert_equal "[1, 2, 'chris']", array.mocha_inspect
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/date_time_inspect_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/inspect'
3 |
4 | class TimeDateInspectTest < Test::Unit::TestCase
5 |
6 | def test_should_use_include_date_in_seconds
7 | time = Time.now
8 | assert_equal "#{time.inspect} (#{time.to_f} secs)", time.mocha_inspect
9 | end
10 |
11 | def test_should_use_to_s_for_date
12 | date = Date.new(2006, 1, 1)
13 | assert_equal date.to_s, date.mocha_inspect
14 | end
15 |
16 | def test_should_use_to_s_for_datetime
17 | datetime = DateTime.new(2006, 1, 1)
18 | assert_equal datetime.to_s, datetime.mocha_inspect
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/expectation_raiser_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 |
3 | require 'mocha/exception_raiser'
4 |
5 | class ExceptionRaiserTest < Test::Unit::TestCase
6 |
7 | include Mocha
8 |
9 | def test_should_raise_exception_with_specified_class_and_default_message
10 | exception_class = Class.new(StandardError)
11 | raiser = ExceptionRaiser.new(exception_class, nil)
12 | exception = assert_raises(exception_class) { raiser.evaluate }
13 | assert_equal exception_class.to_s, exception.message
14 | end
15 |
16 | def test_should_raise_exception_with_specified_class_and_message
17 | exception_class = Class.new(StandardError)
18 | raiser = ExceptionRaiser.new(exception_class, 'message')
19 | exception = assert_raises(exception_class) { raiser.evaluate }
20 | assert_equal 'message', exception.message
21 | end
22 |
23 | def test_should_raise_interrupt_exception_with_default_message_so_it_works_in_ruby_1_8_6
24 | raiser = ExceptionRaiser.new(Interrupt, nil)
25 | assert_raises(Interrupt) { raiser.evaluate }
26 | end
27 |
28 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/hash_inspect_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/inspect'
3 |
4 | class HashInspectTest < Test::Unit::TestCase
5 |
6 | def test_should_keep_spacing_between_key_value
7 | hash = {:a => true}
8 | assert_equal '{:a => true}', hash.mocha_inspect
9 | end
10 |
11 | def test_should_use_mocha_inspect_on_each_item
12 | hash = {:a => 'mocha'}
13 | assert_equal "{:a => 'mocha'}", hash.mocha_inspect
14 | end
15 |
16 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/metaclass_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/metaclass'
3 |
4 | class MetaclassTest < Test::Unit::TestCase
5 |
6 | def test_should_return_objects_singleton_class
7 | object = Object.new
8 | assert_raises(NoMethodError) { object.success? }
9 |
10 | object = Object.new
11 | assert object.__metaclass__.ancestors.include?(Object)
12 | assert object.__metaclass__.ancestors.include?(Kernel)
13 | assert object.__metaclass__.is_a?(Class)
14 |
15 | object.__metaclass__.class_eval { def success?; true; end }
16 | assert object.success?
17 |
18 | object = Object.new
19 | assert_raises(NoMethodError) { object.success? }
20 | end
21 |
22 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/multiple_yields_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 |
3 | require 'mocha/multiple_yields'
4 |
5 | class MultipleYieldsTest < Test::Unit::TestCase
6 |
7 | include Mocha
8 |
9 | def test_should_provide_parameters_for_multiple_yields_in_single_invocation
10 | parameter_group = MultipleYields.new([1, 2, 3], [4, 5])
11 | parameter_groups = []
12 | parameter_group.each do |parameters|
13 | parameter_groups << parameters
14 | end
15 | assert_equal [[1, 2, 3], [4, 5]], parameter_groups
16 | end
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/no_yield_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 |
3 | require 'mocha/no_yields'
4 |
5 | class NoYieldsTest < Test::Unit::TestCase
6 |
7 | include Mocha
8 |
9 | def test_should_provide_parameters_for_no_yields_in_single_invocation
10 | parameter_group = NoYields.new
11 | parameter_groups = []
12 | parameter_group.each do |parameters|
13 | parameter_groups << parameters
14 | end
15 | assert_equal [], parameter_groups
16 | end
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/parameter_matchers/all_of_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/all_of'
4 | require 'mocha/inspect'
5 | require 'stub_matcher'
6 |
7 | class AllOfTest < Test::Unit::TestCase
8 |
9 | include Mocha::ParameterMatchers
10 |
11 | def test_should_match_if_all_matchers_match
12 | matcher = all_of(Stub::Matcher.new(true), Stub::Matcher.new(true), Stub::Matcher.new(true))
13 | assert matcher == 'any_old_value'
14 | end
15 |
16 | def test_should_not_match_if_any_matcher_does_not_match
17 | matcher = all_of(Stub::Matcher.new(true), Stub::Matcher.new(false), Stub::Matcher.new(true))
18 | assert matcher != 'any_old_value'
19 | end
20 |
21 | def test_should_describe_matcher
22 | matcher = all_of(Stub::Matcher.new(true), Stub::Matcher.new(false), Stub::Matcher.new(true))
23 | assert_equal 'all_of(matcher(true), matcher(false), matcher(true))', matcher.mocha_inspect
24 | end
25 |
26 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/parameter_matchers/any_of_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/any_of'
4 | require 'mocha/inspect'
5 | require 'stub_matcher'
6 |
7 | class AnyOfTest < Test::Unit::TestCase
8 |
9 | include Mocha::ParameterMatchers
10 |
11 | def test_should_match_if_any_matchers_match
12 | matcher = any_of(Stub::Matcher.new(false), Stub::Matcher.new(true), Stub::Matcher.new(false))
13 | assert matcher == 'any_old_value'
14 | end
15 |
16 | def test_should_not_match_if_no_matchers_match
17 | matcher = any_of(Stub::Matcher.new(false), Stub::Matcher.new(false), Stub::Matcher.new(false))
18 | assert matcher != 'any_old_value'
19 | end
20 |
21 | def test_should_describe_matcher
22 | matcher = any_of(Stub::Matcher.new(false), Stub::Matcher.new(true), Stub::Matcher.new(false))
23 | assert_equal 'any_of(matcher(false), matcher(true), matcher(false))', matcher.mocha_inspect
24 | end
25 |
26 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/parameter_matchers/anything_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/anything'
4 | require 'mocha/inspect'
5 |
6 | class AnythingTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_anything
11 | matcher = anything
12 | assert matcher == :something
13 | assert matcher == {'x' => 'y'}
14 | end
15 |
16 | def test_should_describe_matcher
17 | matcher = anything
18 | assert_equal "anything", matcher.mocha_inspect
19 | end
20 |
21 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/parameter_matchers/has_entry_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/has_entry'
4 | require 'mocha/inspect'
5 |
6 | class HasEntryTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_hash_including_specified_entry
11 | matcher = has_entry(:key_1, 'value_1')
12 | assert matcher == { :key_1 => 'value_1', :key_2 => 'value_2' }
13 | end
14 |
15 | def test_should_not_match_hash_not_including_specified_entry
16 | matcher = has_entry(:key_1, 'value_2')
17 | assert matcher != { :key_1 => 'value_1', :key_2 => 'value_2' }
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = has_entry(:key_1, 'value_1')
22 | assert_equal "has_entry(:key_1, 'value_1')", matcher.mocha_inspect
23 | end
24 |
25 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/parameter_matchers/has_key_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/has_key'
4 | require 'mocha/inspect'
5 |
6 | class HasKeyTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_hash_including_specified_key
11 | matcher = has_key(:key_1)
12 | assert matcher == { :key_1 => 1, :key_2 => 2 }
13 | end
14 |
15 | def test_should_not_match_hash_not_including_specified_key
16 | matcher = has_key(:key_1)
17 | assert matcher != { :key_2 => 2 }
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = has_key(:key)
22 | assert_equal 'has_key(:key)', matcher.mocha_inspect
23 | end
24 |
25 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/parameter_matchers/has_value_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/has_value'
4 | require 'mocha/inspect'
5 |
6 | class HasValueTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_hash_including_specified_value
11 | matcher = has_value('value_1')
12 | assert matcher == { :key_1 => 'value_1', :key_2 => 'value_2' }
13 | end
14 |
15 | def test_should_not_match_hash_not_including_specified_value
16 | matcher = has_value('value_1')
17 | assert matcher != { :key_2 => 'value_2' }
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = has_value('value_1')
22 | assert_equal "has_value('value_1')", matcher.mocha_inspect
23 | end
24 |
25 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/parameter_matchers/includes_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/includes'
4 | require 'mocha/inspect'
5 |
6 | class IncludesTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_object_including_value
11 | matcher = includes(:x)
12 | assert matcher == [:x, :y, :z]
13 | end
14 |
15 | def test_should_not_match_object_that_does_not_include_value
16 | matcher = includes(:not_included)
17 | assert matcher != [:x, :y, :z]
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = includes(:x)
22 | assert_equal "includes(:x)", matcher.mocha_inspect
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/parameter_matchers/instance_of_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/instance_of'
4 | require 'mocha/inspect'
5 |
6 | class InstanceOfTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_object_that_is_an_instance_of_specified_class
11 | matcher = instance_of(String)
12 | assert matcher == 'string'
13 | end
14 |
15 | def test_should_not_match_object_that_is_not_an_instance_of_specified_class
16 | matcher = instance_of(String)
17 | assert matcher != 99
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = instance_of(String)
22 | assert_equal "instance_of(String)", matcher.mocha_inspect
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/parameter_matchers/kind_of_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/kind_of'
4 | require 'mocha/inspect'
5 |
6 | class InstanceOfTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_object_that_is_a_kind_of_specified_class
11 | matcher = kind_of(Integer)
12 | assert matcher == 99
13 | end
14 |
15 | def test_should_not_match_object_that_is_not_a_kind_of_specified_class
16 | matcher = kind_of(Integer)
17 | assert matcher != 'string'
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = kind_of(Integer)
22 | assert_equal "kind_of(Integer)", matcher.mocha_inspect
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/parameter_matchers/regexp_matches_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/regexp_matches'
4 | require 'mocha/inspect'
5 |
6 | class MatchesTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_parameter_matching_regular_expression
11 | matcher = regexp_matches(/oo/)
12 | assert matcher == 'foo'
13 | end
14 |
15 | def test_should_not_match_parameter_not_matching_regular_expression
16 | matcher = regexp_matches(/oo/)
17 | assert matcher != 'bar'
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = regexp_matches(/oo/)
22 | assert_equal "regexp_matches(/oo/)", matcher.mocha_inspect
23 | end
24 |
25 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/parameter_matchers/stub_matcher.rb:
--------------------------------------------------------------------------------
1 | module Stub
2 |
3 | class Matcher
4 |
5 | attr_accessor :value
6 |
7 | def initialize(matches)
8 | @matches = matches
9 | end
10 |
11 | def ==(value)
12 | @value = value
13 | @matches
14 | end
15 |
16 | def mocha_inspect
17 | "matcher(#{@matches})"
18 | end
19 |
20 | end
21 |
22 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/pretty_parameters_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/pretty_parameters'
3 |
4 | class PrettyParametersTest < Test::Unit::TestCase
5 |
6 | include Mocha
7 |
8 | def test_should_remove_outer_array_braces
9 | params = [1, 2, [3, 4]]
10 | parameters = PrettyParameters.new(params)
11 | assert_equal '1, 2, [3, 4]', parameters.pretty
12 | end
13 |
14 | def test_should_display_numeric_arguments_as_is
15 | params = [1, 2, 3]
16 | parameters = PrettyParameters.new(params)
17 | assert_equal '1, 2, 3', parameters.pretty
18 | end
19 |
20 | def test_should_remove_curly_braces_if_hash_is_only_argument
21 | params = [{:a => 1, :z => 2}]
22 | parameters = PrettyParameters.new(params)
23 | assert_match /^:[az] => [12], :[az] => [12]$/, parameters.pretty
24 | end
25 |
26 | def test_should_not_remove_curly_braces_if_hash_is_not_the_only_argument
27 | params = [1, {:a => 1}]
28 | parameters = PrettyParameters.new(params)
29 | assert_equal '1, {:a => 1}', parameters.pretty
30 | end
31 |
32 | end
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/single_return_value_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 |
3 | require 'mocha/single_return_value'
4 | require 'deprecation_disabler'
5 |
6 | class SingleReturnValueTest < Test::Unit::TestCase
7 |
8 | include Mocha
9 | include DeprecationDisabler
10 |
11 | def test_should_return_value
12 | value = SingleReturnValue.new('value')
13 | assert_equal 'value', value.evaluate
14 | end
15 |
16 | def test_should_return_result_of_calling_proc
17 | proc = lambda { 'value' }
18 | value = SingleReturnValue.new(proc)
19 | result = nil
20 | disable_deprecations { result = value.evaluate }
21 | assert_equal 'value', result
22 | end
23 |
24 | def test_should_indicate_deprecated_use_of_expectation_returns_method
25 | proc = lambda {}
26 | value = SingleReturnValue.new(proc)
27 | Deprecation.messages = []
28 | disable_deprecations { value.evaluate }
29 | expected_message = "use of Expectation#returns with instance of Proc - see Expectation#returns RDoc for alternatives"
30 | assert_equal [expected_message], Deprecation.messages
31 | end
32 |
33 | end
34 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/single_yield_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 |
3 | require 'mocha/single_yield'
4 |
5 | class SingleYieldTest < Test::Unit::TestCase
6 |
7 | include Mocha
8 |
9 | def test_should_provide_parameters_for_single_yield_in_single_invocation
10 | parameter_group = SingleYield.new(1, 2, 3)
11 | parameter_groups = []
12 | parameter_group.each do |parameters|
13 | parameter_groups << parameters
14 | end
15 | assert_equal [[1, 2, 3]], parameter_groups
16 | end
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/string_inspect_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/inspect'
3 |
4 | class StringInspectTest < Test::Unit::TestCase
5 |
6 | def test_should_replace_escaped_quotes_with_single_quote
7 | string = "my_string"
8 | assert_equal "'my_string'", string.mocha_inspect
9 | end
10 |
11 | end
12 |
--------------------------------------------------------------------------------
/vendor/gems/mocha-0.5.5/test/unit/stub_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/stub'
3 |
4 | class StubTest < Test::Unit::TestCase
5 |
6 | include Mocha
7 |
8 | def test_should_always_verify_successfully
9 | stub = Stub.new(nil, :expected_method)
10 | assert stub.verify
11 | stub.invoke
12 | assert stub.verify
13 | end
14 |
15 | def test_should_match_successfully_for_any_number_of_invocations
16 | stub = Stub.new(nil, :expected_method)
17 | assert stub.match?(:expected_method)
18 | stub.invoke
19 | assert stub.match?(:expected_method)
20 | stub.invoke
21 | assert stub.match?(:expected_method)
22 | end
23 |
24 | end
--------------------------------------------------------------------------------
/vendor/jakarta-oro-2.0.8.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/jakarta-oro-2.0.8.jar
--------------------------------------------------------------------------------
/vendor/jaxen-1.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/jaxen-1.1.1.jar
--------------------------------------------------------------------------------
/vendor/jbehave-1.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/jbehave-1.0.1.jar
--------------------------------------------------------------------------------
/vendor/jetty-6.0.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/jetty-6.0.2.jar
--------------------------------------------------------------------------------
/vendor/jetty-util-6.0.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/jetty-util-6.0.2.jar
--------------------------------------------------------------------------------
/vendor/jmock-2.2.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/jmock-2.2.0.jar
--------------------------------------------------------------------------------
/vendor/jmock-junit4-2.2.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/jmock-junit4-2.2.0.jar
--------------------------------------------------------------------------------
/vendor/jmock-legacy-2.2.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/jmock-legacy-2.2.0.jar
--------------------------------------------------------------------------------
/vendor/junit-4.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/junit-4.4.jar
--------------------------------------------------------------------------------
/vendor/jyaml-1.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/jyaml-1.3.jar
--------------------------------------------------------------------------------
/vendor/log4j-1.2.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/log4j-1.2.9.jar
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/COPYING:
--------------------------------------------------------------------------------
1 | Copyright Revieworld Ltd. 2006
2 |
3 | You may use, copy and redistribute this library under the same terms as Ruby itself (see http://www.ruby-lang.org/en/LICENSE.txt) or under the MIT license (see MIT-LICENSE file).
4 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/MIT-LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2006 Revieworld Ltd.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/examples/misc.rb:
--------------------------------------------------------------------------------
1 | # Mocking a class method
2 |
3 | product = Product.new
4 | Product.expects(:find).with(1).returns(product)
5 | assert_equal product, Product.find(1)
6 |
7 | # Mocking an instance method on a real object
8 |
9 | product = Product.new
10 | product.expects(:save).returns(true)
11 | assert product.save
12 |
13 | # Stubbing instance methods on real object
14 |
15 | prices = [stub(:pence => 1000), stub(:pence => 2000)]
16 | product = Product.new
17 | product.stubs(:prices).returns(prices)
18 | assert_equal [1000, 2000], product.prices.collect {|p| p.pence}
19 |
20 | # Stubbing an instance method on all instances of a class
21 |
22 | Product.any_instance.stubs(:name).returns('stubbed_name')
23 | product = Product.new
24 | assert_equal 'stubbed_name', product.name
25 |
26 | # Traditional mocking
27 |
28 | object = mock()
29 | object.expects(:expected_method).with(:p1, :p2).returns(:result)
30 | assert_equal :result, object.expected_method(:p1, :p2)
31 |
32 | # Shortcuts
33 |
34 | object = stub(:method1 => :result1, :method2 => :result2)
35 | assert_equal :result1, object.method1
36 | assert_equal :result2, object.method2
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/examples/mocha.rb:
--------------------------------------------------------------------------------
1 | class Enterprise
2 |
3 | def initialize(dilithium)
4 | @dilithium = dilithium
5 | end
6 |
7 | def go(warp_factor)
8 | warp_factor.times { @dilithium.nuke(:anti_matter) }
9 | end
10 |
11 | end
12 |
13 | require 'test/unit'
14 | require 'rubygems'
15 | require 'mocha'
16 |
17 | class EnterpriseTest < Test::Unit::TestCase
18 |
19 | def test_should_boldly_go
20 | dilithium = mock()
21 | dilithium.expects(:nuke).with(:anti_matter).at_least_once # auto-verified at end of test
22 | enterprise = Enterprise.new(dilithium)
23 | enterprise.go(2)
24 | end
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha.rb:
--------------------------------------------------------------------------------
1 | require 'mocha_standalone'
2 | require 'mocha/test_case_adapter'
3 |
4 | require 'test/unit/testcase'
5 |
6 | module Test
7 |
8 | module Unit
9 |
10 | class TestCase
11 |
12 | include Mocha::Standalone
13 | include Mocha::TestCaseAdapter
14 |
15 | end
16 |
17 | end
18 |
19 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/any_instance_method.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/class_method'
2 |
3 | module Mocha
4 |
5 | class AnyInstanceMethod < ClassMethod
6 |
7 | def unstub
8 | remove_new_method
9 | restore_original_method
10 | stubbee.any_instance.reset_mocha
11 | end
12 |
13 | def mock
14 | stubbee.any_instance.mocha
15 | end
16 |
17 | def hide_original_method
18 | stubbee.class_eval "alias_method :#{hidden_method}, :#{method}" if stubbee.method_defined?(method)
19 | end
20 |
21 | def define_new_method
22 | stubbee.class_eval "def #{method}(*args, &block); self.class.any_instance.mocha.method_missing(:#{method}, *args, &block); end"
23 | end
24 |
25 | def remove_new_method
26 | stubbee.class_eval "remove_method :#{method}"
27 | end
28 |
29 | def restore_original_method
30 | stubbee.class_eval "alias_method :#{method}, :#{hidden_method}; remove_method :#{hidden_method}" if stubbee.method_defined?(hidden_method)
31 | end
32 |
33 | end
34 |
35 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/central.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | class Central
4 |
5 | attr_accessor :stubba_methods
6 |
7 | def initialize
8 | self.stubba_methods = []
9 | end
10 |
11 | def stub(method)
12 | unless stubba_methods.include?(method)
13 | method.stub
14 | stubba_methods.push method
15 | end
16 | end
17 |
18 | def verify_all(&block)
19 | unique_mocks.each { |mock| mock.verify(&block) }
20 | end
21 |
22 | def unique_mocks
23 | stubba_methods.inject({}) { |mocks, method| mocks[method.mock.__id__] = method.mock; mocks }.values
24 | end
25 |
26 | def unstub_all
27 | while stubba_methods.size > 0
28 | method = stubba_methods.pop
29 | method.unstub
30 | end
31 | end
32 |
33 | end
34 |
35 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/deprecation.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | class Deprecation
4 |
5 | class << self
6 |
7 | attr_accessor :mode, :messages
8 |
9 | def warning(message)
10 | @messages << message
11 | $stderr.puts "Mocha deprecation warning: #{message}" unless mode == :disabled
12 | $stderr.puts caller.join("\n ") if mode == :debug
13 | end
14 |
15 | end
16 |
17 | self.mode = :enabled
18 | self.messages = []
19 |
20 | end
21 |
22 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/exception_raiser.rb:
--------------------------------------------------------------------------------
1 | module Mocha # :nodoc:
2 |
3 | class ExceptionRaiser # :nodoc:
4 |
5 | def initialize(exception, message)
6 | @exception, @message = exception, message
7 | end
8 |
9 | def evaluate
10 | raise @exception, @exception.to_s if @exception == Interrupt
11 | raise @exception, @message if @message
12 | raise @exception
13 | end
14 |
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/expectation_error.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | class ExpectationError < StandardError
4 | end
5 |
6 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/expectation_list.rb:
--------------------------------------------------------------------------------
1 | module Mocha # :nodoc:
2 |
3 | class ExpectationList
4 |
5 | def initialize
6 | @expectations = []
7 | end
8 |
9 | def add(expectation)
10 | @expectations << expectation
11 | end
12 |
13 | def respond_to?(method_name)
14 | @expectations.any? { |expectation| expectation.method_name == method_name }
15 | end
16 |
17 | def detect(method_name, *arguments)
18 | expectations = @expectations.reverse.select { |expectation| expectation.match?(method_name, *arguments) }
19 | expectation = expectations.detect { |expectation| expectation.invocations_allowed? }
20 | expectation || expectations.first
21 | end
22 |
23 | def similar(method_name)
24 | @expectations.select { |expectation| expectation.method_name == method_name }
25 | end
26 |
27 | def verify(&block)
28 | @expectations.each { |expectation| expectation.verify(&block) }
29 | end
30 |
31 | def to_a
32 | @expectations
33 | end
34 |
35 | def to_set
36 | @expectations.to_set
37 | end
38 |
39 | def size
40 | @expectations.size
41 | end
42 |
43 | end
44 |
45 | end
46 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/infinite_range.rb:
--------------------------------------------------------------------------------
1 | class Range
2 |
3 | def self.at_least(minimum_value)
4 | Range.new(minimum_value, infinite)
5 | end
6 |
7 | def self.at_most(maximum_value)
8 | Range.new(-infinite, maximum_value, false)
9 | end
10 |
11 | def self.infinite
12 | 1/0.0
13 | end
14 |
15 | def mocha_inspect
16 | if first.respond_to?(:to_f) and first.to_f.infinite? then
17 | return "at most #{last}"
18 | elsif last.respond_to?(:to_f) and last.to_f.infinite? then
19 | return "at least #{first}"
20 | else
21 | to_s
22 | end
23 | end
24 |
25 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/inspect.rb:
--------------------------------------------------------------------------------
1 | require 'date'
2 |
3 | class Object
4 | def mocha_inspect
5 | address = self.__id__ * 2
6 | address += 0x100000000 if address < 0
7 | inspect =~ /# ? "#<#{self.class}:0x#{'%x' % address}>" : inspect
8 | end
9 | end
10 |
11 | class String
12 | def mocha_inspect
13 | inspect.gsub(/\"/, "'")
14 | end
15 | end
16 |
17 | class Array
18 | def mocha_inspect
19 | "[#{collect { |member| member.mocha_inspect }.join(', ')}]"
20 | end
21 | end
22 |
23 | class Hash
24 | def mocha_inspect
25 | "{#{collect { |key, value| "#{key.mocha_inspect} => #{value.mocha_inspect}" }.join(', ')}}"
26 | end
27 | end
28 |
29 | class Time
30 | def mocha_inspect
31 | "#{inspect} (#{to_f} secs)"
32 | end
33 | end
34 |
35 | class Date
36 | def mocha_inspect
37 | to_s
38 | end
39 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/instance_method.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/class_method'
2 |
3 | module Mocha
4 |
5 | class InstanceMethod < ClassMethod
6 | end
7 |
8 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/is_a.rb:
--------------------------------------------------------------------------------
1 | class Object
2 |
3 | # :stopdoc:
4 |
5 | alias_method :__is_a__, :is_a?
6 |
7 | # :startdoc:
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/metaclass.rb:
--------------------------------------------------------------------------------
1 | class Object
2 |
3 | def __metaclass__
4 | class << self; self; end
5 | end
6 |
7 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/missing_expectation.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/expectation'
2 |
3 | module Mocha # :nodoc:
4 |
5 | class MissingExpectation < Expectation # :nodoc:
6 |
7 | def initialize(mock, method_name)
8 | super
9 | @invoked_count = true
10 | end
11 |
12 | def verify
13 | msg = error_message(0, 1)
14 | similar_expectations_list = @mock.similar_expectations(@method_name).collect { |expectation| expectation.method_signature }.join("\n")
15 | msg << "\nSimilar expectations:\n#{similar_expectations_list}" unless similar_expectations_list.empty?
16 | error = ExpectationError.new(msg)
17 | error.set_backtrace(filtered_backtrace)
18 | raise error if @invoked_count
19 | end
20 |
21 | def similar_expectations
22 | @mock.similar_expectations(method_name)
23 | end
24 |
25 | end
26 |
27 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/multiple_yields.rb:
--------------------------------------------------------------------------------
1 | module Mocha # :nodoc:
2 |
3 | class MultipleYields # :nodoc:
4 |
5 | attr_reader :parameter_groups
6 |
7 | def initialize(*parameter_groups)
8 | @parameter_groups = parameter_groups
9 | end
10 |
11 | def each
12 | @parameter_groups.each do |parameter_group|
13 | yield(parameter_group)
14 | end
15 | end
16 |
17 | end
18 |
19 | end
20 |
21 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/no_yields.rb:
--------------------------------------------------------------------------------
1 | module Mocha # :nodoc:
2 |
3 | class NoYields # :nodoc:
4 |
5 | def each
6 | end
7 |
8 | end
9 |
10 | end
11 |
12 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/parameter_matchers.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | # Used as parameters for Expectation#with to restrict the parameter values which will match the expectation.
4 | module ParameterMatchers; end
5 |
6 | end
7 |
8 |
9 | Dir[File.expand_path(File.join(File.dirname(__FILE__), 'parameter_matchers', "*.rb"))].each { |lib| require lib }
10 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/parameter_matchers/all_of.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: all_of -> parameter_matcher
6 | #
7 | # Matches if all +matchers+ match.
8 | # object = mock()
9 | # object.expects(:method_1).with(all_of(includes(1), includes(3)))
10 | # object.method_1([1, 3])
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(all_of(includes(1), includes(3)))
15 | # object.method_1([1, 2])
16 | # # error raised, because method_1 was not called with object including 1 and 3
17 | def all_of(*matchers)
18 | AllOf.new(*matchers)
19 | end
20 |
21 | class AllOf # :nodoc:
22 |
23 | def initialize(*matchers)
24 | @matchers = matchers
25 | end
26 |
27 | def ==(parameter)
28 | @matchers.all? { |matcher| matcher == parameter }
29 | end
30 |
31 | def mocha_inspect
32 | "all_of(#{@matchers.map { |matcher| matcher.mocha_inspect }.join(", ") })"
33 | end
34 |
35 | end
36 |
37 | end
38 |
39 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/parameter_matchers/any_of.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: any_of -> parameter_matcher
6 | #
7 | # Matches if any +matchers+ match.
8 | # object = mock()
9 | # object.expects(:method_1).with(any_of(1, 3))
10 | # object.method_1(1)
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(any_of(1, 3))
15 | # object.method_1(3)
16 | # # no error raised
17 | #
18 | # object = mock()
19 | # object.expects(:method_1).with(any_of(1, 3))
20 | # object.method_1(2)
21 | # # error raised, because method_1 was not called with 1 or 3
22 | def any_of(*matchers)
23 | AnyOf.new(*matchers)
24 | end
25 |
26 | class AnyOf # :nodoc:
27 |
28 | def initialize(*matchers)
29 | @matchers = matchers
30 | end
31 |
32 | def ==(parameter)
33 | @matchers.any? { |matcher| matcher == parameter }
34 | end
35 |
36 | def mocha_inspect
37 | "any_of(#{@matchers.map { |matcher| matcher.mocha_inspect }.join(", ") })"
38 | end
39 |
40 | end
41 |
42 | end
43 |
44 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/parameter_matchers/anything.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: anything -> parameter_matcher
6 | #
7 | # Matches any object.
8 | # object = mock()
9 | # object.expects(:method_1).with(anything)
10 | # object.method_1('foo')
11 | # # no error raised
12 | def anything
13 | Anything.new
14 | end
15 |
16 | class Anything # :nodoc:
17 |
18 | def ==(parameter)
19 | return true
20 | end
21 |
22 | def mocha_inspect
23 | "anything"
24 | end
25 |
26 | end
27 |
28 | end
29 |
30 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/parameter_matchers/has_entry.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: has_entry(key, value) -> parameter_matcher
6 | #
7 | # Matches +Hash+ containing entry with +key+ and +value+.
8 | # object = mock()
9 | # object.expects(:method_1).with(has_entry('key_1', 1))
10 | # object.method_1('key_1' => 1, 'key_2' => 2)
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(has_entry('key_1', 1))
15 | # object.method_1('key_1' => 2, 'key_2' => 1)
16 | # # error raised, because method_1 was not called with Hash containing entry: 'key_1' => 1
17 | def has_entry(key, value)
18 | HasEntry.new(key, value)
19 | end
20 |
21 | class HasEntry # :nodoc:
22 |
23 | def initialize(key, value)
24 | @key, @value = key, value
25 | end
26 |
27 | def ==(parameter)
28 | parameter[@key] == @value
29 | end
30 |
31 | def mocha_inspect
32 | "has_entry(#{@key.mocha_inspect}, #{@value.mocha_inspect})"
33 | end
34 |
35 | end
36 |
37 | end
38 |
39 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/parameter_matchers/has_key.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: has_key(key) -> parameter_matcher
6 | #
7 | # Matches +Hash+ containing +key+.
8 | # object = mock()
9 | # object.expects(:method_1).with(has_key('key_1'))
10 | # object.method_1('key_1' => 1, 'key_2' => 2)
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(has_key('key_1'))
15 | # object.method_1('key_2' => 2)
16 | # # error raised, because method_1 was not called with Hash containing key: 'key_1'
17 | def has_key(key)
18 | HasKey.new(key)
19 | end
20 |
21 | class HasKey # :nodoc:
22 |
23 | def initialize(key)
24 | @key = key
25 | end
26 |
27 | def ==(parameter)
28 | parameter.keys.include?(@key)
29 | end
30 |
31 | def mocha_inspect
32 | "has_key(#{@key.mocha_inspect})"
33 | end
34 |
35 | end
36 |
37 | end
38 |
39 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/parameter_matchers/has_value.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: has_value(value) -> parameter_matcher
6 | #
7 | # Matches +Hash+ containing +value+.
8 | # object = mock()
9 | # object.expects(:method_1).with(has_value(1))
10 | # object.method_1('key_1' => 1, 'key_2' => 2)
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(has_value(1))
15 | # object.method_1('key_2' => 2)
16 | # # error raised, because method_1 was not called with Hash containing value: 1
17 | def has_value(value)
18 | HasValue.new(value)
19 | end
20 |
21 | class HasValue # :nodoc:
22 |
23 | def initialize(value)
24 | @value = value
25 | end
26 |
27 | def ==(parameter)
28 | parameter.values.include?(@value)
29 | end
30 |
31 | def mocha_inspect
32 | "has_value(#{@value.mocha_inspect})"
33 | end
34 |
35 | end
36 |
37 | end
38 |
39 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/parameter_matchers/includes.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: includes(item) -> parameter_matcher
6 | #
7 | # Matches any object that responds true to include?(item)
8 | # object = mock()
9 | # object.expects(:method_1).with(includes('foo'))
10 | # object.method_1(['foo', 'bar'])
11 | # # no error raised
12 | #
13 | # object.method_1(['baz'])
14 | # # error raised, because ['baz'] does not include 'foo'.
15 | def includes(item)
16 | Includes.new(item)
17 | end
18 |
19 | class Includes # :nodoc:
20 |
21 | def initialize(item)
22 | @item = item
23 | end
24 |
25 | def ==(parameter)
26 | return parameter.include?(@item)
27 | end
28 |
29 | def mocha_inspect
30 | "includes(#{@item.mocha_inspect})"
31 | end
32 |
33 | end
34 |
35 | end
36 |
37 | end
38 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/parameter_matchers/instance_of.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: instance_of(klass) -> parameter_matcher
6 | #
7 | # Matches any object that is an instance of +klass+
8 | # object = mock()
9 | # object.expects(:method_1).with(instance_of(String))
10 | # object.method_1('string')
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(instance_of(String))
15 | # object.method_1(99)
16 | # # error raised, because method_1 was not called with an instance of String
17 | def instance_of(klass)
18 | InstanceOf.new(klass)
19 | end
20 |
21 | class InstanceOf # :nodoc:
22 |
23 | def initialize(klass)
24 | @klass = klass
25 | end
26 |
27 | def ==(parameter)
28 | parameter.instance_of?(@klass)
29 | end
30 |
31 | def mocha_inspect
32 | "instance_of(#{@klass.mocha_inspect})"
33 | end
34 |
35 | end
36 |
37 | end
38 |
39 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/parameter_matchers/kind_of.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: kind_of(klass) -> parameter_matcher
6 | #
7 | # Matches any object that is a kind of +klass+
8 | # object = mock()
9 | # object.expects(:method_1).with(kind_of(Integer))
10 | # object.method_1(99)
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(kind_of(Integer))
15 | # object.method_1('string')
16 | # # error raised, because method_1 was not called with a kind of Integer
17 | def kind_of(klass)
18 | KindOf.new(klass)
19 | end
20 |
21 | class KindOf # :nodoc:
22 |
23 | def initialize(klass)
24 | @klass = klass
25 | end
26 |
27 | def ==(parameter)
28 | parameter.kind_of?(@klass)
29 | end
30 |
31 | def mocha_inspect
32 | "kind_of(#{@klass.mocha_inspect})"
33 | end
34 |
35 | end
36 |
37 | end
38 |
39 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/parameter_matchers/regexp_matches.rb:
--------------------------------------------------------------------------------
1 | module Mocha
2 |
3 | module ParameterMatchers
4 |
5 | # :call-seq: regexp_matches(regexp) -> parameter_matcher
6 | #
7 | # Matches any object that matches the regular expression, +regexp+.
8 | # object = mock()
9 | # object.expects(:method_1).with(regexp_matches(/e/))
10 | # object.method_1('hello')
11 | # # no error raised
12 | #
13 | # object = mock()
14 | # object.expects(:method_1).with(regexp_matches(/a/))
15 | # object.method_1('hello')
16 | # # error raised, because method_1 was not called with a parameter that matched the
17 | # # regular expression
18 | def regexp_matches(regexp)
19 | RegexpMatches.new(regexp)
20 | end
21 |
22 | class RegexpMatches # :nodoc:
23 |
24 | def initialize(regexp)
25 | @regexp = regexp
26 | end
27 |
28 | def ==(parameter)
29 | parameter =~ @regexp
30 | end
31 |
32 | def mocha_inspect
33 | "regexp_matches(#{@regexp.mocha_inspect})"
34 | end
35 |
36 | end
37 |
38 | end
39 |
40 | end
41 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/pretty_parameters.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/inspect'
2 |
3 | module Mocha
4 |
5 | class PrettyParameters
6 |
7 | def initialize(params)
8 | @params = params
9 | @params_string = params.mocha_inspect
10 | end
11 |
12 | def pretty
13 | remove_outer_array_braces!
14 | remove_outer_hash_braces!
15 | @params_string
16 | end
17 |
18 | def remove_outer_array_braces!
19 | @params_string = @params_string.gsub(/^\[|\]$/, '')
20 | end
21 |
22 | def remove_outer_hash_braces!
23 | @params_string = @params_string.gsub(/^\{|\}$/, '') if @params.size == 1
24 | end
25 |
26 | end
27 |
28 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/return_values.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/single_return_value'
2 |
3 | module Mocha # :nodoc:
4 |
5 | class ReturnValues # :nodoc:
6 |
7 | def self.build(*values)
8 | new(*values.map { |value| SingleReturnValue.new(value) })
9 | end
10 |
11 | attr_accessor :values
12 |
13 | def initialize(*values)
14 | @values = values
15 | end
16 |
17 | def next
18 | case @values.size
19 | when 0: nil
20 | when 1: @values.first.evaluate
21 | else @values.shift.evaluate
22 | end
23 | end
24 |
25 | def +(other)
26 | self.class.new(*(@values + other.values))
27 | end
28 |
29 | end
30 |
31 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/setup_and_teardown.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/central'
2 |
3 | module Mocha
4 |
5 | module SetupAndTeardown
6 |
7 | def setup_stubs
8 | $stubba = Mocha::Central.new
9 | end
10 |
11 | def verify_stubs
12 | $stubba.verify_all { yield if block_given? } if $stubba
13 | end
14 |
15 | def teardown_stubs
16 | if $stubba then
17 | $stubba.unstub_all
18 | $stubba = nil
19 | end
20 | end
21 |
22 | end
23 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/single_return_value.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/is_a'
2 | require 'mocha/deprecation'
3 |
4 | module Mocha # :nodoc:
5 |
6 | class SingleReturnValue # :nodoc:
7 |
8 | def initialize(value)
9 | @value = value
10 | end
11 |
12 | def evaluate
13 | if @value.__is_a__(Proc) then
14 | message = 'use of Expectation#returns with instance of Proc - see Expectation#returns RDoc for alternatives'
15 | Deprecation.warning(message)
16 | @value.call
17 | else
18 | @value
19 | end
20 | end
21 |
22 | end
23 |
24 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/single_yield.rb:
--------------------------------------------------------------------------------
1 | module Mocha # :nodoc:
2 |
3 | class SingleYield # :nodoc:
4 |
5 | attr_reader :parameters
6 |
7 | def initialize(*parameters)
8 | @parameters = parameters
9 | end
10 |
11 | def each
12 | yield(@parameters)
13 | end
14 |
15 | end
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/standalone.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/auto_verify'
2 | require 'mocha/parameter_matchers'
3 | require 'mocha/setup_and_teardown'
4 |
5 | module Mocha
6 |
7 | module Standalone
8 |
9 | include AutoVerify
10 | include ParameterMatchers
11 | include SetupAndTeardown
12 |
13 | def mocha_setup
14 | setup_stubs
15 | end
16 |
17 | def mocha_verify(&block)
18 | verify_mocks(&block)
19 | verify_stubs(&block)
20 | end
21 |
22 | def mocha_teardown
23 | begin
24 | teardown_mocks
25 | ensure
26 | teardown_stubs
27 | end
28 | end
29 |
30 | end
31 |
32 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/stub.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/expectation'
2 |
3 | module Mocha # :nodoc:
4 |
5 | class Stub < Expectation # :nodoc:
6 |
7 | def initialize(mock, method_name, backtrace = nil)
8 | super
9 | @expected_count = Range.at_least(0)
10 | end
11 |
12 | def verify
13 | true
14 | end
15 |
16 | end
17 |
18 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha/yield_parameters.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/no_yields'
2 | require 'mocha/single_yield'
3 | require 'mocha/multiple_yields'
4 |
5 | module Mocha # :nodoc:
6 |
7 | class YieldParameters # :nodoc:
8 |
9 | def initialize
10 | @parameter_groups = []
11 | end
12 |
13 | def next_invocation
14 | case @parameter_groups.size
15 | when 0: NoYields.new
16 | when 1: @parameter_groups.first
17 | else @parameter_groups.shift
18 | end
19 | end
20 |
21 | def add(*parameters)
22 | @parameter_groups << SingleYield.new(*parameters)
23 | end
24 |
25 | def multiple_add(*parameter_groups)
26 | @parameter_groups << MultipleYields.new(*parameter_groups)
27 | end
28 |
29 | end
30 |
31 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/mocha_standalone.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/standalone'
2 | require 'mocha/object'
3 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/lib/stubba.rb:
--------------------------------------------------------------------------------
1 | # for backwards compatibility
2 | require 'mocha'
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/active_record_test_case.rb:
--------------------------------------------------------------------------------
1 | module ActiveRecordTestCase
2 |
3 | def setup_with_fixtures
4 | methods_called << :setup_with_fixtures
5 | end
6 |
7 | alias_method :setup, :setup_with_fixtures
8 |
9 | def teardown_with_fixtures
10 | methods_called << :teardown_with_fixtures
11 | end
12 |
13 | alias_method :teardown, :teardown_with_fixtures
14 |
15 | def self.method_added(method)
16 | case method.to_s
17 | when 'setup'
18 | unless method_defined?(:setup_without_fixtures)
19 | alias_method :setup_without_fixtures, :setup
20 | define_method(:setup) do
21 | setup_with_fixtures
22 | setup_without_fixtures
23 | end
24 | end
25 | when 'teardown'
26 | unless method_defined?(:teardown_without_fixtures)
27 | alias_method :teardown_without_fixtures, :teardown
28 | define_method(:teardown) do
29 | teardown_without_fixtures
30 | teardown_with_fixtures
31 | end
32 | end
33 | end
34 | end
35 |
36 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/deprecation_disabler.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/deprecation'
2 |
3 | module DeprecationDisabler
4 |
5 | def disable_deprecations
6 | original_mode = Mocha::Deprecation.mode
7 | Mocha::Deprecation.mode = :disabled
8 | begin
9 | yield
10 | ensure
11 | Mocha::Deprecation.mode = original_mode
12 | end
13 | end
14 |
15 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/execution_point.rb:
--------------------------------------------------------------------------------
1 | class ExecutionPoint
2 |
3 | attr_reader :backtrace
4 |
5 | def self.current
6 | new(caller)
7 | end
8 |
9 | def initialize(backtrace)
10 | @backtrace = backtrace
11 | end
12 |
13 | def file_name
14 | /\A(.*?):\d+/.match(@backtrace.first)[1]
15 | end
16 |
17 | def line_number
18 | Integer(/\A.*?:(\d+)/.match(@backtrace.first)[1])
19 | end
20 |
21 | def ==(other)
22 | return false unless other.is_a?(ExecutionPoint)
23 | (file_name == other.file_name) and (line_number == other.line_number)
24 | end
25 |
26 | def to_s
27 | "file: #{file_name} line: #{line_number}"
28 | end
29 |
30 | def inspect
31 | to_s
32 | end
33 |
34 | end
35 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/method_definer.rb:
--------------------------------------------------------------------------------
1 | require 'mocha/metaclass'
2 |
3 | class Object
4 |
5 | def define_instance_method(method_symbol, &block)
6 | __metaclass__.send(:define_method, method_symbol, block)
7 | end
8 |
9 | def replace_instance_method(method_symbol, &block)
10 | raise "Cannot replace #{method_symbol} as #{self} does not respond to it." unless self.respond_to?(method_symbol)
11 | define_instance_method(method_symbol, &block)
12 | end
13 |
14 | def define_instance_accessor(*symbols)
15 | symbols.each { |symbol| __metaclass__.send(:attr_accessor, symbol) }
16 | end
17 |
18 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/test_helper.rb:
--------------------------------------------------------------------------------
1 | unless defined?(STANDARD_OBJECT_PUBLIC_INSTANCE_METHODS)
2 | STANDARD_OBJECT_PUBLIC_INSTANCE_METHODS = Object.public_instance_methods
3 | end
4 |
5 | $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
6 | $:.unshift File.expand_path(File.join(File.dirname(__FILE__)))
7 | $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'unit'))
8 | $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'unit', 'parameter_matchers'))
9 | $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'integration'))
10 | $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'acceptance'))
11 |
12 | require 'test/unit'
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/test_runner.rb:
--------------------------------------------------------------------------------
1 | require 'test/unit/testresult'
2 | require 'test/unit/testcase'
3 | require 'mocha/standalone'
4 | require 'mocha/test_case_adapter'
5 |
6 | module TestRunner
7 |
8 | def run_test(test_result = Test::Unit::TestResult.new, &block)
9 | test_class = Class.new(Test::Unit::TestCase) do
10 | include Mocha::Standalone
11 | include Mocha::TestCaseAdapter
12 | define_method(:test_me, &block)
13 | end
14 | test = test_class.new(:test_me)
15 | test.run(test_result) {}
16 | class << test_result
17 | attr_reader :failures, :errors
18 | end
19 | test_result
20 | end
21 |
22 | def assert_passed(test_result)
23 | flunk "Test failed unexpectedly with message: #{test_result.failures.first.message}" if test_result.failure_count > 0
24 | flunk "Test failed unexpectedly with message: #{test_result.errors.first.message}" if test_result.error_count > 0
25 | end
26 |
27 | def assert_failed(test_result)
28 | flunk "Test passed unexpectedly" if test_result.passed?
29 | end
30 |
31 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/array_inspect_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/inspect'
3 |
4 | class ArrayInstanceTest < Test::Unit::TestCase
5 |
6 | def test_should_use_inspect
7 | array = [1, 2]
8 | assert_equal array.inspect, array.mocha_inspect
9 | end
10 |
11 | def test_should_use_mocha_inspect_on_each_item
12 | array = [1, 2, "chris"]
13 | assert_equal "[1, 2, 'chris']", array.mocha_inspect
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/date_time_inspect_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/inspect'
3 |
4 | class TimeDateInspectTest < Test::Unit::TestCase
5 |
6 | def test_should_use_include_date_in_seconds
7 | time = Time.now
8 | assert_equal "#{time.inspect} (#{time.to_f} secs)", time.mocha_inspect
9 | end
10 |
11 | def test_should_use_to_s_for_date
12 | date = Date.new(2006, 1, 1)
13 | assert_equal date.to_s, date.mocha_inspect
14 | end
15 |
16 | def test_should_use_to_s_for_datetime
17 | datetime = DateTime.new(2006, 1, 1)
18 | assert_equal datetime.to_s, datetime.mocha_inspect
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/expectation_raiser_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 |
3 | require 'mocha/exception_raiser'
4 |
5 | class ExceptionRaiserTest < Test::Unit::TestCase
6 |
7 | include Mocha
8 |
9 | def test_should_raise_exception_with_specified_class_and_default_message
10 | exception_class = Class.new(StandardError)
11 | raiser = ExceptionRaiser.new(exception_class, nil)
12 | exception = assert_raises(exception_class) { raiser.evaluate }
13 | assert_equal exception_class.to_s, exception.message
14 | end
15 |
16 | def test_should_raise_exception_with_specified_class_and_message
17 | exception_class = Class.new(StandardError)
18 | raiser = ExceptionRaiser.new(exception_class, 'message')
19 | exception = assert_raises(exception_class) { raiser.evaluate }
20 | assert_equal 'message', exception.message
21 | end
22 |
23 | def test_should_raise_interrupt_exception_with_default_message_so_it_works_in_ruby_1_8_6
24 | raiser = ExceptionRaiser.new(Interrupt, nil)
25 | assert_raises(Interrupt) { raiser.evaluate }
26 | end
27 |
28 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/hash_inspect_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/inspect'
3 |
4 | class HashInspectTest < Test::Unit::TestCase
5 |
6 | def test_should_keep_spacing_between_key_value
7 | hash = {:a => true}
8 | assert_equal '{:a => true}', hash.mocha_inspect
9 | end
10 |
11 | def test_should_use_mocha_inspect_on_each_item
12 | hash = {:a => 'mocha'}
13 | assert_equal "{:a => 'mocha'}", hash.mocha_inspect
14 | end
15 |
16 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/metaclass_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/metaclass'
3 |
4 | class MetaclassTest < Test::Unit::TestCase
5 |
6 | def test_should_return_objects_singleton_class
7 | object = Object.new
8 | assert_raises(NoMethodError) { object.success? }
9 |
10 | object = Object.new
11 | assert object.__metaclass__.ancestors.include?(Object)
12 | assert object.__metaclass__.ancestors.include?(Kernel)
13 | assert object.__metaclass__.is_a?(Class)
14 |
15 | object.__metaclass__.class_eval { def success?; true; end }
16 | assert object.success?
17 |
18 | object = Object.new
19 | assert_raises(NoMethodError) { object.success? }
20 | end
21 |
22 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/multiple_yields_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 |
3 | require 'mocha/multiple_yields'
4 |
5 | class MultipleYieldsTest < Test::Unit::TestCase
6 |
7 | include Mocha
8 |
9 | def test_should_provide_parameters_for_multiple_yields_in_single_invocation
10 | parameter_group = MultipleYields.new([1, 2, 3], [4, 5])
11 | parameter_groups = []
12 | parameter_group.each do |parameters|
13 | parameter_groups << parameters
14 | end
15 | assert_equal [[1, 2, 3], [4, 5]], parameter_groups
16 | end
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/no_yield_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 |
3 | require 'mocha/no_yields'
4 |
5 | class NoYieldsTest < Test::Unit::TestCase
6 |
7 | include Mocha
8 |
9 | def test_should_provide_parameters_for_no_yields_in_single_invocation
10 | parameter_group = NoYields.new
11 | parameter_groups = []
12 | parameter_group.each do |parameters|
13 | parameter_groups << parameters
14 | end
15 | assert_equal [], parameter_groups
16 | end
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/parameter_matchers/all_of_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/all_of'
4 | require 'mocha/inspect'
5 | require 'stub_matcher'
6 |
7 | class AllOfTest < Test::Unit::TestCase
8 |
9 | include Mocha::ParameterMatchers
10 |
11 | def test_should_match_if_all_matchers_match
12 | matcher = all_of(Stub::Matcher.new(true), Stub::Matcher.new(true), Stub::Matcher.new(true))
13 | assert matcher == 'any_old_value'
14 | end
15 |
16 | def test_should_not_match_if_any_matcher_does_not_match
17 | matcher = all_of(Stub::Matcher.new(true), Stub::Matcher.new(false), Stub::Matcher.new(true))
18 | assert matcher != 'any_old_value'
19 | end
20 |
21 | def test_should_describe_matcher
22 | matcher = all_of(Stub::Matcher.new(true), Stub::Matcher.new(false), Stub::Matcher.new(true))
23 | assert_equal 'all_of(matcher(true), matcher(false), matcher(true))', matcher.mocha_inspect
24 | end
25 |
26 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/parameter_matchers/any_of_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/any_of'
4 | require 'mocha/inspect'
5 | require 'stub_matcher'
6 |
7 | class AnyOfTest < Test::Unit::TestCase
8 |
9 | include Mocha::ParameterMatchers
10 |
11 | def test_should_match_if_any_matchers_match
12 | matcher = any_of(Stub::Matcher.new(false), Stub::Matcher.new(true), Stub::Matcher.new(false))
13 | assert matcher == 'any_old_value'
14 | end
15 |
16 | def test_should_not_match_if_no_matchers_match
17 | matcher = any_of(Stub::Matcher.new(false), Stub::Matcher.new(false), Stub::Matcher.new(false))
18 | assert matcher != 'any_old_value'
19 | end
20 |
21 | def test_should_describe_matcher
22 | matcher = any_of(Stub::Matcher.new(false), Stub::Matcher.new(true), Stub::Matcher.new(false))
23 | assert_equal 'any_of(matcher(false), matcher(true), matcher(false))', matcher.mocha_inspect
24 | end
25 |
26 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/parameter_matchers/anything_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/anything'
4 | require 'mocha/inspect'
5 |
6 | class AnythingTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_anything
11 | matcher = anything
12 | assert matcher == :something
13 | assert matcher == {'x' => 'y'}
14 | end
15 |
16 | def test_should_describe_matcher
17 | matcher = anything
18 | assert_equal "anything", matcher.mocha_inspect
19 | end
20 |
21 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/parameter_matchers/has_entry_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/has_entry'
4 | require 'mocha/inspect'
5 |
6 | class HasEntryTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_hash_including_specified_entry
11 | matcher = has_entry(:key_1, 'value_1')
12 | assert matcher == { :key_1 => 'value_1', :key_2 => 'value_2' }
13 | end
14 |
15 | def test_should_not_match_hash_not_including_specified_entry
16 | matcher = has_entry(:key_1, 'value_2')
17 | assert matcher != { :key_1 => 'value_1', :key_2 => 'value_2' }
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = has_entry(:key_1, 'value_1')
22 | assert_equal "has_entry(:key_1, 'value_1')", matcher.mocha_inspect
23 | end
24 |
25 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/parameter_matchers/has_key_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/has_key'
4 | require 'mocha/inspect'
5 |
6 | class HasKeyTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_hash_including_specified_key
11 | matcher = has_key(:key_1)
12 | assert matcher == { :key_1 => 1, :key_2 => 2 }
13 | end
14 |
15 | def test_should_not_match_hash_not_including_specified_key
16 | matcher = has_key(:key_1)
17 | assert matcher != { :key_2 => 2 }
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = has_key(:key)
22 | assert_equal 'has_key(:key)', matcher.mocha_inspect
23 | end
24 |
25 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/parameter_matchers/has_value_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/has_value'
4 | require 'mocha/inspect'
5 |
6 | class HasValueTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_hash_including_specified_value
11 | matcher = has_value('value_1')
12 | assert matcher == { :key_1 => 'value_1', :key_2 => 'value_2' }
13 | end
14 |
15 | def test_should_not_match_hash_not_including_specified_value
16 | matcher = has_value('value_1')
17 | assert matcher != { :key_2 => 'value_2' }
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = has_value('value_1')
22 | assert_equal "has_value('value_1')", matcher.mocha_inspect
23 | end
24 |
25 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/parameter_matchers/includes_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/includes'
4 | require 'mocha/inspect'
5 |
6 | class IncludesTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_object_including_value
11 | matcher = includes(:x)
12 | assert matcher == [:x, :y, :z]
13 | end
14 |
15 | def test_should_not_match_object_that_does_not_include_value
16 | matcher = includes(:not_included)
17 | assert matcher != [:x, :y, :z]
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = includes(:x)
22 | assert_equal "includes(:x)", matcher.mocha_inspect
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/parameter_matchers/instance_of_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/instance_of'
4 | require 'mocha/inspect'
5 |
6 | class InstanceOfTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_object_that_is_an_instance_of_specified_class
11 | matcher = instance_of(String)
12 | assert matcher == 'string'
13 | end
14 |
15 | def test_should_not_match_object_that_is_not_an_instance_of_specified_class
16 | matcher = instance_of(String)
17 | assert matcher != 99
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = instance_of(String)
22 | assert_equal "instance_of(String)", matcher.mocha_inspect
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/parameter_matchers/kind_of_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/kind_of'
4 | require 'mocha/inspect'
5 |
6 | class InstanceOfTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_object_that_is_a_kind_of_specified_class
11 | matcher = kind_of(Integer)
12 | assert matcher == 99
13 | end
14 |
15 | def test_should_not_match_object_that_is_not_a_kind_of_specified_class
16 | matcher = kind_of(Integer)
17 | assert matcher != 'string'
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = kind_of(Integer)
22 | assert_equal "kind_of(Integer)", matcher.mocha_inspect
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/parameter_matchers/regexp_matches_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2 |
3 | require 'mocha/parameter_matchers/regexp_matches'
4 | require 'mocha/inspect'
5 |
6 | class MatchesTest < Test::Unit::TestCase
7 |
8 | include Mocha::ParameterMatchers
9 |
10 | def test_should_match_parameter_matching_regular_expression
11 | matcher = regexp_matches(/oo/)
12 | assert matcher == 'foo'
13 | end
14 |
15 | def test_should_not_match_parameter_not_matching_regular_expression
16 | matcher = regexp_matches(/oo/)
17 | assert matcher != 'bar'
18 | end
19 |
20 | def test_should_describe_matcher
21 | matcher = regexp_matches(/oo/)
22 | assert_equal "regexp_matches(/oo/)", matcher.mocha_inspect
23 | end
24 |
25 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/parameter_matchers/stub_matcher.rb:
--------------------------------------------------------------------------------
1 | module Stub
2 |
3 | class Matcher
4 |
5 | attr_accessor :value
6 |
7 | def initialize(matches)
8 | @matches = matches
9 | end
10 |
11 | def ==(value)
12 | @value = value
13 | @matches
14 | end
15 |
16 | def mocha_inspect
17 | "matcher(#{@matches})"
18 | end
19 |
20 | end
21 |
22 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/pretty_parameters_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/pretty_parameters'
3 |
4 | class PrettyParametersTest < Test::Unit::TestCase
5 |
6 | include Mocha
7 |
8 | def test_should_remove_outer_array_braces
9 | params = [1, 2, [3, 4]]
10 | parameters = PrettyParameters.new(params)
11 | assert_equal '1, 2, [3, 4]', parameters.pretty
12 | end
13 |
14 | def test_should_display_numeric_arguments_as_is
15 | params = [1, 2, 3]
16 | parameters = PrettyParameters.new(params)
17 | assert_equal '1, 2, 3', parameters.pretty
18 | end
19 |
20 | def test_should_remove_curly_braces_if_hash_is_only_argument
21 | params = [{:a => 1, :z => 2}]
22 | parameters = PrettyParameters.new(params)
23 | assert_match /^:[az] => [12], :[az] => [12]$/, parameters.pretty
24 | end
25 |
26 | def test_should_not_remove_curly_braces_if_hash_is_not_the_only_argument
27 | params = [1, {:a => 1}]
28 | parameters = PrettyParameters.new(params)
29 | assert_equal '1, {:a => 1}', parameters.pretty
30 | end
31 |
32 | end
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/single_return_value_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 |
3 | require 'mocha/single_return_value'
4 | require 'deprecation_disabler'
5 |
6 | class SingleReturnValueTest < Test::Unit::TestCase
7 |
8 | include Mocha
9 | include DeprecationDisabler
10 |
11 | def test_should_return_value
12 | value = SingleReturnValue.new('value')
13 | assert_equal 'value', value.evaluate
14 | end
15 |
16 | def test_should_return_result_of_calling_proc
17 | proc = lambda { 'value' }
18 | value = SingleReturnValue.new(proc)
19 | result = nil
20 | disable_deprecations { result = value.evaluate }
21 | assert_equal 'value', result
22 | end
23 |
24 | def test_should_indicate_deprecated_use_of_expectation_returns_method
25 | proc = lambda {}
26 | value = SingleReturnValue.new(proc)
27 | Deprecation.messages = []
28 | disable_deprecations { value.evaluate }
29 | expected_message = "use of Expectation#returns with instance of Proc - see Expectation#returns RDoc for alternatives"
30 | assert_equal [expected_message], Deprecation.messages
31 | end
32 |
33 | end
34 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/single_yield_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 |
3 | require 'mocha/single_yield'
4 |
5 | class SingleYieldTest < Test::Unit::TestCase
6 |
7 | include Mocha
8 |
9 | def test_should_provide_parameters_for_single_yield_in_single_invocation
10 | parameter_group = SingleYield.new(1, 2, 3)
11 | parameter_groups = []
12 | parameter_group.each do |parameters|
13 | parameter_groups << parameters
14 | end
15 | assert_equal [[1, 2, 3]], parameter_groups
16 | end
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/string_inspect_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/inspect'
3 |
4 | class StringInspectTest < Test::Unit::TestCase
5 |
6 | def test_should_replace_escaped_quotes_with_single_quote
7 | string = "my_string"
8 | assert_equal "'my_string'", string.mocha_inspect
9 | end
10 |
11 | end
12 |
--------------------------------------------------------------------------------
/vendor/mocha-0.5.5/test/unit/stub_test.rb:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(__FILE__), "..", "test_helper")
2 | require 'mocha/stub'
3 |
4 | class StubTest < Test::Unit::TestCase
5 |
6 | include Mocha
7 |
8 | def test_should_always_verify_successfully
9 | stub = Stub.new(nil, :expected_method)
10 | assert stub.verify
11 | stub.invoke
12 | assert stub.verify
13 | end
14 |
15 | def test_should_match_successfully_for_any_number_of_invocations
16 | stub = Stub.new(nil, :expected_method)
17 | assert stub.match?(:expected_method)
18 | stub.invoke
19 | assert stub.match?(:expected_method)
20 | stub.invoke
21 | assert stub.match?(:expected_method)
22 | end
23 |
24 | end
--------------------------------------------------------------------------------
/vendor/objenesis-1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/objenesis-1.0.jar
--------------------------------------------------------------------------------
/vendor/pmd-4.2.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/pmd-4.2.2.jar
--------------------------------------------------------------------------------
/vendor/proxytoys-0.2.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/proxytoys-0.2.1.jar
--------------------------------------------------------------------------------
/vendor/selenium-java-client-driver-1.0-SNAPSHOT.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/selenium-java-client-driver-1.0-SNAPSHOT.jar
--------------------------------------------------------------------------------
/vendor/servlet-api-2.5-6.1.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/servlet-api-2.5-6.1.5.jar
--------------------------------------------------------------------------------
/vendor/testng-5.7-jdk15.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcotton/selenium-grid/9d05140058657ecca7942b0bdfc62d570bca11d2/vendor/testng-5.7-jdk15.jar
--------------------------------------------------------------------------------