zhimin-rwebspec 1.4.0.2 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,68 +1,79 @@
1
- require 'socket'
2
-
3
- module RWebSpec
4
- module ITestPlugin
5
-
6
- def connect_to_itest(message_type, body)
7
- begin
8
- the_message = message_type + "|" + body
9
- if @last_message == the_message then # ignore the message same as preivous one
10
- return
11
- end
12
- itest_port = $ITEST2_TRACE_PORT || 7025
13
- itest_socket = Socket.new(Socket::AF_INET,Socket::SOCK_STREAM,0)
14
- itest_socket.connect(Socket.pack_sockaddr_in(itest_port, '127.0.0.1'))
15
- itest_socket.puts(the_message)
16
- @last_message = the_message
17
- itest_socket.close
18
- rescue => e
19
- end
20
- end
21
- alias connect_to_itest2 connect_to_itest
22
-
23
- def debug(message)
24
- connect_to_itest(" DEBUG", message + "\r\n") if $RUN_IN_ITEST
25
- end
26
-
27
-
28
- # Support of iTest to ajust the intervals between keystroke/mouse operations
29
- def operation_delay
30
- begin
31
- if $ITEST2_OPERATION_DELAY && $ITEST2_OPERATION_DELAY > 0 &&
32
- $ITEST2_OPERATION_DELAY && $ITEST2_OPERATION_DELAY < 30000 then # max 30 seconds
33
- sleep($ITEST2_OPERATION_DELAY / 1000)
34
- end
35
-
36
- while $ITEST2_PAUSE
37
- debug("Paused, waiting ...")
38
- sleep 1
39
- end
40
- rescue => e
41
- puts "Error on delaying: #{e}"
42
- # ignore
43
- end
44
- end
45
-
46
- # find out the line (and file) the execution is on, and notify iTest via Socket
47
- def dump_caller_stack
48
- return unless $ITEST2_TRACE_EXECUTION
49
- begin
50
- caller.each_with_index do |position, idx|
51
- next unless position =~ /\A(.*?):(\d+)/
52
- file = $1
53
- # TODO: send multiple trace to be parse with pages.rb
54
- # next if file =~ /example\/example_methods\.rb$/ or file =~ /example\/example_group_methods\.rb$/ or file =~ /driver\.rb$/ or file =~ /timeout\.rb$/ # don't include rspec or ruby trace
55
-
56
- if file.include?("_spec.rb") || file.include?("_test.rb") || file.include?("_cmd.rb")
57
- connect_to_itest(" TRACE", position)
58
- end
59
-
60
- break if idx > 4 or file =~ /"_spec\.rb$/
61
- end
62
- rescue => e
63
- puts "failed to capture log: #{e}"
64
- end
65
- end
66
-
67
- end
68
- end
1
+ require 'socket'
2
+
3
+ module RWebSpec
4
+ module ITestPlugin
5
+
6
+ def connect_to_itest(message_type, body)
7
+ begin
8
+ the_message = message_type + "|" + body
9
+ if @last_message == the_message then # ignore the message same as preivous one
10
+ return
11
+ end
12
+ itest_port = $ITEST2_TRACE_PORT || 7025
13
+ itest_socket = Socket.new(Socket::AF_INET,Socket::SOCK_STREAM,0)
14
+ itest_socket.connect(Socket.pack_sockaddr_in(itest_port, '127.0.0.1'))
15
+ itest_socket.puts(the_message)
16
+ @last_message = the_message
17
+ itest_socket.close
18
+ rescue => e
19
+ end
20
+ end
21
+ alias connect_to_itest2 connect_to_itest
22
+
23
+ def debug(message)
24
+ connect_to_itest(" DEBUG", message + "\r\n") if $RUN_IN_ITEST
25
+ end
26
+
27
+
28
+ # Support of iTest to ajust the intervals between keystroke/mouse operations
29
+ def operation_delay
30
+ begin
31
+ if $ITEST2_OPERATION_DELAY && $ITEST2_OPERATION_DELAY > 0 &&
32
+ $ITEST2_OPERATION_DELAY && $ITEST2_OPERATION_DELAY < 30000 then # max 30 seconds
33
+ sleep($ITEST2_OPERATION_DELAY / 1000)
34
+ end
35
+
36
+ while $ITEST2_PAUSE
37
+ debug("Paused, waiting ...")
38
+ sleep 1
39
+ end
40
+ rescue => e
41
+ puts "Error on delaying: #{e}"
42
+ # ignore
43
+ end
44
+ end
45
+
46
+ # find out the line (and file) the execution is on, and notify iTest via Socket
47
+ def dump_caller_stack
48
+ return unless $ITEST2_TRACE_EXECUTION
49
+ begin
50
+ trace_lines = []
51
+ trace_file = nil
52
+ found_first_spec_reference = false
53
+ caller.each_with_index do |position, idx|
54
+ next unless position =~ /\A(.*?):(\d+)/
55
+ trace_file = $1
56
+ if trace_file =~ /(_spec|_test|_rwebspec)\.rb\s*$/
57
+ found_first_spec_reference = true
58
+ trace_lines << position
59
+ break
60
+ end
61
+ trace_lines << position
62
+ break if trace_file =~ /example\/example_methods\.rb$/ or trace_file =~ /example\/example_group_methods\.rb$/
63
+ break if trace_lines.size > 10
64
+ # TODO: send multiple trace to be parse with pages.rb
65
+ # break if trace_file =~ /example\/example_methods\.rb$/ or trace_file =~ /example\/example_group_methods\.rb$/ or trace_file =~ /driver\.rb$/ or trace_file =~ /timeout\.rb$/ # don't include rspec or ruby trace
66
+ end
67
+
68
+ # (trace_file.include?("_spec.rb") || trace_file.include?("_rwebspec.rb") || trace_file.include?("_test.rb") || trace_file.include?("_cmd.rb"))
69
+ if !trace_lines.empty?
70
+ connect_to_itest(" TRACE", trace_lines.reverse.join("|"))
71
+ end
72
+
73
+ rescue => e
74
+ puts "failed to capture log: #{e}"
75
+ end
76
+ end
77
+
78
+ end
79
+ end
@@ -361,6 +361,7 @@ module RWebSpec
361
361
  def click_button_with_caption(caption)
362
362
  wait_before_and_after { button(:caption, caption).click }
363
363
  end
364
+ alias click_button click_button_with_caption
364
365
 
365
366
  # Click a button with value
366
367
  # Usage:
@@ -557,6 +558,18 @@ module RWebSpec
557
558
  end
558
559
 
559
560
 
561
+ # Verify the next page following an operation.
562
+ #
563
+ # Typical usage:
564
+ # browser.expect_page HomePage
565
+ def expect_page(page_clazz, argument = nil)
566
+ if argument
567
+ page_clazz.new(self, argument)
568
+ else
569
+ page_clazz.new(self)
570
+ end
571
+ end
572
+
560
573
  # is it running in MS Windows platforms?
561
574
  def self.is_windows?
562
575
  RUBY_PLATFORM.downcase.include?("mswin") or RUBY_PLATFORM.downcase.include?("mingw")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zhimin-rwebspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0.2
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zhimin Zhan
@@ -76,7 +76,6 @@ files:
76
76
  - lib/watir_extensions.rb
77
77
  has_rdoc: true
78
78
  homepage: http://github.com/zhimin/rwebspec/tree/master
79
- licenses:
80
79
  post_install_message:
81
80
  rdoc_options: []
82
81
 
@@ -97,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
96
  requirements:
98
97
  - none
99
98
  rubyforge_project: rwebspec
100
- rubygems_version: 1.3.5
99
+ rubygems_version: 1.2.0
101
100
  signing_key:
102
101
  specification_version: 2
103
102
  summary: Executable functional specification for web applications in RSpec syntax and Watir