splinter 0.0.3 → 0.0.4

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.
data/README.markdown CHANGED
@@ -69,6 +69,13 @@ Here's a little sugar to help complete Rails forms:
69
69
 
70
70
  After the block is evaluated, the form is completed and submitted.
71
71
 
72
+ ## Javascript Confirm
73
+
74
+ You can use these helpers to confirm/cancel a javascript "confirm":
75
+
76
+ javascript_confirm { click_link "Destroy" }
77
+ javascript_confirm(false) { click_link "Destroy" }
78
+
72
79
  ## Note on Patches/Pull Requests
73
80
 
74
81
  * Fork the project.
@@ -109,6 +109,20 @@ module Splinter
109
109
  select.find(:xpath, path, :message => option_err).select_option
110
110
  end
111
111
 
112
+ # Simulates a javascript alert confirmation. You need to pass in a block that will
113
+ # generate the alert. E.g.:
114
+ #
115
+ # javascript_confirm { click_link "Destroy" }
116
+ # javascript_confirm(false) { click_link "Destroy" }
117
+ def javascript_confirm(result = true)
118
+ raise ArgumentError, "Block required" unless block_given?
119
+ result = !! result
120
+
121
+ page.evaluate_script("window.original_confirm = window.confirm; window.confirm = function() { return #{result.inspect}; }")
122
+ yield
123
+ page.evaluate_script("window.confirm = window.original_confirm;")
124
+ end
125
+
112
126
  private
113
127
 
114
128
  def select_prefix_from_options(options)
@@ -1,3 +1,3 @@
1
1
  module Splinter
2
- VERSION = Version = '0.0.3'
2
+ VERSION = Version = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splinter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-08 00:00:00.000000000 Z
12
+ date: 2012-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capybara