rwebspec 1.4.0 → 1.4.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.
@@ -1,94 +1,94 @@
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
+ 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,36 +1,36 @@
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
+ 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
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
- RWEBUNIT_VERSION = "1.4.0"
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.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"
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
4
+ version: 1.4.0.1
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-11 00:00:00 +10:00
12
+ date: 2009-08-19 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -56,13 +56,11 @@ files:
56
56
  - CHANGELOG
57
57
  - MIT-LICENSE
58
58
  - lib/rspec_extensions.rb
59
- - lib/rwebspec
60
59
  - lib/rwebspec/assert.rb
61
60
  - lib/rwebspec/clickJSDialog.rb
62
61
  - lib/rwebspec/context.rb
63
62
  - lib/rwebspec/driver.rb
64
63
  - lib/rwebspec/itest_plugin.rb
65
- - lib/rwebspec/matchers
66
64
  - lib/rwebspec/matchers/contains_text.rb
67
65
  - lib/rwebspec/popup.rb
68
66
  - lib/rwebspec/rspec_helper.rb
@@ -77,6 +75,8 @@ files:
77
75
  - lib/watir_extensions.rb
78
76
  has_rdoc: true
79
77
  homepage: http://github.com/zhimin/rwebspec/tree/master
78
+ licenses: []
79
+
80
80
  post_install_message:
81
81
  rdoc_options: []
82
82
 
@@ -97,9 +97,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  requirements:
98
98
  - none
99
99
  rubyforge_project: rwebspec
100
- rubygems_version: 1.3.1
100
+ rubygems_version: 1.3.4
101
101
  signing_key:
102
- specification_version: 2
102
+ specification_version: 3
103
103
  summary: Executable functional specification for web applications in RSpec syntax and Watir
104
104
  test_files: []
105
105