rwebspec 1.4.0.1 → 1.4.0.2

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.
@@ -1,94 +1,104 @@
1
- #***********************************************************
2
- #* Copyright (c) 2006, Zhimin Zhan.
3
- #* Distributed open-source, see full license in MIT-LICENSE
4
- #***********************************************************
5
- require File.join(File.dirname(__FILE__), 'assert')
6
- require File.join(File.dirname(__FILE__), 'driver')
7
- require 'fileutils'
8
-
9
- module RWebSpec
10
-
11
- # WebPage (children of AbstractWebPage) encapsulates a real web page.
12
- # For example,
13
- # beginAt("/home")
14
- # @web_browser.clickLinkWithText("/login")
15
- # @web_browser.setFormElement("username", "sa")
16
- # Can be rewritten to
17
- # begin_at("/home")
18
- # home_page = HomePage.new
19
- # login_page = home_page.clickLoginLink
20
- # login_page.enterUserName("sa")
21
- #
22
- # So you only need change in LoingPage class if UI changes, which happen quite often.
23
- class AbstractWebPage
24
-
25
- include RWebSpec::Assert
26
- include RWebSpec::Driver
27
-
28
- # browser: passed to do assertion within the page
29
- # page_text: text used to identify the page, title will be the first candidate
30
- attr_accessor :page_text
31
-
32
- def initialize(the_browser, page_text = nil)
33
- @web_browser = the_browser
34
- @web_tester = the_browser
35
- @page_text = page_text
36
- begin
37
- snapshot if $ITEST2_DUMP_PAGE
38
- delay = $ITEST2_PAGE_DELAY
39
- sleep(delay)
40
- rescue => e
41
- end
42
- assert_on_page
43
- end
44
-
45
- def browser
46
- @web_browser
47
- end
48
-
49
- def assert_on_page()
50
- assert_text_present(@page_text) if @page_text
51
- end
52
-
53
- def assert_not_on_page()
54
- assert_text_not_present(@page_text) if @page_text
55
- end
56
-
57
- def dump(stream = nil)
58
- @web_browser.dump_response(stream)
59
- end
60
-
61
-
62
- def source
63
- @web_browser.page_source
64
- end
65
- alias html source
66
-
67
- # return current page title
68
- def title
69
- @web_browser.page_title
70
- end
71
-
72
- # return current page text
73
- def text
74
- @web_browser.text
75
- end
76
-
77
- # TO validate
78
- def contains?(ary)
79
- return true if ary.nil?
80
- the_page_source = source
81
- found = false
82
- ary.each_line do |str|
83
- found ||= the_page_source.include?(str)
84
- end
85
- return found
86
- end
87
-
88
- def snapshot(replace_css = false)
89
- save_current_page(:filename => Time.now.strftime("%m%d%H%M%S") + "_" + self.class.name.gsub(" ", "") + ".html" )
90
- end
91
-
92
- end
93
-
94
- end
1
+ #***********************************************************
2
+ #* Copyright (c) 2006, Zhimin Zhan.
3
+ #* Distributed open-source, see full license in MIT-LICENSE
4
+ #***********************************************************
5
+ require File.join(File.dirname(__FILE__), 'assert')
6
+ require File.join(File.dirname(__FILE__), 'driver')
7
+ require 'fileutils'
8
+
9
+ module RWebSpec
10
+
11
+ # WebPage (children of AbstractWebPage) encapsulates a real web page.
12
+ # For example,
13
+ # beginAt("/home")
14
+ # @web_browser.clickLinkWithText("/login")
15
+ # @web_browser.setFormElement("username", "sa")
16
+ # Can be rewritten to
17
+ # begin_at("/home")
18
+ # home_page = HomePage.new
19
+ # login_page = home_page.clickLoginLink
20
+ # login_page.enterUserName("sa")
21
+ #
22
+ # So you only need change in LoingPage class if UI changes, which happen quite often.
23
+ class AbstractWebPage
24
+
25
+ include RWebSpec::Assert
26
+ include RWebSpec::Driver
27
+
28
+ # browser: passed to do assertion within the page
29
+ # page_text: text used to identify the page, title will be the first candidate
30
+ attr_accessor :page_text
31
+
32
+ def initialize(the_browser, page_text = nil)
33
+ @web_browser = the_browser
34
+ @web_tester = the_browser
35
+ @page_text = page_text
36
+ begin
37
+ snapshot if $ITEST2_DUMP_PAGE
38
+ delay = $ITEST2_PAGE_DELAY
39
+ sleep(delay)
40
+ rescue => e
41
+ end
42
+ assert_on_page
43
+ end
44
+
45
+ # return the browser instance in page objects
46
+ def browser
47
+ @web_browser
48
+ end
49
+
50
+ # Assert is on current page
51
+ # Example
52
+ # home_page = HomePage.new("Welcome to iTest2")
53
+ # ....
54
+ # home_page.assert_on_page # will check the text 'Welcome to iTest2' still present on the page
55
+ def assert_on_page()
56
+ assert_text_present(@page_text) if @page_text
57
+ end
58
+
59
+ def assert_not_on_page()
60
+ assert_text_not_present(@page_text) if @page_text
61
+ end
62
+
63
+ def dump(stream = nil)
64
+ @web_browser.dump_response(stream)
65
+ end
66
+
67
+ # Page source (html)
68
+ def source
69
+ @web_browser.page_source
70
+ end
71
+ alias html source
72
+
73
+ # return current page title
74
+ def title
75
+ @web_browser.page_title
76
+ end
77
+
78
+ # return current page text
79
+ def text
80
+ @web_browser.text
81
+ end
82
+
83
+ # TO validate
84
+ def contains?(ary)
85
+ return true if ary.nil?
86
+ the_page_source = source
87
+ found = false
88
+ ary.each_line do |str|
89
+ found ||= the_page_source.include?(str)
90
+ end
91
+ return found
92
+ end
93
+
94
+ # Will save current page source to a file
95
+ # home_page = HomePage.new("Welcome to iTest2")
96
+ # ...
97
+ # home_page.snapshot() # => save to 20090830100102_HomePage.html
98
+ def snapshot(replace_css = false)
99
+ save_current_page(:filename => Time.now.strftime("%m%d%H%M%S") + "_" + self.class.name.gsub(" ", "") + ".html" )
100
+ end
101
+
102
+ end
103
+
104
+ end
@@ -1,36 +1,38 @@
1
- #***********************************************************
2
- #* Copyright (c) 2006, Zhimin Zhan.
3
- #* Distributed open-source, see full license in MIT-LICENSE
4
- #***********************************************************
5
-
6
- require 'test/unit'
7
- require File.join(File.dirname(__FILE__), 'assert')
8
- require File.join(File.dirname(__FILE__), 'driver')
9
-
10
- module RWebSpec
11
-
12
- class WebTestCase < Test::Unit::TestCase
13
- include RWebSpec::Driver
14
- include RWebSpec::Assert
15
- include RWebSpec::Utils
16
-
17
- attr_reader :web_tester
18
-
19
- def initialize(name=nil)
20
- super(name) if name
21
- @web_browser = WebBrowser.new
22
- end
23
-
24
- def default_test
25
- super unless (self.class == WebTestCase)
26
- end
27
-
28
- def open_browser(baseUrl, relativeUrl)
29
- context.base_url = baseUrl
30
- begin_at(relativeUrl)
31
- end
32
- alias open_ie open_browser
33
-
34
- end
35
-
36
- end
1
+ #***********************************************************
2
+ #* Copyright (c) 2006, Zhimin Zhan.
3
+ #* Distributed open-source, see full license in MIT-LICENSE
4
+ #***********************************************************
5
+
6
+ # Deprecated, use RSpec syntax instead
7
+
8
+ require 'test/unit'
9
+ require File.join(File.dirname(__FILE__), 'assert')
10
+ require File.join(File.dirname(__FILE__), 'driver')
11
+
12
+ module RWebSpec
13
+
14
+ class WebTestCase < Test::Unit::TestCase
15
+ include RWebSpec::Driver
16
+ include RWebSpec::Assert
17
+ include RWebSpec::Utils
18
+
19
+ attr_reader :web_tester
20
+
21
+ def initialize(name=nil)
22
+ super(name) if name
23
+ @web_browser = WebBrowser.new
24
+ end
25
+
26
+ def default_test
27
+ super unless (self.class == WebTestCase)
28
+ end
29
+
30
+ def open_browser(baseUrl, relativeUrl)
31
+ context.base_url = baseUrl
32
+ begin_at(relativeUrl)
33
+ end
34
+ alias open_ie open_browser
35
+
36
+ end
37
+
38
+ end
data/lib/rwebspec.rb CHANGED
@@ -1,31 +1,31 @@
1
- #***********************************************************
2
- #* Copyright (c) 2006 - 2009, Zhimin Zhan.
3
- #* Distributed open-source, see full license in MIT-LICENSE
4
- #***********************************************************
5
-
6
- # Load active_support, so that we can use 1.days.ago
7
- begin
8
- require 'active_support/basic_object'
9
- require 'active_support/duration'
10
- rescue LoadError => no_as1_err
11
- # active_support 2.0 loaded error
12
- end
13
- require 'active_support/core_ext'
14
- require 'spec'
15
-
16
- RWEBSPEC_VERSION = RWEBUNIT_VERSION = "1.4.0.1"
17
-
18
- # Extra full path to load libraries
19
- require File.dirname(__FILE__) + "/rwebspec/using_pages"
20
- require File.dirname(__FILE__) + "/rwebspec/test_utils"
21
- require File.dirname(__FILE__) + "/rwebspec/web_page"
22
- require File.dirname(__FILE__) + "/rwebspec/assert"
23
- require File.dirname(__FILE__) + "/rwebspec/itest_plugin"
24
- require File.dirname(__FILE__) + "/rwebspec/web_browser"
25
- require File.dirname(__FILE__) + "/rwebspec/driver"
26
- require File.dirname(__FILE__) + "/rwebspec/test_script"
27
- require File.dirname(__FILE__) + "/rwebspec/context"
28
- require File.dirname(__FILE__) + "/rwebspec/rspec_helper"
29
- require File.dirname(__FILE__) + "/rspec_extensions"
30
- require File.dirname(__FILE__) + "/watir_extensions"
31
- require File.dirname(__FILE__) + "/rwebspec/matchers/contains_text"
1
+ #***********************************************************
2
+ #* Copyright (c) 2006 - 2009, Zhimin Zhan.
3
+ #* Distributed open-source, see full license in MIT-LICENSE
4
+ #***********************************************************
5
+
6
+ # Load active_support, so that we can use 1.days.ago
7
+ begin
8
+ require 'active_support/basic_object'
9
+ require 'active_support/duration'
10
+ rescue LoadError => no_as1_err
11
+ # active_support 2.0 loaded error
12
+ end
13
+ require 'active_support/core_ext'
14
+ require 'spec'
15
+
16
+ RWEBSPEC_VERSION = RWEBUNIT_VERSION = "1.4.0.2"
17
+
18
+ # Extra full path to load libraries
19
+ require File.dirname(__FILE__) + "/rwebspec/using_pages"
20
+ require File.dirname(__FILE__) + "/rwebspec/test_utils"
21
+ require File.dirname(__FILE__) + "/rwebspec/web_page"
22
+ require File.dirname(__FILE__) + "/rwebspec/assert"
23
+ require File.dirname(__FILE__) + "/rwebspec/itest_plugin"
24
+ require File.dirname(__FILE__) + "/rwebspec/web_browser"
25
+ require File.dirname(__FILE__) + "/rwebspec/driver"
26
+ require File.dirname(__FILE__) + "/rwebspec/test_script"
27
+ require File.dirname(__FILE__) + "/rwebspec/context"
28
+ require File.dirname(__FILE__) + "/rwebspec/rspec_helper"
29
+ require File.dirname(__FILE__) + "/rspec_extensions"
30
+ require File.dirname(__FILE__) + "/watir_extensions"
31
+ require File.dirname(__FILE__) + "/rwebspec/matchers/contains_text"
data/lib/rwebunit.rb CHANGED
@@ -1,3 +1,3 @@
1
- # legacy code to support old 'require rwebunit'
2
- require File.dirname(__FILE__) + "/rwebspec"
3
- RWebUnit = RWebSpec
1
+ # legacy code to support old 'require rwebunit'
2
+ require File.dirname(__FILE__) + "/rwebspec"
3
+ RWebUnit = RWebSpec
@@ -1,69 +1,69 @@
1
- if RUBY_PLATFORM == "java" then
2
- # no need to load firefox extension
3
- else
4
- module FireWatir
5
- class Firefox
6
-
7
- @@firefox_started = false
8
-
9
- def initialize(options = {})
10
- if(options.kind_of?(Integer))
11
- options = {:waitTime => options}
12
- end
13
-
14
- if(options[:profile])
15
- profile_opt = "-no-remote -P #{options[:profile]}"
16
- else
17
- profile_opt = ""
18
- end
19
-
20
- waitTime = options[:waitTime] || 2
21
-
22
- case RUBY_PLATFORM
23
- when /mswin/
24
- # Get the path to Firefox.exe using Registry.
25
- require 'win32/registry.rb'
26
- path_to_bin = ""
27
- Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Mozilla\Mozilla Firefox') do |reg|
28
- keys = reg.keys
29
- reg1 = Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\Mozilla\\Mozilla Firefox\\#{keys[0]}\\Main")
30
- reg1.each do |subkey, type, data|
31
- if(subkey =~ /pathtoexe/i)
32
- path_to_bin = data
33
- end
34
- end
35
- end
36
-
37
- when /linux/i
38
- path_to_bin = `which firefox`.strip
39
- when /darwin/i
40
- path_to_bin = '/Applications/Firefox.app/Contents/MacOS/firefox'
41
- when /java/
42
- raise "Not implemented: Create a browser finder in JRuby"
43
- end
44
-
45
- @t = Thread.new { system("#{path_to_bin} -jssh #{profile_opt}")} unless @@firefox_started
46
-
47
- sleep waitTime
48
- begin
49
- set_defaults()
50
- rescue Watir::Exception::UnableToStartJSShException
51
- if !@t # no new thread starting browser, try again
52
- puts "Firefox with JSSH not detected after you indicated @@firefox_started"
53
- @t = Thread.new { system("#{path_to_bin} -jssh #{profile_opt}")}
54
- sleep waitTime
55
- set_defaults
56
- end
57
- end
58
- get_window_number()
59
- set_browser_document()
60
- end
61
-
62
- def self.firefox_started=(value)
63
- @@firefox_started = value
64
- end
65
-
66
- end
67
- end
68
-
69
- end
1
+ if RUBY_PLATFORM == "java" then
2
+ # no need to load firefox extension
3
+ else
4
+ module FireWatir
5
+ class Firefox
6
+
7
+ @@firefox_started = false
8
+
9
+ def initialize(options = {})
10
+ if(options.kind_of?(Integer))
11
+ options = {:waitTime => options}
12
+ end
13
+
14
+ if(options[:profile])
15
+ profile_opt = "-no-remote -P #{options[:profile]}"
16
+ else
17
+ profile_opt = ""
18
+ end
19
+
20
+ waitTime = options[:waitTime] || 2
21
+
22
+ case RUBY_PLATFORM
23
+ when /mswin/
24
+ # Get the path to Firefox.exe using Registry.
25
+ require 'win32/registry.rb'
26
+ path_to_bin = ""
27
+ Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Mozilla\Mozilla Firefox') do |reg|
28
+ keys = reg.keys
29
+ reg1 = Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\Mozilla\\Mozilla Firefox\\#{keys[0]}\\Main")
30
+ reg1.each do |subkey, type, data|
31
+ if(subkey =~ /pathtoexe/i)
32
+ path_to_bin = data
33
+ end
34
+ end
35
+ end
36
+
37
+ when /linux/i
38
+ path_to_bin = `which firefox`.strip
39
+ when /darwin/i
40
+ path_to_bin = '/Applications/Firefox.app/Contents/MacOS/firefox'
41
+ when /java/
42
+ raise "Not implemented: Create a browser finder in JRuby"
43
+ end
44
+
45
+ @t = Thread.new { system("#{path_to_bin} -jssh #{profile_opt}")} unless @@firefox_started
46
+
47
+ sleep waitTime
48
+ begin
49
+ set_defaults()
50
+ rescue Watir::Exception::UnableToStartJSShException
51
+ if !@t # no new thread starting browser, try again
52
+ puts "Firefox with JSSH not detected after you indicated @@firefox_started"
53
+ @t = Thread.new { system("#{path_to_bin} -jssh #{profile_opt}")}
54
+ sleep waitTime
55
+ set_defaults
56
+ end
57
+ end
58
+ get_window_number()
59
+ set_browser_document()
60
+ end
61
+
62
+ def self.firefox_started=(value)
63
+ @@firefox_started = value
64
+ end
65
+
66
+ end
67
+ end
68
+
69
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rwebspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0.1
4
+ version: 1.4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zhimin Zhan
@@ -9,7 +9,7 @@ autorequire: rwebspec
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-19 00:00:00 +10:00
12
+ date: 2009-09-01 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 1.1.12
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: firewatir
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.6.2
34
+ version:
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: commonwatir
27
37
  type: :runtime
@@ -56,11 +66,13 @@ files:
56
66
  - CHANGELOG
57
67
  - MIT-LICENSE
58
68
  - lib/rspec_extensions.rb
69
+ - lib/rwebspec
59
70
  - lib/rwebspec/assert.rb
60
71
  - lib/rwebspec/clickJSDialog.rb
61
72
  - lib/rwebspec/context.rb
62
73
  - lib/rwebspec/driver.rb
63
74
  - lib/rwebspec/itest_plugin.rb
75
+ - lib/rwebspec/matchers
64
76
  - lib/rwebspec/matchers/contains_text.rb
65
77
  - lib/rwebspec/popup.rb
66
78
  - lib/rwebspec/rspec_helper.rb
@@ -75,8 +87,6 @@ files:
75
87
  - lib/watir_extensions.rb
76
88
  has_rdoc: true
77
89
  homepage: http://github.com/zhimin/rwebspec/tree/master
78
- licenses: []
79
-
80
90
  post_install_message:
81
91
  rdoc_options: []
82
92
 
@@ -97,9 +107,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
107
  requirements:
98
108
  - none
99
109
  rubyforge_project: rwebspec
100
- rubygems_version: 1.3.4
110
+ rubygems_version: 1.3.1
101
111
  signing_key:
102
- specification_version: 3
112
+ specification_version: 2
103
113
  summary: Executable functional specification for web applications in RSpec syntax and Watir
104
114
  test_files: []
105
115