watirsplash 0.2.14 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/History.rdoc +8 -0
  2. data/License.txt +2 -2
  3. data/README.rdoc +5 -5
  4. data/Rakefile +16 -17
  5. data/VERSION +1 -1
  6. data/bin/watirsplash +2 -9
  7. data/lib/watirsplash.rb +5 -7
  8. data/lib/watirsplash/cli.rb +34 -0
  9. data/lib/watirsplash/file_helper.rb +1 -1
  10. data/lib/watirsplash/generators/migrate_project.rb +25 -0
  11. data/lib/watirsplash/generators/new_common_project.rb +18 -0
  12. data/lib/watirsplash/generators/new_project.rb +45 -0
  13. data/{templates/common/config.rb → lib/watirsplash/generators/templates/new_common_project/config.rb.tt} +4 -4
  14. data/{templates/common → lib/watirsplash/generators/templates/new_common_project}/environment.rb +3 -3
  15. data/{templates/common → lib/watirsplash/generators/templates/new_common_project}/lib/common_application_helper.rb +2 -2
  16. data/lib/watirsplash/generators/templates/new_project/.rspec +2 -0
  17. data/lib/watirsplash/generators/templates/new_project/config.rb.tt +22 -0
  18. data/{templates/project/environment.rb → lib/watirsplash/generators/templates/new_project/environment.rb.tt} +4 -5
  19. data/{templates/project/spec/application_helper.rb → lib/watirsplash/generators/templates/new_project/spec/%formatted_name%_helper.rb.tt} +3 -3
  20. data/lib/watirsplash/generators/templates/new_project/spec/dummy_spec.rb.tt +40 -0
  21. data/lib/watirsplash/html_formatter.rb +14 -16
  22. data/lib/watirsplash/rspec_patches.rb +74 -0
  23. data/lib/watirsplash/spec_helper.rb +2 -10
  24. data/lib/watirsplash/util.rb +15 -1
  25. data/lib/watirsplash/{watir.rb → watir_patches.rb} +3 -7
  26. data/spec/file_helper_spec.rb +19 -0
  27. data/spec/spec_helper_spec.rb +0 -13
  28. data/spec/spec_match_array_spec.rb +0 -2
  29. data/spec/util_spec.rb +0 -2
  30. data/spec/watir_ie_spec.rb +14 -31
  31. metadata +61 -50
  32. data/lib/watirsplash/element_extensions.rb +0 -70
  33. data/lib/watirsplash/generator.rb +0 -55
  34. data/lib/watirsplash/spec.rb +0 -53
  35. data/lib/watirsplash/wait_helper.rb +0 -44
  36. data/spec/spec.opts +0 -11
  37. data/spec/watir_element_spec.rb +0 -69
  38. data/spec/watir_table_row_spec.rb +0 -45
  39. data/spec/watir_table_spec.rb +0 -78
  40. data/templates/project/config.rb +0 -22
  41. data/templates/project/spec/dummy_spec.rb +0 -44
  42. data/templates/project/spec/spec.opts +0 -11
@@ -1,3 +1,11 @@
1
+ === Version 1.0.0 / 2011-01-26
2
+
3
+ * using RSpec 2
4
+ - if you have projects using WatirSplash <= 0.2.14 then execute `watirsplash migrate` under ui-test and ui-test-common directories!
5
+ * removed Watir::WaitHelper - use Watir's waiting methods instead
6
+ * using Watir 1.7.1
7
+ * use WATIRSPLASH_RESULTS_PATH environment variable for specifying custom spec results location
8
+
1
9
  === Version 0.2.14 / 2011-01-25
2
10
 
3
11
  * use newer RAutomation
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2010 Jarmo Pertman
3
+ Copyright (c) 2010-2011 Jarmo Pertman
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person
6
6
  obtaining a copy of this software and associated documentation
@@ -21,4 +21,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
21
  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
22
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
23
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
- OTHER DEALINGS IN THE SOFTWARE
24
+ OTHER DEALINGS IN THE SOFTWARE
@@ -7,7 +7,7 @@
7
7
 
8
8
  WatirSplash makes browser-based web page testing in Ruby splashin' easy.
9
9
  It combines Watir (http://www.watir.com) for controlling the browser and
10
- RSpec (http://rspec.info) for testing framework. This powerful combination gives you
10
+ RSpec (http://relishapp.com/rspec) for testing framework. This powerful combination gives you
11
11
  the ability to write easily well-maintained and easy-to-read specs (specifications in RSpec) so
12
12
  you don't need to have any extra documentation for your applications.
13
13
 
@@ -19,7 +19,7 @@ testing right away!
19
19
 
20
20
  === With vanilla Watir and RSpec
21
21
  require 'watir'
22
- require 'spec'
22
+ require 'rspec'
23
23
 
24
24
  describe "Google" do
25
25
  before :all do
@@ -68,7 +68,7 @@ testing right away!
68
68
  end
69
69
  end
70
70
 
71
- C:\project\ui-test>spec spec\google_spec.rb
71
+ C:\project\ui-test>rspec spec\google_spec.rb
72
72
  Results will be saved into the directory C:/project/ui-test/results
73
73
  Google
74
74
  has search field
@@ -87,7 +87,7 @@ testing right away!
87
87
  gem install watirsplash
88
88
 
89
89
  3) in your project's directory:
90
- watirsplash generate
90
+ watirsplash new
91
91
 
92
92
  == WHAT NEXT?
93
93
 
@@ -95,4 +95,4 @@ You can read more information about the usage and features from the wiki at http
95
95
 
96
96
  == COPYRIGHT
97
97
 
98
- Copyright © 2010 Jarmo Pertman. See LICENSE for details.
98
+ Copyright © 2010-2011 Jarmo Pertman. See LICENSE for details.
data/Rakefile CHANGED
@@ -14,26 +14,30 @@ begin
14
14
  gem.executables = ["watirsplash"]
15
15
  gem.extra_rdoc_files = ["README.rdoc", "History.rdoc", "License.txt"]
16
16
  gem.rdoc_options << "--main" << "README.rdoc" <<
17
- "--template" << "hanna" <<
18
- "--inline-source" << "--format=html"
17
+ "--template" << "hanna" <<
18
+ "--inline-source" << "--format=html"
19
19
  ignored_files = File.readlines(".gitignore").map {|l| l.strip.gsub("*", "")}
20
20
  ignored_files << ".gitignore" << ".gemspec"
21
21
  gem.files = Dir.glob("**/*").delete_if {|f| f =~ Regexp.union(*ignored_files)}
22
+ gem.files << "lib/watirsplash/generators/templates/new_project/.rspec"
22
23
  gem.post_install_message = %Q{#{"*"*25}
23
24
 
24
- Thank you for installing WatirSplash #{version}! Don't forget to take a look at README and History files!
25
+ Thank you for installing WatirSplash #{version}! Don't forget to take a look at the README and History files!
25
26
 
26
- Execute "watirsplash generate" under your project's directory to generate default project structure.
27
+ Execute `watirsplash new` under your project's directory to generate default project structure.
28
+
29
+ PS! If you are using older WatirSplash version <= 0.2.14, then execute `watirsplash migrate` under ui-test and ui-test-common!
27
30
 
28
31
  #{"*"*25}}
29
32
 
30
- gem.add_dependency("watir", "=1.6.6")
31
- gem.add_dependency("rspec", "=1.3.0")
32
- gem.add_dependency("diff-lcs")
33
+ gem.add_dependency("watir", "=1.7.1")
34
+ gem.add_dependency("rspec", "~>2.4")
35
+ gem.add_dependency("require_all")
36
+ gem.add_dependency("syntax")
37
+ gem.add_dependency("thor", "~>0")
33
38
  gem.add_dependency("rautomation", "~>0.4")
34
39
  gem.add_dependency("require_all")
35
40
  gem.add_dependency("syntax")
36
- gem.add_dependency("win32console")
37
41
  gem.add_dependency("win32screenshot", "~>1.0.2")
38
42
  end
39
43
  Jeweler::GemcutterTasks.new
@@ -41,16 +45,11 @@ rescue LoadError
41
45
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
42
46
  end
43
47
 
44
- require 'spec/rake/spectask'
45
- Spec::Rake::SpecTask.new(:spec) do |spec|
46
- spec.libs << 'lib' << 'spec'
47
- spec.spec_files = FileList['spec/**/*_spec.rb']
48
- end
48
+ require 'rspec/core/rake_task'
49
+ RSpec::Core::RakeTask.new(:spec)
49
50
 
50
- Spec::Rake::SpecTask.new(:rcov) do |spec|
51
- spec.libs << 'lib' << 'spec'
52
- spec.pattern = 'spec/**/*_spec.rb'
53
- spec.rcov = true
51
+ RSpec::Core::RakeTask.new(:rcov) do |t|
52
+ t.rcov = true
54
53
  end
55
54
 
56
55
  task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.14
1
+ 1.0.0
@@ -1,10 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- watirsplash_dir = File.expand_path(File.join(File.dirname(__FILE__), '../lib'))
3
- $LOAD_PATH.unshift(watirsplash_dir) unless $LOAD_PATH.include?(watirsplash_dir)
4
- require 'watirsplash/generator'
5
-
6
- if ARGV.size == 1 && ::WatirSplash::Generator.respond_to?(ARGV[0])
7
- exit ::WatirSplash::Generator.send(ARGV[0])
8
- else
9
- exit ::WatirSplash::Generator.help
10
- end
2
+ require "watirsplash/cli"
3
+ WatirSplash::CLI.start
@@ -1,17 +1,15 @@
1
1
  require "rubygems"
2
2
  require "require_all"
3
3
  require "rautomation"
4
- gem "rspec", "=1.3.0"
5
- require "spec"
6
- gem "watir", "=1.6.6"
4
+ require "rspec"
7
5
  require "watir"
8
6
  require "pathname"
9
- require_rel "watirsplash/wait_helper"
10
- require_rel "watirsplash/element_extensions"
11
7
  require_rel "watirsplash/file_helper"
12
8
  require_rel "watirsplash/spec_helper"
13
- require_rel "watirsplash/spec"
14
- require_rel "watirsplash/watir"
9
+ require_rel "watirsplash/rspec_patches"
10
+ require_rel "watirsplash/watir_patches"
15
11
  require_rel "watirsplash/util"
12
+ require_rel "watirsplash/html_formatter"
13
+ WatirSplash::Util.configure_rspec_formatters
16
14
  WatirSplash::Util.load_environment
17
15
 
@@ -0,0 +1,34 @@
1
+ require "thor"
2
+ require "thor/group"
3
+ require "watirsplash/generators/new_project"
4
+ require "watirsplash/generators/new_common_project"
5
+ require "watirsplash/generators/migrate_project"
6
+
7
+ module WatirSplash
8
+ class CLI < Thor
9
+
10
+ desc "new [APPLICATION_NAME]", "Creates a new WatirSplash project."
11
+ method_option :load_common, :type => :boolean, :default => false, :aliases => "-l",
12
+ :desc => "Load WatirSplash common project automatically."
13
+ method_option :url, :default => "about:blank", :aliases => "-u",
14
+ :desc => "URL to open in the browser before each test. May be relative if WatirSplash common project is loaded."
15
+ def new(name = "Application")
16
+ WatirSplash::Generators::NewProject.start([Thor::Util.camel_case(name), options[:url], options.load_common?])
17
+ end
18
+
19
+ desc "new_common", "Create a new WatirSplash common project."
20
+ method_option :url, :default => "http://localhost",
21
+ :desc => "url for the application main page"
22
+ def new_common
23
+ WatirSplash::Generators::NewCommonProject.start([options[:url]])
24
+ end
25
+
26
+ if File.basename(Dir.pwd) =~ /^ui-test(-common)?$/
27
+ desc "migrate", "Migrates old WatirSplash generated project to new."
28
+ def migrate
29
+ WatirSplash::Generators::MigrateProject.start
30
+ end
31
+ end
32
+
33
+ end
34
+ end
@@ -5,7 +5,7 @@ class File
5
5
  # all file names generated with this method will
6
6
  # be shown on the report upon test failure.
7
7
  def path(file_name, description=nil)
8
- WatirSplash::SpecHelper.formatter.file_path(file_name, description)
8
+ WatirSplash::Util.formatter.file_path(file_name, description)
9
9
  end
10
10
 
11
11
  # returns native file path
@@ -0,0 +1,25 @@
1
+ require "pathname"
2
+
3
+ module WatirSplash
4
+ module Generators
5
+ class MigrateProject < Thor::Group
6
+ include Thor::Actions
7
+
8
+ argument :dir
9
+
10
+ def self.source_root
11
+ File.dirname(__FILE__) + "/templates"
12
+ end
13
+
14
+ def migrate
15
+ gsub_file("config.rb", /^(\s*)Spec::Runner\./, "\\1RSpec.")
16
+
17
+ if File.basename(Dir.pwd) == "ui-test"
18
+ remove_file "spec/spec.opts"
19
+ template "new_project/.rspec", ".rspec"
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ module WatirSplash
2
+ module Generators
3
+ class NewCommonProject < Thor::Group
4
+ include Thor::Actions
5
+
6
+ argument :url
7
+
8
+ def self.source_root
9
+ File.dirname(__FILE__) + "/templates"
10
+ end
11
+
12
+ def generate
13
+ directory("new_common_project", "ui-test-common")
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,45 @@
1
+ require "uri"
2
+
3
+ module WatirSplash
4
+ module Generators
5
+ class NewProject < Thor::Group
6
+ include Thor::Actions
7
+
8
+ argument :name
9
+ argument :url
10
+ argument :load_common, :optional => true
11
+
12
+ def self.source_root
13
+ File.dirname(__FILE__) + "/templates"
14
+ end
15
+
16
+ def generate
17
+ directory("new_project", "ui-test")
18
+ end
19
+
20
+ def load_common_cmd
21
+ cmd = "WatirSplash::Util.load_common"
22
+ cmd = "# Uncomment the following line to load functionality from ui-test-common\n# " + cmd unless load_common
23
+ cmd
24
+ end
25
+
26
+ def formatted_name
27
+ Thor::Util.snake_case(name)
28
+ end
29
+
30
+ def formatted_url
31
+ uri = URI.parse(url)
32
+ if load_common && !default_url? && uri.relative?
33
+ %Q[Config.full_url("#{uri}")]
34
+ else
35
+ %Q["#{uri}"]
36
+ end
37
+ end
38
+
39
+ def default_url?
40
+ url.to_s == "about:blank"
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -3,8 +3,8 @@
3
3
  For example, you can use the URL constant below from your projects' config.rb like this:
4
4
 
5
5
  module Config
6
- module Application
7
- URL = Config.full_url("my_subpage/index.html") # => equals "http://localhost/my_subpage/index.html
6
+ module YourApplication
7
+ URL = Config.full_url("my_subpage/index.html") # => "http://localhost/my_subpage/index.html
8
8
  end
9
9
  end
10
10
  =end
@@ -13,7 +13,7 @@ require "uri"
13
13
 
14
14
  module Config
15
15
  module GlobalApplication
16
- URL = "http://localhost"
16
+ URL = <%= %Q["#{url}"] %>
17
17
  end
18
18
 
19
19
  def Config.full_url relative_url
@@ -21,6 +21,6 @@ module Config
21
21
  end
22
22
  end
23
23
 
24
- Spec::Runner.configure do |config|
24
+ RSpec.configure do |config|
25
25
  config.include(CommonApplicationHelper)
26
26
  end
@@ -2,10 +2,10 @@
2
2
  You have to load this file from your projects' environment.rb, which
3
3
  would like to use common functionality.
4
4
 
5
- Use the following code to do it automatically:
6
- WatirSplash::Util.load_common
5
+ Use the following line to do it automatically:
6
+ WatirSplash::Util.load_common
7
7
 
8
- Add all your require statements into this file to avoid unnecessary
8
+ Add all your global require statements into this file to avoid unnecessary
9
9
  code in your other projects' files
10
10
 
11
11
  By default everything in lib directory will be loaded
@@ -1,5 +1,5 @@
1
- # You can create under this directory common libraries/helpers/methods which you would
2
- # like to use within your specs in different projects
1
+ # You can create common libraries/helpers/methods under this directory
2
+ # to use within your specs within different projects
3
3
 
4
4
  module CommonApplicationHelper
5
5
 
@@ -0,0 +1,2 @@
1
+ --require
2
+ watirsplash
@@ -0,0 +1,22 @@
1
+ # Config for your application
2
+ module Config
3
+ module <%= name %>
4
+ # URL, which will be opened before every test
5
+ #
6
+ # Replace it with the URL of your application under test
7
+ # or if ui-test-common is used then
8
+ # URL = Config.full_url("/relative/url/index.html")
9
+ URL = <%= formatted_url %>
10
+ end
11
+ end
12
+
13
+ # A global configuration for specs in this project, which will include by default
14
+ # an <%= name %>Helper module and open Config::<%= name %>::URL with
15
+ # the browser.
16
+ #
17
+ # You can read more about RSpec-s before and after syntax from:
18
+ # http://relishapp.com/rspec/rspec-core/dir/hooks/before-and-after-hooks
19
+ RSpec.configure do |config|
20
+ config.include(<%= name %>Helper)
21
+ config.before(:all) {goto Config::<%= name %>::URL}
22
+ end
@@ -1,14 +1,13 @@
1
1
  # Add all your require statements into this file to avoid unnecessary
2
2
  # code in your spec files
3
3
 
4
- # Uncomment following line to load functionality from ui-test-common
5
- # WatirSplash::Util.load_common
4
+ <%= load_common_cmd %>
6
5
 
7
6
  # By default everything, which is not a spec file, will be loaded from spec directory
8
7
  # and it's subdirectories
9
8
  spec_dir = File.join(File.dirname(__FILE__), "spec/**/*.rb")
10
9
  filtered_ruby_files = Dir.glob(spec_dir).delete_if do |file|
11
- File.basename(file) =~ /.*_spec\.rb$/
10
+ File.basename(file) =~ /.*_spec\.rb$/i
12
11
  end
13
- require_all filtered_ruby_files unless filtered_ruby_files.empty?
14
- require_rel "config.rb"
12
+ require_all filtered_ruby_files
13
+ require_rel "config.rb"
@@ -1,7 +1,7 @@
1
- # ApplicationHelper module has helper methods for easy use in specs
1
+ # <%= name %>Helper module has helper methods for easy use in specs
2
2
  # see usages in spec/dummy_spec.rb
3
3
 
4
- module ApplicationHelper
4
+ module <%= name %>Helper
5
5
 
6
6
  def helper_method_one
7
7
  "one"
@@ -15,4 +15,4 @@ module ApplicationHelper
15
15
  false
16
16
  end
17
17
 
18
- end
18
+ end
@@ -0,0 +1,40 @@
1
+ # This is a fully working spec file which you can run to see if
2
+ # your configuration is correct and everything is working as expected
3
+
4
+ describe WatirSplash do
5
+
6
+ it "has the browser window opened" do
7
+ url.should == Config::<%= name %>::URL
8
+ end
9
+
10
+ it "has easy access to <%= name %>Helper methods" do
11
+ # <%= name %>Helper#helper_method_one will be executed
12
+ helper_method_one.should == "one"
13
+ # <%= name %>Helper#has_second_method? will be executed
14
+ should have_second_method
15
+ # <%= name %>Helper#correct? method will be executed
16
+ should_not be_correct
17
+ end
18
+
19
+ it "fails the example and makes a screenshot of the browser" do
20
+ false.should be_true
21
+ end
22
+
23
+ it "is in pending status" do
24
+ goto "http://google.com/ncr"
25
+ title.should == "Google"
26
+ text_field(:name => "q").set "Bing"
27
+ wait_until(15) {text.include? "Bing"}
28
+ pending "this is a known 'bug'" do
29
+ title.should == "Bing"
30
+ end
31
+ end
32
+
33
+ it "has access to global methods after \"new_common\" command has been used" do
34
+ pending "it fails as long as 'watirsplash new_common' command hasn't been executed
35
+ and ui-test-common is not loaded by this project" do
36
+ new_global_method.should == "it just works"
37
+ end
38
+ end
39
+
40
+ end