rwebspec 1.9.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,11 @@
1
1
  CHANGELOG
2
2
  =========
3
+
4
+ 2.0
5
+ [Update] Deprecate support for FireWatir, speed up loading
6
+ [Update] Drop constant naming RWebUnit
7
+ [Refactoring] internal folder structure like extensions and plugins
8
+
3
9
  1.9.3
4
10
  [Enhacement] take_screenshot with to_dir arguments
5
11
 
data/Rakefile CHANGED
@@ -45,6 +45,7 @@ Rake::RDocTask.new do |rdoc|
45
45
  rdoc.title = 'RWebSpec'
46
46
  rdoc.rdoc_files.include('lib/rwebspec.rb')
47
47
  rdoc.rdoc_files.include('lib/rwebspec/*.rb')
48
+ rdoc.rdoc_files.include('lib/extensions/*.rb')
48
49
  rdoc.rdoc_files.delete("lib/rwebspec/web_testcase.rb")
49
50
  rdoc.rdoc_files.delete("lib/rwebspec/checkJSDialog.rb")
50
51
  rdoc.options += [
@@ -70,8 +71,8 @@ end
70
71
  spec = Gem::Specification.new do |s|
71
72
  s.platform= Gem::Platform::RUBY
72
73
  s.name = "rwebspec"
73
- s.version = "1.9.3"
74
- s.summary = "Executable functional specification for web applications in RSpec syntax and Watir"
74
+ s.version = "2.0.0"
75
+ s.summary = "Web application functional specification in Ruby"
75
76
  s.description = "Executable functional specification for web applications in RSpec syntax and Watir"
76
77
 
77
78
  s.author = "Zhimin Zhan"
@@ -90,7 +91,6 @@ spec = Gem::Specification.new do |s|
90
91
  s.files = s.files + Dir.glob( "sample/**/*")
91
92
  s.files = s.files + Dir.glob( "docs/**/*" )
92
93
  s.add_dependency(%q<rspec>, ["= 1.1.12"])
93
-
94
94
  s.add_dependency("commonwatir", ">= 2.0")
95
95
  end
96
96
 
@@ -1,4 +1,3 @@
1
-
2
1
  module FireWatir
3
2
  class Firefox
4
3
 
@@ -0,0 +1,85 @@
1
+ gem 'watir'
2
+ require 'fileutils'
3
+ require 'watir/container'
4
+ require 'watir/element_collections'
5
+ require 'watir/element'
6
+
7
+ module Watir
8
+ # Base class for html elements.
9
+ # This is not a class that users would normally access.
10
+ class Element
11
+
12
+ def method_missing(method_name, *args, &block)
13
+
14
+ if ($TESTWISE_DIR || $TESTWISE_BROWSER) && method_name.to_s =~ /(.*)_no_wait/ && self.respond_to?($1)
15
+ ruby_code = testwise_generate_ruby_code(self, $1, *args)
16
+ testwise_click_no_wait(ruby_code)
17
+
18
+ elsif method_name.to_s =~ /(.*)_no_wait/ && self.respond_to?($1)
19
+ puts "[Watir] handle it"
20
+ assert_exists
21
+ assert_enabled
22
+ highlight(:set)
23
+ ruby_code = generate_ruby_code(self, $1, *args)
24
+ system(spawned_no_wait_command(ruby_code))
25
+ highlight(:clear)
26
+ else
27
+ super
28
+ end
29
+
30
+ end
31
+
32
+
33
+ def testwise_generate_ruby_code(element, method_name, *args)
34
+ element = "#{self.class}.new(#{@page_container.attach_command}, :unique_number, #{self.unique_number})"
35
+ method = build_method(method_name, *args)
36
+ watir_load_path = []
37
+ watir_lib_path = nil
38
+ $LOAD_PATH.each do |x|
39
+ if x =~ /rautomation/ || x =~ /watir/
40
+ watir_load_path << x
41
+ if x =~ /\/gems\/watir-/
42
+ watir_lib_path = x
43
+ end
44
+ end
45
+ end
46
+ watir_load_path = $LOAD_PATH
47
+ ruby_code = "$:.unshift(#{watir_load_path.map {|p| "'#{p}'" }.join(").unshift(")});" <<
48
+ "require '#{watir_lib_path}/watir/core';#{element}.#{method};"
49
+ return ruby_code
50
+ end
51
+
52
+ # customiiation here
53
+ #
54
+ def testwise_click_no_wait(ruby_code)
55
+ begin
56
+ puts "[TestWise] I am handling it"
57
+ assert_exists
58
+ assert_enabled
59
+ highlight(:set)
60
+ current_path = File.expand_path(".")
61
+
62
+ # not necessary
63
+ # ruby_code.gsub("C:/Program Files/TestWise/vendor/bundle/ruby/1.8", "C:/rubyshell/ruby/lib/ruby/gems/1.8")
64
+
65
+ # Trick 1: need to set RUBYOPT, otherwise might get -F error
66
+ ENV["RUBYOPT"] = "-rubygems"
67
+
68
+ # Trick 2: need to wrap no-wait click operation in a thread
69
+ Thread.new do
70
+ # this will pop up Windows Command window
71
+ # system("ruby", "-e", ruby_code)
72
+ system("rubyw", "-e", ruby_code)
73
+ end
74
+ highlight(:clear)
75
+ rescue RuntimeError => re
76
+ puts re.backtrace
77
+
78
+ rescue => e
79
+ puts "Failed to click_no_wait: #{e.backtrace}"
80
+ raise e
81
+ end
82
+ end
83
+
84
+ end
85
+ end
@@ -12,11 +12,6 @@ module RWebSpec
12
12
  # Support of iTest to ajust the intervals between keystroke/mouse operations
13
13
  def operation_delay
14
14
  begin
15
- if $ITEST2_OPERATION_DELAY && $ITEST2_OPERATION_DELAY > 0 &&
16
- $ITEST2_OPERATION_DELAY < 30000 then # max 30 seconds
17
- Thread.pass
18
- sleep($ITEST2_OPERATION_DELAY / 1000)
19
- end
20
15
 
21
16
  if $TESTWISE_OPERATION_DELAY && $TESTWISE_OPERATION_DELAY > 0 &&
22
17
  $TESTWISE_OPERATION_DELAY < 30000 then # max 30 seconds
@@ -6,7 +6,7 @@
6
6
  # You can just use
7
7
  # click_button("submit")
8
8
  #
9
- require File.join(File.dirname(__FILE__), 'testwise_plugin')
9
+ require File.join(File.dirname(__FILE__), '../plugins/testwise_plugin')
10
10
  require File.join(File.dirname(__FILE__), 'popup')
11
11
  require File.join(File.dirname(__FILE__), 'matchers', "contains_text.rb")
12
12
 
data/lib/rwebspec.rb CHANGED
@@ -1,30 +1,36 @@
1
1
  #***********************************************************
2
- #* Copyright (c) 2006 - 2010, Zhimin Zhan.
2
+ #* Copyright (c) 2006 - 2011, Zhimin Zhan.
3
3
  #* Distributed open-source, see full license in MIT-LICENSE
4
4
  #***********************************************************
5
- require "rubygems";
5
+ require "rubygems"
6
6
 
7
- # Try load firewatir first, which depends on ActiveSupport 2.3.9
8
- begin
9
- require "firewatir";
10
- $firewatir_loaded = true
11
- rescue LoadError => e
12
- puts e
13
- $firewatir_loaded = false
7
+ # From 2.0, no default support for FireWatir.
8
+ #
9
+ if $ENABLE_FIREFOX
10
+ # Try load firewatir first, which depends on ActiveSupport
11
+ puts "Deprecated: Please use watir-webdriver or selenium-webdriver to run tests in Firefox"
12
+ begin
13
+ require "firewatir";
14
+ $firewatir_loaded = true
15
+ rescue LoadError => e
16
+ puts e
17
+ $firewatir_loaded = false
18
+ end
14
19
  end
15
20
 
16
21
  # Load active_support, so that we can use 1.days.ago
17
22
  begin
18
23
  require 'active_support/basic_object'
19
24
  require 'active_support/duration'
25
+ require 'active_support/core_ext'
20
26
  rescue LoadError => no_as1_err
21
27
  # active_support 2.0 loaded error
22
28
  end
23
- require 'active_support/core_ext'
29
+
24
30
  require 'spec'
25
31
 
26
32
  unless defined? RWEBSPEC_VERSION
27
- RWEBSPEC_VERSION = RWEBUNIT_VERSION = "1.9.3"
33
+ RWEBSPEC_VERSION = RWEBUNIT_VERSION = "2.0.0"
28
34
  end
29
35
 
30
36
  if RUBY_PLATFORM =~ /mswin/ or RUBY_PLATFORM =~ /mingw/
@@ -47,12 +53,14 @@ require File.dirname(__FILE__) + "/rwebspec/test_script"
47
53
  require File.dirname(__FILE__) + "/rwebspec/context"
48
54
  require File.dirname(__FILE__) + "/rwebspec/rspec_helper"
49
55
  require File.dirname(__FILE__) + "/rwebspec/load_test_helper"
50
- require File.dirname(__FILE__) + "/rspec_extensions"
51
- require File.dirname(__FILE__) + "/watir_extensions"
52
- if RUBY_PLATFORM =~ /mswin/ or RUBY_PLATFORM =~ /mingw/
53
- require File.dirname(__FILE__) + "/window_script_extensions.rb"
54
- end
55
56
 
56
57
  require File.dirname(__FILE__) + "/rwebspec/matchers/contains_text"
57
- require File.dirname(__FILE__) + "/rwebspec/testwise_plugin"
58
+
59
+ require File.dirname(__FILE__) + "/extensions/rspec_extensions"
60
+ require File.dirname(__FILE__) + "/extensions/watir_extensions"
61
+ require File.dirname(__FILE__) + "/extensions/firewatir_extensions" if $ENABLE_FIREFOX
62
+ if RUBY_PLATFORM =~ /mswin/ or RUBY_PLATFORM =~ /mingw/
63
+ require File.dirname(__FILE__) + "/extensions/window_script_extensions.rb"
64
+ end
65
+ require File.dirname(__FILE__) + "/plugins/testwise_plugin.rb"
58
66
 
metadata CHANGED
@@ -3,10 +3,10 @@ name: rwebspec
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
- - 1
7
- - 9
8
- - 3
9
- version: 1.9.3
6
+ - 2
7
+ - 0
8
+ - 0
9
+ version: 2.0.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Zhimin Zhan
@@ -14,7 +14,7 @@ autorequire: rwebspec
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-10-02 00:00:00 +10:00
17
+ date: 2011-10-15 00:00:00 +10:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -57,7 +57,11 @@ files:
57
57
  - README
58
58
  - CHANGELOG
59
59
  - MIT-LICENSE
60
- - lib/rspec_extensions.rb
60
+ - lib/extensions/firewatir_extensions.rb
61
+ - lib/extensions/rspec_extensions.rb
62
+ - lib/extensions/watir_extensions.rb
63
+ - lib/extensions/window_script_extensions.rb
64
+ - lib/plugins/testwise_plugin.rb
61
65
  - lib/rwebspec/assert.rb
62
66
  - lib/rwebspec/clickJSDialog.rb
63
67
  - lib/rwebspec/context.rb
@@ -69,15 +73,11 @@ files:
69
73
  - lib/rwebspec/rspec_helper.rb
70
74
  - lib/rwebspec/test_script.rb
71
75
  - lib/rwebspec/test_utils.rb
72
- - lib/rwebspec/testwise_plugin.rb
73
76
  - lib/rwebspec/using_pages.rb
74
77
  - lib/rwebspec/web_browser.rb
75
78
  - lib/rwebspec/web_page.rb
76
79
  - lib/rwebspec/web_testcase.rb
77
80
  - lib/rwebspec.rb
78
- - lib/rwebunit.rb
79
- - lib/watir_extensions.rb
80
- - lib/window_script_extensions.rb
81
81
  has_rdoc: true
82
82
  homepage: http://github.com/zhimin/rwebspec/tree/master
83
83
  licenses: []
@@ -107,6 +107,6 @@ rubyforge_project: rwebspec
107
107
  rubygems_version: 1.3.6
108
108
  signing_key:
109
109
  specification_version: 3
110
- summary: Executable functional specification for web applications in RSpec syntax and Watir
110
+ summary: Web application functional specification in Ruby
111
111
  test_files: []
112
112
 
data/lib/rwebunit.rb DELETED
@@ -1,3 +0,0 @@
1
- # legacy code to support old 'require rwebunit'
2
- require File.dirname(__FILE__) + "/rwebspec"
3
- RWebUnit = RWebSpec