rsel 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/docs/fitnesse.md CHANGED
@@ -49,13 +49,14 @@ selenium-server on `my.selenium.host`, port `4455`, do this:
49
49
 
50
50
  | script | selenium test | http://www.mysite.com | !{host:my.selenium.host, port:4455} |
51
51
 
52
- Another useful argument to pass in this hash is `stop_on_error`, which causes
52
+ Another useful argument to pass in this hash is `stop_on_failure`, which causes
53
53
  the test to be aborted whenever any failure occurs:
54
54
 
55
- | script | selenium test | http://www.mysite.com | !{stop_on_error:true} |
55
+ | script | selenium test | http://www.mysite.com | !{stop_on_failure:true} |
56
56
 
57
57
  By default, when an error occurs, the failing step is simply colored red, and
58
- the test continues. With `stop_on_error` set, an exception will be raised.
58
+ the test continues. With `stop_on_failure` set, all steps after the failing step will
59
+ fail automatically without being executed.
59
60
 
60
61
  The first argument after `selenium test` is the URL of the site you will be testing.
61
62
  This URL is loaded when you call `Open browser`, and all steps that follow are
data/docs/history.md CHANGED
@@ -1,6 +1,14 @@
1
1
  Rsel History
2
2
  ============
3
3
 
4
+ 0.0.9
5
+ -----
6
+
7
+ - stop_on_error renamed to stop_on_failure
8
+ - stop_on_failure now causes all subsequent steps to fail, instead of raising exception
9
+ - Added begin_scenario and end_scenario to reset the found_failure flag
10
+
11
+
4
12
  0.0.8
5
13
  -----
6
14
 
@@ -39,15 +39,18 @@ module Rsel
39
39
  # @option options [String] :browser
40
40
  # Which browser to run. Should be a string like `'*firefox'` (default),
41
41
  # `'*googlechrome'`, `'*opera'`, `'*iexplore'`, `'*safari'` etc.
42
- # @option options [String, Boolean] :stop_on_error
43
- # `true` or `'true'` to raise an exception when a step fails,
44
- # `false` or `'false'` to simply return false when a step fails
42
+ # @option options [String, Boolean] :stop_on_failure
43
+ # `true` or `'true'` to abort the test when a failure occurs;
44
+ # `false` or `'false'` to continue execution when failure occurs.
45
+ # @option options [String, Integer] :timeout
46
+ # Default timeout in seconds. This determines how long the `open` method
47
+ # will wait for the page to load.
45
48
  #
46
49
  # @example
47
50
  # | script | selenium test | http://site.to.test/ |
48
51
  # | script | selenium test | http://site.to.test/ | !{host:192.168.0.3} |
49
52
  # | script | selenium test | http://site.to.test/ | !{host:192.168.0.3, port:4445} |
50
- # | script | selenium test | http://site.to.test/ | !{stop_on_error:true} |
53
+ # | script | selenium test | http://site.to.test/ | !{stop_on_failure:true} |
51
54
  #
52
55
  def initialize(url, options={})
53
56
  # Strip HTML tags from URL
@@ -56,17 +59,19 @@ module Rsel
56
59
  :host => options[:host] || 'localhost',
57
60
  :port => options[:port] || 4444,
58
61
  :browser => options[:browser] || '*firefox',
59
- :url => @url)
62
+ :url => @url,
63
+ :default_timeout_in_seconds => options[:timeout] || 300)
60
64
  # Accept Booleans or strings, case-insensitive
61
- if options[:stop_on_error].to_s =~ /true/i
62
- @stop_on_error = true
65
+ if options[:stop_on_failure].to_s =~ /true/i
66
+ @stop_on_failure = true
63
67
  else
64
- @stop_on_error = false
68
+ @stop_on_failure = false
65
69
  end
70
+ @found_failure = false
66
71
  end
67
72
 
68
- attr_reader :url, :browser, :stop_on_error
69
- attr_writer :stop_on_error
73
+ attr_reader :url, :browser, :stop_on_failure, :found_failure
74
+ attr_writer :stop_on_failure, :found_failure
70
75
 
71
76
 
72
77
  # Start the session and open a browser to the URL defined at the start of
@@ -108,6 +113,33 @@ module Rsel
108
113
  end
109
114
 
110
115
 
116
+ # Begin a new scenario, and forget about any previous failures.
117
+ # This allows you to modularize your tests into standalone sections
118
+ # that can run independently of previous scenarios, regardless of
119
+ # whether those scenarios passed or failed.
120
+ #
121
+ # @example
122
+ # | Begin scenario |
123
+ #
124
+ # @since 0.0.9
125
+ #
126
+ def begin_scenario
127
+ @found_failure = false
128
+ end
129
+
130
+
131
+ # End the current scenario. For now, this does not do anything, but is
132
+ # merely provided for symmetry with begin_scenario.
133
+ #
134
+ # @example
135
+ # | End scenario |
136
+ #
137
+ # @since 0.0.9
138
+ #
139
+ def end_scenario
140
+ end
141
+
142
+
111
143
  # Load an absolute URL or a relative path in the browser.
112
144
  #
113
145
  # @param [String] path_or_url
@@ -119,6 +151,7 @@ module Rsel
119
151
  # | Visit | /software |
120
152
  #
121
153
  def visit(path_or_url)
154
+ return false if aborted?
122
155
  fail_on_exception do
123
156
  @browser.open(path_or_url)
124
157
  end
@@ -131,6 +164,7 @@ module Rsel
131
164
  # | Click back |
132
165
  #
133
166
  def click_back
167
+ return false if aborted?
134
168
  fail_on_exception do
135
169
  @browser.go_back
136
170
  end
@@ -143,6 +177,7 @@ module Rsel
143
177
  # | Refresh page |
144
178
  #
145
179
  def refresh_page
180
+ return false if aborted?
146
181
  fail_on_exception do
147
182
  @browser.refresh
148
183
  end
@@ -169,6 +204,7 @@ module Rsel
169
204
  # | See | Welcome, Marcus |
170
205
  #
171
206
  def see(text)
207
+ return false if aborted?
172
208
  pass_if @browser.text?(text)
173
209
  end
174
210
 
@@ -182,6 +218,7 @@ module Rsel
182
218
  # | Do not see | Take a hike |
183
219
  #
184
220
  def do_not_see(text)
221
+ return false if aborted?
185
222
  pass_if !@browser.text?(text)
186
223
  end
187
224
 
@@ -195,6 +232,7 @@ module Rsel
195
232
  # | See title | Our Homepage |
196
233
  #
197
234
  def see_title(title)
235
+ return false if aborted?
198
236
  pass_if @browser.get_title == title
199
237
  end
200
238
 
@@ -208,6 +246,7 @@ module Rsel
208
246
  # | Do not see title | Someone else's homepage |
209
247
  #
210
248
  def do_not_see_title(title)
249
+ return false if aborted?
211
250
  pass_if !(@browser.get_title == title)
212
251
  end
213
252
 
@@ -226,6 +265,7 @@ module Rsel
226
265
  # @since 0.0.2
227
266
  #
228
267
  def link_exists(locator, scope={})
268
+ return false if aborted?
229
269
  pass_if @browser.element?(loc(locator, 'link', scope))
230
270
  end
231
271
 
@@ -244,6 +284,7 @@ module Rsel
244
284
  # @since 0.0.2
245
285
  #
246
286
  def button_exists(locator, scope={})
287
+ return false if aborted?
247
288
  pass_if @browser.element?(loc(locator, 'button', scope))
248
289
  end
249
290
 
@@ -260,6 +301,7 @@ module Rsel
260
301
  # @since 0.0.3
261
302
  #
262
303
  def row_exists(cells)
304
+ return false if aborted?
263
305
  row = XPath.descendant(:tr)[XPath::HTML.table_row(cells.split(/, */))]
264
306
  pass_if @browser.element?("xpath=#{row.to_s}")
265
307
  end
@@ -280,6 +322,7 @@ module Rsel
280
322
  # | Type | Dale | into | First name | field | !{within:contact} |
281
323
  #
282
324
  def type_into_field(text, locator, scope={})
325
+ return false if aborted?
283
326
  field = loc(locator, 'field', scope)
284
327
  fail_on_exception do
285
328
  ensure_editable(field) && @browser.type(field, text)
@@ -301,6 +344,7 @@ module Rsel
301
344
  # | Fill in | First name | with | Eric |
302
345
  #
303
346
  def fill_in_with(locator, text, scope={})
347
+ return false if aborted?
304
348
  type_into_field(text, locator, scope)
305
349
  end
306
350
 
@@ -317,10 +361,11 @@ module Rsel
317
361
  # | Field | First name | contains | Eric |
318
362
  #
319
363
  def field_contains(locator, text, scope={})
364
+ return false if aborted?
320
365
  begin
321
366
  field = @browser.field(loc(locator, 'field', scope))
322
- rescue => e
323
- failure e.message
367
+ rescue
368
+ failure
324
369
  else
325
370
  pass_if field.include?(text)
326
371
  end
@@ -340,10 +385,11 @@ module Rsel
340
385
  # | Field | First name | equals; | Eric | !{within:contact} |
341
386
  #
342
387
  def field_equals(locator, text, scope={})
388
+ return false if aborted?
343
389
  begin
344
390
  field = @browser.field(loc(locator, 'field', scope))
345
- rescue => e
346
- failure e.message
391
+ rescue
392
+ failure
347
393
  else
348
394
  pass_if field == text
349
395
  end
@@ -361,12 +407,12 @@ module Rsel
361
407
  # | Click; | Logout | !{within:header} |
362
408
  #
363
409
  def click(locator, scope={})
410
+ return false if aborted?
364
411
  fail_on_exception do
365
412
  @browser.click(loc(locator, 'link_or_button', scope))
366
413
  end
367
414
  end
368
415
 
369
-
370
416
  # Click on a link.
371
417
  #
372
418
  # @param [String] locator
@@ -381,6 +427,7 @@ module Rsel
381
427
  # | Click | Edit | link | !{in_row:Eric} |
382
428
  #
383
429
  def click_link(locator, scope={})
430
+ return false if aborted?
384
431
  fail_on_exception do
385
432
  @browser.click(loc(locator, 'link', scope))
386
433
  end
@@ -402,6 +449,7 @@ module Rsel
402
449
  # | Click | Search | button | !{within:customers} |
403
450
  #
404
451
  def click_button(locator, scope={})
452
+ return false if aborted?
405
453
  button = loc(locator, 'button', scope)
406
454
  fail_on_exception do
407
455
  ensure_editable(button) && @browser.click(button)
@@ -424,6 +472,7 @@ module Rsel
424
472
  # | Enable | Send me spam | checkbox | !{within:opt_in} |
425
473
  #
426
474
  def enable_checkbox(locator, scope={})
475
+ return false if aborted?
427
476
  cb = loc(locator, 'checkbox', scope)
428
477
  fail_on_exception do
429
478
  ensure_editable(cb) && checkbox_is_disabled(cb) && @browser.click(cb)
@@ -445,6 +494,7 @@ module Rsel
445
494
  # | Disable | Send me spam | checkbox | !{within:opt_in} |
446
495
  #
447
496
  def disable_checkbox(locator, scope={})
497
+ return false if aborted?
448
498
  cb = loc(locator, 'checkbox', scope)
449
499
  fail_on_exception do
450
500
  ensure_editable(cb) && checkbox_is_enabled(cb) && @browser.click(cb)
@@ -464,11 +514,12 @@ module Rsel
464
514
  # | Checkbox | send me spam | is enabled | !{within:opt_in} |
465
515
  #
466
516
  def checkbox_is_enabled(locator, scope={})
517
+ return false if aborted?
467
518
  xp = loc(locator, 'checkbox', scope)
468
519
  begin
469
520
  enabled = @browser.checked?(xp)
470
- rescue => e
471
- failure e.message
521
+ rescue
522
+ failure
472
523
  else
473
524
  return enabled
474
525
  end
@@ -489,11 +540,12 @@ module Rsel
489
540
  # @since 0.0.4
490
541
  #
491
542
  def radio_is_enabled(locator, scope={})
543
+ return false if aborted?
492
544
  xp = loc(locator, 'radio_button', scope)
493
545
  begin
494
546
  enabled = @browser.checked?(xp)
495
- rescue => e
496
- failure e.message
547
+ rescue
548
+ failure
497
549
  else
498
550
  return enabled
499
551
  end
@@ -512,11 +564,12 @@ module Rsel
512
564
  # | Checkbox | send me spam | is disabled | !{within:opt_in} |
513
565
  #
514
566
  def checkbox_is_disabled(locator, scope={})
567
+ return false if aborted?
515
568
  xp = loc(locator, 'checkbox', scope)
516
569
  begin
517
570
  enabled = @browser.checked?(xp)
518
- rescue => e
519
- failure e.message
571
+ rescue
572
+ failure
520
573
  else
521
574
  return !enabled
522
575
  end
@@ -537,11 +590,12 @@ module Rsel
537
590
  # @since 0.0.4
538
591
  #
539
592
  def radio_is_disabled(locator, scope={})
593
+ return false if aborted?
540
594
  xp = loc(locator, 'radio_button', scope)
541
595
  begin
542
596
  enabled = @browser.checked?(xp)
543
- rescue => e
544
- failure e.message
597
+ rescue
598
+ failure
545
599
  else
546
600
  return !enabled
547
601
  end
@@ -561,6 +615,7 @@ module Rsel
561
615
  # | Select | female | radio | !{within:gender} |
562
616
  #
563
617
  def select_radio(locator, scope={})
618
+ return false if aborted?
564
619
  radio = loc(locator, 'radio_button', scope)
565
620
  fail_on_exception do
566
621
  ensure_editable(radio) && @browser.click(radio)
@@ -582,6 +637,7 @@ module Rsel
582
637
  # | Select | Tall | from dropdown | Height |
583
638
  #
584
639
  def select_from_dropdown(option, locator, scope={})
640
+ return false if aborted?
585
641
  dropdown = loc(locator, 'select', scope)
586
642
  fail_on_exception do
587
643
  ensure_editable(dropdown) && @browser.select(dropdown, option)
@@ -602,6 +658,7 @@ module Rsel
602
658
  # @since 0.0.2
603
659
  #
604
660
  def dropdown_includes(locator, option, scope={})
661
+ return false if aborted?
605
662
  # TODO: Apply scope
606
663
  dropdown = XPath::HTML.select(locator)
607
664
  opt = dropdown[XPath::HTML.option(option)]
@@ -623,10 +680,11 @@ module Rsel
623
680
  # @since 0.0.2
624
681
  #
625
682
  def dropdown_equals(locator, option, scope={})
683
+ return false if aborted?
626
684
  begin
627
685
  selected = @browser.get_selected_label(loc(locator, 'select', scope))
628
- rescue => e
629
- failure e.message
686
+ rescue
687
+ failure
630
688
  else
631
689
  return selected == option
632
690
  end
@@ -642,6 +700,7 @@ module Rsel
642
700
  # | Pause | 5 | seconds |
643
701
  #
644
702
  def pause_seconds(seconds)
703
+ return false if aborted?
645
704
  sleep seconds.to_i
646
705
  return true
647
706
  end
@@ -658,6 +717,7 @@ module Rsel
658
717
  # | Page loads in | 10 | seconds or less |
659
718
  #
660
719
  def page_loads_in_seconds_or_less(seconds)
720
+ return false if aborted?
661
721
  fail_on_exception do
662
722
  @browser.wait_for_page_to_load(seconds)
663
723
  end
@@ -676,8 +736,8 @@ module Rsel
676
736
  if @browser.respond_to?(method)
677
737
  begin
678
738
  result = @browser.send(method, *args, &block)
679
- rescue => e
680
- failure e.message
739
+ rescue
740
+ failure
681
741
  else
682
742
  # The method call succeeded; did it return true or false?
683
743
  return result if [true, false].include? result
@@ -709,8 +769,7 @@ module Rsel
709
769
  private
710
770
 
711
771
  # Execute the given block, and return false if it raises an exception.
712
- # Otherwise, return true. If `@stop_on_error` is true, raise a
713
- # `StopTestStepFailed` exception instead of returning false.
772
+ # Otherwise, return true.
714
773
  #
715
774
  # @example
716
775
  # fail_on_exception do
@@ -723,7 +782,7 @@ module Rsel
723
782
  rescue => e
724
783
  #puts e.message
725
784
  #puts e.backtrace
726
- failure e.message
785
+ failure
727
786
  else
728
787
  return true
729
788
  end
@@ -738,6 +797,8 @@ module Rsel
738
797
  #
739
798
  # @since 0.0.7
740
799
  #
800
+ # @raise [StopTestInputDisabled] if the given input is not editable
801
+ #
741
802
  def ensure_editable(selenium_locator)
742
803
  if @browser.is_editable(selenium_locator)
743
804
  return true
@@ -747,38 +808,37 @@ module Rsel
747
808
  end
748
809
 
749
810
 
750
- # Indicate a failure by returning `false` or raising an exception.
751
- # If `@stop_on_error` is true, raise a `StopTestStepFailed` exception.
752
- # Otherwise, simply return false.
753
- #
754
- # @param [String] message
755
- # Optional message to include in the exception.
756
- # Ignored if `@stop_on_error` is false.
811
+ # Indicate a failure by returning `false` and setting `@found_failure = true`.
757
812
  #
758
813
  # @since 0.0.6
759
814
  #
760
- def failure(message='')
761
- if @stop_on_error
762
- raise StopTestStepFailed, message
763
- else
764
- return false
765
- end
815
+ def failure
816
+ @found_failure = true
817
+ return false
766
818
  end
767
819
 
768
820
 
769
- # Pass if the given condition is true; otherwise, fail by calling
770
- # {#failure} with an optional `message`.
821
+ # Pass if the given condition is true; otherwise, fail with {#failure}.
771
822
  #
772
823
  # @since 0.0.6
773
824
  #
774
- def pass_if(condition, message='')
825
+ def pass_if(condition)
775
826
  if condition
776
827
  return true
777
828
  else
778
- failure message
829
+ failure
779
830
  end
780
831
  end
781
832
 
833
+
834
+ # Return true if this test has been aborted.
835
+ #
836
+ # @since 0.0.9
837
+ #
838
+ def aborted?
839
+ return @found_failure && @stop_on_failure
840
+ end
841
+
782
842
  end
783
843
  end
784
844
 
data/rsel.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rsel"
3
- s.version = "0.0.8"
3
+ s.version = "0.0.9"
4
4
  s.summary = "Runs Selenium tests from FitNesse"
5
5
  s.description = <<-EOS
6
6
  Rsel provides a Slim fixture for running Selenium tests, with
@@ -970,156 +970,199 @@ describe Rsel::SeleniumTest do
970
970
  end # waiting
971
971
 
972
972
 
973
- context "stop on error" do
973
+ context "stop on failure" do
974
974
  before(:each) do
975
975
  @st.visit("/").should be_true
976
- @st.stop_on_error = true
976
+ @st.stop_on_failure = true
977
+ @st.found_failure = false
977
978
  end
978
979
 
979
980
  after(:each) do
980
- @st.stop_on_error = false
981
+ @st.stop_on_failure = false
981
982
  end
982
983
 
983
- context "causes an exception to be raised" do
984
+ context "causes subsequent steps to fail" do
984
985
  it "when #see fails" do
985
- lambda do
986
- @st.see("Nonexistent")
987
- end.should raise_error(Rsel::StopTestStepFailed)
986
+ @st.see("Nonexistent").should be_false
987
+ # Would pass, but previous step failed
988
+ @st.see("Welcome").should be_false
988
989
  end
989
990
 
990
991
  it "when #do_not_see fails" do
991
- lambda do
992
- @st.do_not_see("Welcome")
993
- end.should raise_error(Rsel::StopTestStepFailed)
992
+ @st.do_not_see("Welcome").should be_false
993
+ # Would pass, but previous step failed
994
+ @st.do_not_see("Nonexistent").should be_false
994
995
  end
995
996
 
996
997
  it "when #see_title fails" do
997
- lambda do
998
- @st.see_title("Wrong Title")
999
- end.should raise_error(Rsel::StopTestStepFailed)
998
+ @st.see_title("Wrong Title").should be_false
999
+ # Would pass, but previous step failed
1000
+ @st.see_title("Rsel Test Site").should be_false
1000
1001
  end
1001
1002
 
1002
1003
  it "when #do_not_see_title fails" do
1003
- lambda do
1004
- @st.do_not_see_title("Rsel Test Site")
1005
- end.should raise_error(Rsel::StopTestStepFailed)
1004
+ @st.do_not_see_title("Rsel Test Site").should be_false
1005
+ # Would pass, but previous step failed
1006
+ @st.do_not_see_title("Wrong title").should be_false
1006
1007
  end
1007
1008
 
1008
1009
  it "when #link_exists fails" do
1009
- lambda do
1010
- @st.link_exists("Bogus Link")
1011
- end.should raise_error(Rsel::StopTestStepFailed)
1010
+ @st.link_exists("Bogus Link").should be_false
1011
+ # Would pass, but previous step failed
1012
+ @st.link_exists("About this site").should be_false
1012
1013
  end
1013
1014
 
1014
1015
  it "when #button_exists fails" do
1015
- lambda do
1016
- @st.button_exists("Bogus Button")
1017
- end.should raise_error(Rsel::StopTestStepFailed)
1016
+ @st.visit("/form").should be_true
1017
+ @st.button_exists("Bogus Button").should be_false
1018
+ # Would pass, but previous step failed
1019
+ @st.button_exists("Submit person form").should be_false
1018
1020
  end
1019
1021
 
1020
1022
  it "when #row_exists fails" do
1021
- lambda do
1022
- @st.row_exists("No, Such, Row")
1023
- end.should raise_error(Rsel::StopTestStepFailed)
1023
+ @st.visit("/table").should be_true
1024
+ @st.row_exists("No, Such, Row").should be_false
1025
+ # Would pass, but previous step failed
1026
+ @st.row_exists("First name, Last name, Email").should be_false
1024
1027
  end
1025
1028
 
1026
1029
  it "when #type_into_field fails" do
1027
- lambda do
1028
- @st.type_into_field("Hello", "Bad Field")
1029
- end.should raise_error(Rsel::StopTestStepFailed)
1030
+ @st.visit("/form").should be_true
1031
+ @st.type_into_field("Hello", "Bad Field").should be_false
1032
+ # Would pass, but previous step failed
1033
+ @st.type_into_field("Eric", "First name").should be_false
1030
1034
  end
1031
1035
 
1032
1036
  it "when #field_contains fails" do
1033
- lambda do
1034
- @st.field_contains("Bad Field", "Hello")
1035
- end.should raise_error(Rsel::StopTestStepFailed)
1037
+ @st.visit("/form").should be_true
1038
+ @st.field_contains("Bad Field", "Hello").should be_false
1039
+ # Would pass, but previous step failed
1040
+ @st.field_contains("First name", "Marcus").should be_false
1036
1041
  end
1037
1042
 
1038
1043
  it "when #field_equals fails" do
1039
- lambda do
1040
- @st.field_equals("Bad Field", "Hello")
1041
- end.should raise_error(Rsel::StopTestStepFailed)
1044
+ @st.visit("/form").should be_true
1045
+ @st.fill_in_with("First name", "Ken")
1046
+ @st.field_equals("First name", "Eric").should be_false
1047
+ # Would pass, but previous step failed
1048
+ @st.field_equals("First name", "Ken").should be_false
1042
1049
  end
1043
1050
 
1044
1051
  it "when #click fails" do
1045
- lambda do
1046
- @st.click("No Such Link")
1047
- end.should raise_error(Rsel::StopTestStepFailed)
1052
+ @st.click("No Such Link").should be_false
1053
+ # Would pass, but previous step failed
1054
+ @st.click("About this site").should be_false
1048
1055
  end
1049
1056
 
1050
1057
  it "when #click_link fails" do
1051
- lambda do
1052
- @st.click_link("No Such Link")
1053
- end.should raise_error(Rsel::StopTestStepFailed)
1058
+ @st.click_link("No Such Link").should be_false
1059
+ # Would pass, but previous step failed
1060
+ @st.click_link("About this site").should be_false
1054
1061
  end
1055
1062
 
1056
1063
  it "when #click_button fails" do
1057
- lambda do
1058
- @st.click_button("No Such Link")
1059
- end.should raise_error(Rsel::StopTestStepFailed)
1064
+ @st.visit("/form").should be_true
1065
+ @st.click_button("No Such Link").should be_false
1066
+ # Would pass, but previous step failed
1067
+ @st.click_button("Submit person form").should be_false
1060
1068
  end
1061
1069
 
1062
1070
  it "when #enable_checkbox fails" do
1063
- lambda do
1064
- @st.enable_checkbox("No Such Checkbox")
1065
- end.should raise_error(Rsel::StopTestStepFailed)
1071
+ @st.visit("/form").should be_true
1072
+ @st.enable_checkbox("No Such Checkbox").should be_false
1073
+ # Would pass, but previous step failed
1074
+ @st.enable_checkbox("I like cheese").should be_false
1066
1075
  end
1067
1076
 
1068
1077
  it "when #disable_checkbox fails" do
1069
- lambda do
1070
- @st.disable_checkbox("No Such Checkbox")
1071
- end.should raise_error(Rsel::StopTestStepFailed)
1078
+ @st.visit("/form").should be_true
1079
+ @st.disable_checkbox("No Such Checkbox").should be_false
1080
+ # Would pass, but previous step failed
1081
+ @st.disable_checkbox("I like cheese").should be_false
1072
1082
  end
1073
1083
 
1074
1084
  it "when #checkbox_is_enabled fails" do
1075
- lambda do
1076
- @st.checkbox_is_enabled("No Such Checkbox")
1077
- end.should raise_error(Rsel::StopTestStepFailed)
1085
+ @st.visit("/form").should be_true
1086
+ @st.enable_checkbox("I like cheese").should be_true
1087
+ @st.checkbox_is_enabled("No Such Checkbox").should be_false
1088
+ # Would pass, but previous step failed
1089
+ @st.checkbox_is_enabled("I like cheese").should be_false
1078
1090
  end
1079
1091
 
1080
1092
  it "when #checkbox_is_disabled fails" do
1081
- lambda do
1082
- @st.checkbox_is_disabled("No Such Checkbox")
1083
- end.should raise_error(Rsel::StopTestStepFailed)
1093
+ @st.visit("/form").should be_true
1094
+ @st.checkbox_is_disabled("No Such Checkbox").should be_false
1095
+ # Would pass, but previous step failed
1096
+ @st.checkbox_is_disabled("I like cheese").should be_false
1084
1097
  end
1085
1098
 
1086
1099
  it "when #radio_is_enabled fails" do
1087
- lambda do
1088
- @st.radio_is_enabled("No Such Radio")
1089
- end.should raise_error(Rsel::StopTestStepFailed)
1100
+ @st.visit("/form").should be_true
1101
+ @st.select_radio("Briefs").should be_true
1102
+ @st.radio_is_enabled("No Such Radio").should be_false
1103
+ # Would pass, but previous step failed
1104
+ @st.radio_is_enabled("Briefs").should be_false
1090
1105
  end
1091
1106
 
1092
1107
  it "when #radio_is_disabled fails" do
1093
- lambda do
1094
- @st.radio_is_disabled("No Such Radio")
1095
- end.should raise_error(Rsel::StopTestStepFailed)
1108
+ @st.visit("/form").should be_true
1109
+ @st.select_radio("Boxers").should be_true
1110
+ @st.radio_is_disabled("No Such Radio").should be_false
1111
+ # Would pass, but previous step failed
1112
+ @st.radio_is_disabled("Briefs").should be_false
1096
1113
  end
1097
1114
 
1098
1115
  it "when #select_radio fails" do
1099
- lambda do
1100
- @st.select_radio("No Such Radio")
1101
- end.should raise_error(Rsel::StopTestStepFailed)
1116
+ @st.visit("/form").should be_true
1117
+ @st.select_radio("No Such Radio").should be_false
1118
+ # Would pass, but previous step failed
1119
+ @st.select_radio("Boxers").should be_false
1102
1120
  end
1103
1121
 
1104
1122
  it "when #select_from_dropdown fails" do
1105
- lambda do
1106
- @st.select_from_dropdown("Junk", "No Such Dropdown")
1107
- end.should raise_error(Rsel::StopTestStepFailed)
1123
+ @st.visit("/form").should be_true
1124
+ @st.select_from_dropdown("Junk", "No Such Dropdown").should be_false
1125
+ # Would pass, but previous step failed
1126
+ @st.select_from_dropdown("Tall", "Height").should be_false
1108
1127
  end
1109
1128
 
1110
1129
  it "when #dropdown_includes fails" do
1111
- lambda do
1112
- @st.dropdown_includes("No Such Dropdown", "Junk")
1113
- end.should raise_error(Rsel::StopTestStepFailed)
1130
+ @st.visit("/form").should be_true
1131
+ @st.dropdown_includes("No Such Dropdown", "Junk").should be_false
1132
+ # Would pass, but previous step failed
1133
+ @st.dropdown_includes("Height", "Tall").should be_false
1114
1134
  end
1115
1135
 
1116
1136
  it "when #dropdown_equals fails" do
1117
- lambda do
1118
- @st.dropdown_equals("No Such Dropdown", "Junk")
1119
- end.should raise_error(Rsel::StopTestStepFailed)
1137
+ @st.visit("/form").should be_true
1138
+ @st.select_from_dropdown("Tall", "Height").should be_true
1139
+ @st.dropdown_equals("No Such Dropdown", "Junk").should be_false
1140
+ # Would pass, but previous step failed
1141
+ @st.dropdown_equals("Tall", "Height").should be_false
1120
1142
  end
1121
1143
  end
1122
- end # stop on error
1144
+
1145
+ context "can be reset with #begin_scenario" do
1146
+ it "when #see fails" do
1147
+ @st.see("Nonexistent").should be_false
1148
+ # Would pass, but previous step failed
1149
+ @st.see("Welcome").should be_false
1150
+ # Starting a new scenario allows #see to pass
1151
+ @st.begin_scenario
1152
+ @st.see("Welcome").should be_true
1153
+ end
1154
+
1155
+ it "when #do_not_see fails" do
1156
+ @st.do_not_see("Welcome").should be_false
1157
+ # Would pass, but previous step failed
1158
+ @st.do_not_see("Nonexistent").should be_false
1159
+ # Starting a new scenario allows #do_not_see to pass
1160
+ @st.begin_scenario
1161
+ @st.do_not_see("Nonexistent").should be_true
1162
+ end
1163
+ end
1164
+
1165
+ end # stop on failure
1123
1166
 
1124
1167
 
1125
1168
  context "Selenium::Client::Driver wrapper" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marcus French
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-09-23 00:00:00 -06:00
20
+ date: 2011-09-26 00:00:00 -06:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency