suhyo 0.0.1 → 0.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.
- data/VERSION +1 -1
- data/lib/suhyo/view_matchers.rb +5 -1
- data/spec/view_matchers_spec.rb +10 -0
- data/suhyo.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/suhyo/view_matchers.rb
CHANGED
@@ -83,11 +83,15 @@ module Suhyo
|
|
83
83
|
|
84
84
|
class HaveRestfulForm < ::Webrat::Matchers::HaveSelector
|
85
85
|
def initialize(method, options = {}, &block)
|
86
|
+
raise(ArgumentError, "Expected options to be a Hash, but got #{options.inspect}") unless options.is_a?(Hash)
|
86
87
|
@options = options
|
87
88
|
@method = method.to_s.downcase
|
89
|
+
unless @method == 'get' or @method == 'post' or @method == 'put' or @method == 'delete'
|
90
|
+
raise(ArgumentError, "Expected method to be 'get', 'post', 'put', or 'delete', but got #{method.inspect}")
|
91
|
+
end
|
88
92
|
# browser_method is the method the browser actually uses, either GET or POST
|
89
93
|
@browser_method = (method == 'get') ? 'get' : 'post'
|
90
|
-
if ancestors = options.delete(:ancestors)
|
94
|
+
if ancestors = @options.delete(:ancestors)
|
91
95
|
@expected = ancestors + ' form'
|
92
96
|
else
|
93
97
|
@expected = 'form'
|
data/spec/view_matchers_spec.rb
CHANGED
@@ -80,5 +80,15 @@ describe Suhyo::ViewMatchers do
|
|
80
80
|
'<form action="http://example.com" method="get"></form>'.should have_restful_form('get', :action => 'http://example.com')
|
81
81
|
'<form action="http://example.com" method="get"></form>'.should_not have_restful_form('get', :action => 'http://google.com')
|
82
82
|
end
|
83
|
+
|
84
|
+
it 'raises ArgumentError if method is not get, post, put, or delete' do
|
85
|
+
lambda { restful_form('get').should have_restful_form('foo') }.should raise_error(ArgumentError)
|
86
|
+
lambda { restful_form('get').should have_restful_form(42) }.should raise_error(ArgumentError)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'raises ArgumentError if options is not a hash' do
|
90
|
+
lambda { restful_form('get').should have_restful_form('get', 42) }.should raise_error(ArgumentError)
|
91
|
+
lambda { restful_form('get').should have_restful_form('get', 'foo') }.should raise_error(ArgumentError)
|
92
|
+
end
|
83
93
|
end
|
84
94
|
end
|
data/suhyo.gemspec
CHANGED