tobytripp-selenium_specr 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README ADDED
@@ -0,0 +1,54 @@
1
+ = SeleniumSpecr
2
+
3
+ This is a library/plugin that aims to ease the creation and maintenance of Selenium[http://selenium.openqa.org/] functional tests.
4
+
5
+ SeleniumSpecr operates in one of two modes: as a Rails[http://rubyonrails.com/] plug-in, or as a stand-alone project to test any running web application.
6
+
7
+
8
+ == Using SeleniumSpecr Stand-Alone
9
+
10
+ Generate your test project using the 'specr' application generator:
11
+
12
+ specr my_test_project
13
+
14
+ This will create a new project directory called 'my_test_project'. Start creating selenium specs by using the included spec generator:
15
+
16
+ cd my_test_project
17
+ script/generate selenium_spec open_page
18
+
19
+ Run your specs using the included rake task:
20
+
21
+ rake test:selenium
22
+
23
+ === Configuration
24
+
25
+ Your test project will include a YAML configuration file that tells SeleniumSpecr where to find your web application. You can find it in 'config/selenium.yml'.
26
+
27
+ If you provide 'start' and 'stop' configurations, SeleniumSpecr will start and stop your application server for you by executing the provided commands in a shell. For example, the following configuration snippet will instruct SeleniumSpecr to start and stop a mongrel rails server before and after each test run:
28
+
29
+ app_server:
30
+ url: http://localhost:3800
31
+ start: mongrel_rails start -d -p 3800 -P log/mongrel.pid
32
+ stop: mongrel_rails stop -P log/mongrel.pid && rm -f log/mongrel.pid
33
+
34
+
35
+ # Note: P Gross has requested this be converted from YAML to just a Ruby file. Sounds like a plan.
36
+
37
+
38
+ == Using SeleniumSpecr as a Rails plug-in
39
+
40
+ === Installation
41
+
42
+ You can SeleniumSpecr as a git submodule (if you're using git for your Rails project) like this:
43
+ git submodule add git://github.com/tobytripp/selenium-specr.git vendor/plugins/selenium_specr
44
+ or, if you're using Rails 2.0.2 or later, you can use script/plugin to install it from github[http://github.com]:
45
+ ./script/plugin install git://github.com/tobytripp/selenium-specr.git
46
+
47
+
48
+
49
+ = TODO
50
+
51
+ 1. Make Selenium tests easier to run by bundling a set of Rake tasks that manage starting the selenium RC server, starting the application server, running all the specs, and then shutting the whole thing down when it's finished.
52
+ 2. Make Selenium tests easier to write by including a set of action macros and spec generators.
53
+ 3. Make Selenium tests easier to maintain by making it easier to push specs down into unit or integration tests.
54
+
data/bin/specr ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rubigen'
5
+
6
+ # PROJ_ROOT = File.join("#{File.dirname(__FILE__)}", "..")
7
+ # $LOAD_PATH << "#{PROJ_ROOT}/lib"
8
+
9
+ if %w(-v --version).include? ARGV.first
10
+ require 'selenium_specr/version'
11
+ puts "#{File.basename($0)} #{Specr::VERSION::STRING}"
12
+ exit 0
13
+ end
14
+
15
+ require 'rubigen/scripts/generate'
16
+
17
+ source = RubiGen::PathSource.new(
18
+ :application,
19
+ File.join( File.dirname(__FILE__), %w(.. app_generators) )
20
+ )
21
+
22
+ RubiGen::Base.reset_sources
23
+ RubiGen::Base.append_sources source
24
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'specr')
@@ -0,0 +1,15 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) ||
3
+ $:.include?(File.expand_path(File.dirname(__FILE__)))
4
+
5
+ require "selenium_specr/initializer"
6
+
7
+ module SeleniumSpecr
8
+ if defined?( RAILS_ROOT )
9
+ PROJ_ROOT = RAILS_ROOT
10
+ else
11
+ PROJ_ROOT = File.join( "#{File.dirname(__FILE__)}", ".." )
12
+ end
13
+
14
+ Initializer::execute
15
+ end
@@ -0,0 +1,9 @@
1
+ module Specr #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ TINY = 1
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "Register" do
4
+ it "should open" do
5
+ @browser.open '/account/1/transfers'
6
+ end
7
+
8
+ it "should fail" do
9
+ @browser.open '/account/1/transfers'
10
+ puts @browser.html
11
+ raise "FAIL!"
12
+ end
13
+
14
+ end
@@ -0,0 +1,45 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+
3
+ class TestSeleniumSpecGenerator < Test::Unit::TestCase
4
+ include RubiGen::GeneratorTestHelper
5
+
6
+ def setup() bare_setup; end
7
+ def teardown() bare_teardown; end
8
+
9
+ # Some generator-related assertions:
10
+ # assert_generated_file(name, &block) # block passed the file contents
11
+ # assert_directory_exists(name)
12
+ # assert_generated_class(name, &block)
13
+ # assert_generated_module(name, &block)
14
+ # assert_generated_test_for(name, &block)
15
+ # The assert_generated_(class|module|test_for) &block is passed the body of
16
+ # the class/module within the file assert_has_method(body, *methods)
17
+ # check that the body has a list of methods (methods with parentheses not
18
+ # supported yet)
19
+ #
20
+ # Other helper methods are:
21
+ # app_root_files - put this in teardown to show files generated by the
22
+ # test method (e.g. p app_root_files)
23
+ # bare_setup - place this in setup method to create the APP_ROOT folder
24
+ # for each test
25
+ # bare_teardown - place this in teardown method to destroy the TMP_ROOT or
26
+ # APP_ROOT folder after each test
27
+ def test_generator_without_options
28
+ name = "my_app"
29
+ run_generator('selenium_spec', [name], sources)
30
+ assert_generated_file("spec/selenium/specs/my_app_spec.rb") do |contents|
31
+ assert_match /^describe "MyApp"/, contents
32
+ end
33
+ end
34
+
35
+ private
36
+ def sources
37
+ [RubiGen::PathSource.new(
38
+ :test, File.join(File.dirname(__FILE__), "..", generator_path))
39
+ ]
40
+ end
41
+
42
+ def generator_path
43
+ "lib/generators"
44
+ end
45
+ end
@@ -0,0 +1,72 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+
3
+ class TestSpecrGenerator < Test::Unit::TestCase
4
+ include RubiGen::GeneratorTestHelper
5
+
6
+ def setup
7
+ bare_setup
8
+ end
9
+
10
+ def teardown
11
+ bare_teardown
12
+ end
13
+
14
+ # Some generator-related assertions:
15
+ # assert_generated_file(name, &block) # block passed the file contents
16
+ # assert_directory_exists(name)
17
+ # assert_generated_class(name, &block)
18
+ # assert_generated_module(name, &block)
19
+ # assert_generated_test_for(name, &block)
20
+ # The assert_generated_(class|module|test_for) &block is passed the body of
21
+ # the class/module within the file assert_has_method(body, *methods)
22
+ # check that the body has a list of methods (methods with parentheses not
23
+ # supported yet)
24
+ #
25
+ # Other helper methods are:
26
+ # app_root_files - put this in teardown to show files generated by the
27
+ # test method (e.g. p app_root_files)
28
+ # bare_setup - place this in setup method to create the APP_ROOT folder
29
+ # for each test
30
+ # bare_teardown - place this in teardown method to destroy the TMP_ROOT or
31
+ # APP_ROOT folder after each test
32
+ def test_generator_without_options
33
+ run_generator('specr', [APP_ROOT], sources)
34
+
35
+ assert_directory_exists "lib/tasks"
36
+ assert_directory_exists "lib/core_ext"
37
+ assert_directory_exists "config"
38
+ assert_directory_exists "script"
39
+ assert_directory_exists "spec/selenium/helpers"
40
+ assert_directory_exists "generators/selenium_spec"
41
+
42
+ assert_generated_file "lib/selenium_specr/selenium_rc_server.rb"
43
+ assert_generated_file "lib/selenium_specr/application_server.rb"
44
+ assert_generated_file "lib/selenium_specr/shell.rb"
45
+ assert_generated_file "lib/selenium_specr/formatter/screenshot_formatter.rb"
46
+ assert_generated_file "lib/core_ext/string_extensions.rb"
47
+ assert_generated_file "lib/tasks/task_loader.rb"
48
+ assert_generated_file "lib/tasks/test/selenium.rake"
49
+ assert_generated_file "lib/tasks/test/selenium.rb"
50
+ assert_generated_file "spec/selenium/spec_helper.rb"
51
+ assert_generated_file "spec/selenium/selenium.rb"
52
+ assert_generated_file "config/selenium.yml"
53
+ assert_generated_file "lib/bin/selenium-server.jar"
54
+
55
+ assert_generated_file "Rakefile"
56
+ assert_generated_file "script/console"
57
+ assert_generated_file "script/generate"
58
+
59
+ assert_generated_file "generators/selenium_spec/selenium_spec_generator.rb"
60
+ end
61
+
62
+ private
63
+ def sources
64
+ [ RubiGen::PathSource.new(
65
+ :test, File.join( File.dirname(__FILE__), "..", generator_path )
66
+ ) ]
67
+ end
68
+
69
+ def generator_path
70
+ "app_generators"
71
+ end
72
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tobytripp-selenium_specr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Toby Tripp
8
+ - Lydia Tripp
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-06-25 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rspec
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.1.3
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ version_requirement:
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.8.1
33
+ version:
34
+ - !ruby/object:Gem::Dependency
35
+ name: diff-lcs
36
+ version_requirement:
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 1.1.2
42
+ version:
43
+ - !ruby/object:Gem::Dependency
44
+ name: rubigen
45
+ version_requirement:
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 1.1.2
51
+ version:
52
+ description:
53
+ email: ""
54
+ executables: []
55
+
56
+ extensions: []
57
+
58
+ extra_rdoc_files:
59
+ - README
60
+ files:
61
+ - bin/specr
62
+ - lib/selenium_specr
63
+ - lib/selenium_specr/core_ext
64
+ - lib/selenium_specr/core_ext/string_extensions.rb
65
+ - lib/selenium_specr/version.rb
66
+ - lib/selenium.rb
67
+ - lib/selenium_specr.rb
68
+ - lib/tasks
69
+ - lib/tasks/gem.rake
70
+ - lib/tasks/task_loader.rb
71
+ - lib/tasks/test
72
+ - lib/tasks/test/selenium.rake
73
+ - README
74
+ has_rdoc: true
75
+ homepage: http://ttripp.blogspot.com
76
+ post_install_message:
77
+ rdoc_options:
78
+ - --main
79
+ - README
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ version:
94
+ requirements: []
95
+
96
+ rubyforge_project:
97
+ rubygems_version: 1.2.0
98
+ signing_key:
99
+ specification_version: 2
100
+ summary: Rake tasks and scripts for automating Selenium RSpec testing.
101
+ test_files:
102
+ - test/selenium_spec_generator_test.rb
103
+ - test/specr_generator_test.rb
104
+ - test/selenium/specs/register_spec.rb