suhyo 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -5
- data/.gitignore +21 -21
- data/LICENSE +20 -20
- data/README.markdown +3 -3
- data/Rakefile +47 -46
- data/VERSION +1 -1
- data/lib/suhyo/controller_matchers.rb +37 -37
- data/lib/suhyo/hash_matchers.rb +27 -0
- data/lib/suhyo/view_matchers.rb +18 -7
- data/lib/suhyo/webrat_steps.rb +85 -0
- data/lib/suhyo.rb +1 -0
- data/spec/features/README.txt +1 -0
- data/spec/features/steps.rb +32 -0
- data/spec/features/webrat.feature +98 -0
- data/spec/hash_matchers_spec.rb +15 -0
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +12 -9
- data/spec/view_matchers_spec.rb +174 -132
- data/spec/webrat_steps_spec.rb +127 -0
- data/suhyo.gemspec +76 -63
- metadata +50 -13
data/.document
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
README.rdoc
|
2
|
-
lib/**/*.rb
|
3
|
-
bin/*
|
4
|
-
features/**/*.feature
|
5
|
-
LICENSE
|
1
|
+
README.rdoc
|
2
|
+
lib/**/*.rb
|
3
|
+
bin/*
|
4
|
+
features/**/*.feature
|
5
|
+
LICENSE
|
data/.gitignore
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
## MAC OS
|
2
|
-
.DS_Store
|
3
|
-
|
4
|
-
## TEXTMATE
|
5
|
-
*.tmproj
|
6
|
-
tmtags
|
7
|
-
|
8
|
-
## EMACS
|
9
|
-
*~
|
10
|
-
\#*
|
11
|
-
.\#*
|
12
|
-
|
13
|
-
## VIM
|
14
|
-
*.swp
|
15
|
-
|
16
|
-
## PROJECT::GENERAL
|
17
|
-
coverage
|
18
|
-
rdoc
|
19
|
-
pkg
|
20
|
-
|
21
|
-
## PROJECT::SPECIFIC
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## PROJECT::GENERAL
|
17
|
+
coverage
|
18
|
+
rdoc
|
19
|
+
pkg
|
20
|
+
|
21
|
+
## PROJECT::SPECIFIC
|
data/LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2009 jarrett
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2009 jarrett
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Suhyo
|
2
|
-
=====
|
3
|
-
|
1
|
+
Suhyo
|
2
|
+
=====
|
3
|
+
|
4
4
|
Suhyo is an extension to RSpec and Webrat. It provides commonly-needed matchers for web applications. The matchers are documented with RDoc in their respective files in the `lib` directory.
|
data/Rakefile
CHANGED
@@ -1,46 +1,47 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "suhyo"
|
8
|
-
gem.summary = 'Matchers for web app specs'
|
9
|
-
gem.description = 'Matchers built on Webrat to address some common needs in web app testing'
|
10
|
-
gem.email = 'jarrett@uchicago.edu'
|
11
|
-
gem.homepage = 'http://github.com/jarrett/suhyo'
|
12
|
-
gem.authors = ['jarrett']
|
13
|
-
gem.add_dependency 'rspec', '>= 1.2.9'
|
14
|
-
gem.add_dependency 'webrat', '>= 0.7.0'
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
spec.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
spec.
|
31
|
-
spec.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
rdoc.
|
44
|
-
rdoc.
|
45
|
-
rdoc.rdoc_files.include('
|
46
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "suhyo"
|
8
|
+
gem.summary = 'Matchers for web app specs'
|
9
|
+
gem.description = 'Matchers built on Webrat to address some common needs in web app testing'
|
10
|
+
gem.email = 'jarrett@uchicago.edu'
|
11
|
+
gem.homepage = 'http://github.com/jarrett/suhyo'
|
12
|
+
gem.authors = ['jarrett']
|
13
|
+
gem.add_dependency 'rspec', '>= 1.2.9'
|
14
|
+
gem.add_dependency 'webrat', '>= 0.7.0'
|
15
|
+
gem.add_development_dependency 'cuke-test'
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'spec/rake/spectask'
|
24
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
25
|
+
spec.libs << 'lib' << 'spec'
|
26
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
27
|
+
end
|
28
|
+
|
29
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
+
spec.libs << 'lib' << 'spec'
|
31
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
+
spec.rcov = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :spec => :check_dependencies
|
36
|
+
|
37
|
+
task :default => :spec
|
38
|
+
|
39
|
+
require 'rake/rdoctask'
|
40
|
+
Rake::RDocTask.new do |rdoc|
|
41
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
42
|
+
|
43
|
+
rdoc.rdoc_dir = 'rdoc'
|
44
|
+
rdoc.title = "suhyo #{version}"
|
45
|
+
rdoc.rdoc_files.include('README*')
|
46
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
47
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
@@ -1,38 +1,38 @@
|
|
1
|
-
module Suhyo
|
2
|
-
module ControllerMatchers
|
3
|
-
class DenyAccess
|
4
|
-
def matches?(response)
|
5
|
-
@response = response
|
6
|
-
@response.status.split(' ').first == '403' or (@response.redirect? and response.redirect_url == Suhyo.config.access_denied_url)
|
7
|
-
end
|
8
|
-
|
9
|
-
def failure_message
|
10
|
-
if @response.redirect?
|
11
|
-
"expected response to deny access (403 or 302 to #{Suhyo.config.access_denied_url}). Status was #{@response.status} with redirect to #{@response.redirect_url}."
|
12
|
-
else
|
13
|
-
"expected response to deny access (403 or 302 to #{Suhyo.config.access_denied_url}). Status was #{@response.status}."
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def negative_failure_message
|
18
|
-
'expected response not to deny access'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# Looks for either of two things:
|
23
|
-
#
|
24
|
-
# 1. HTTP status code 403 Forbidden
|
25
|
-
# 2. Redirect to a certain access denied URL.
|
26
|
-
#
|
27
|
-
# The access denied URL is determined by +Suhyo.config.access_denied_url+,
|
28
|
-
# which defaults to +http://test.host/login+.
|
29
|
-
#
|
30
|
-
# Usage:
|
31
|
-
#
|
32
|
-
# get :some_restricted_action
|
33
|
-
# response.should deny_access
|
34
|
-
def deny_access
|
35
|
-
DenyAccess.new
|
36
|
-
end
|
37
|
-
end
|
1
|
+
module Suhyo
|
2
|
+
module ControllerMatchers
|
3
|
+
class DenyAccess
|
4
|
+
def matches?(response)
|
5
|
+
@response = response
|
6
|
+
@response.status.split(' ').first == '403' or (@response.redirect? and response.redirect_url == Suhyo.config.access_denied_url)
|
7
|
+
end
|
8
|
+
|
9
|
+
def failure_message
|
10
|
+
if @response.redirect?
|
11
|
+
"expected response to deny access (403 or 302 to #{Suhyo.config.access_denied_url}). Status was #{@response.status} with redirect to #{@response.redirect_url}."
|
12
|
+
else
|
13
|
+
"expected response to deny access (403 or 302 to #{Suhyo.config.access_denied_url}). Status was #{@response.status}."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def negative_failure_message
|
18
|
+
'expected response not to deny access'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Looks for either of two things:
|
23
|
+
#
|
24
|
+
# 1. HTTP status code 403 Forbidden
|
25
|
+
# 2. Redirect to a certain access denied URL.
|
26
|
+
#
|
27
|
+
# The access denied URL is determined by +Suhyo.config.access_denied_url+,
|
28
|
+
# which defaults to +http://test.host/login+.
|
29
|
+
#
|
30
|
+
# Usage:
|
31
|
+
#
|
32
|
+
# get :some_restricted_action
|
33
|
+
# response.should deny_access
|
34
|
+
def deny_access
|
35
|
+
DenyAccess.new
|
36
|
+
end
|
37
|
+
end
|
38
38
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Suhyo::HashMatchers
|
2
|
+
class IncludeHash
|
3
|
+
def initialize(hash)
|
4
|
+
@hash = hash
|
5
|
+
end
|
6
|
+
|
7
|
+
def matches?(target)
|
8
|
+
@target = target
|
9
|
+
@hash.each do |key, value|
|
10
|
+
return false unless target[key] == value
|
11
|
+
end
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
def failure_message
|
16
|
+
"Expected hash to include #{@hash.inspect} but got #{@target.inspect}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def negative_failure_message
|
20
|
+
"Expected hash not to include #{@hash.inspect} but got #{@target.inspect}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def include_hash(hash)
|
25
|
+
IncludeHash.new(hash)
|
26
|
+
end
|
27
|
+
end
|
data/lib/suhyo/view_matchers.rb
CHANGED
@@ -2,6 +2,15 @@ module Suhyo
|
|
2
2
|
module ViewMatchers
|
3
3
|
include Webrat::Matchers
|
4
4
|
|
5
|
+
# A simple wrapper around +have_selector+. Usage:
|
6
|
+
#
|
7
|
+
# response.should have_button(:text => 'Submit')
|
8
|
+
def have_button(options = {})
|
9
|
+
options[:type] = 'button'
|
10
|
+
options[:value] = options.delete(:text) if options.has_key?(:text)
|
11
|
+
have_selector('input', options)
|
12
|
+
end
|
13
|
+
|
5
14
|
class HaveOrderedContent < ::Webrat::Matchers::HasContent
|
6
15
|
def initialize(content, options = {})
|
7
16
|
@content = content
|
@@ -36,26 +45,28 @@ module Suhyo
|
|
36
45
|
end
|
37
46
|
|
38
47
|
def failure_message
|
39
|
-
"expected the following element's content to #{content_message}:\n#{squeeze_space(@element)}
|
48
|
+
"expected the following element's content to #{content_message}#{order_message}:\n\n#{squeeze_space(@element)}"
|
40
49
|
end
|
41
50
|
|
42
51
|
def negative_failure_message
|
43
|
-
"expected the following element's content to not #{content_message}:\n#{squeeze_space(@element)}
|
52
|
+
"expected the following element's content to not #{content_message}#{order_message}:\n\n#{squeeze_space(@element)}"
|
44
53
|
end
|
45
54
|
|
46
55
|
def order_message
|
47
56
|
if @options.has_key?(:before)
|
48
|
-
str =
|
57
|
+
str = %Q{ before "#{@options[:before]}"}
|
49
58
|
if @other_content_index.nil?
|
50
|
-
str <<
|
59
|
+
str << %Q{ but "#{@options[:before]}" was not found}
|
51
60
|
end
|
61
|
+
return str
|
52
62
|
elsif @options.has_key?(:after)
|
53
|
-
str =
|
63
|
+
str = %Q{ after "#{@options[:after]}"}
|
54
64
|
if @other_content_index.nil?
|
55
|
-
str <<
|
65
|
+
str << %Q{ but "#{@options[:after]}" was not found}
|
56
66
|
end
|
67
|
+
return str
|
57
68
|
else
|
58
|
-
nil
|
69
|
+
return nil
|
59
70
|
end
|
60
71
|
end
|
61
72
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'webrat'
|
2
|
+
require 'suhyo'
|
3
|
+
|
4
|
+
World(Webrat::Matchers)
|
5
|
+
|
6
|
+
include Suhyo::ViewMatchers
|
7
|
+
include Suhyo::HashMatchers
|
8
|
+
|
9
|
+
# The form class can be something like "user search," which will find form.user_search
|
10
|
+
When /^I press "([^\"]*)" in the "([^\"]*)" form$/ do |button, form_class|
|
11
|
+
within '.' + form_class.downcase.gsub(' ', '_') do |scope|
|
12
|
+
scope.click_button(button)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Then /^I should see a link that says "([^\"]*)"$/ do |text|
|
17
|
+
response.should have_link(:text => text)
|
18
|
+
end
|
19
|
+
|
20
|
+
Then /^I should not see a link that says "([^\"]*)"$/ do |text|
|
21
|
+
response.should_not have_link(:text => text)
|
22
|
+
end
|
23
|
+
|
24
|
+
Then /^I should see a link to "([^\"]*)"$/ do |url|
|
25
|
+
response.should have_link(:url => url)
|
26
|
+
end
|
27
|
+
|
28
|
+
Then /^I should not see a link to "([^\"]*)"$/ do |url|
|
29
|
+
response.should_not have_link(:url => url)
|
30
|
+
end
|
31
|
+
|
32
|
+
Then /^I should see a button that says "([^\"]*)"$/ do |text|
|
33
|
+
response.should have_button(:text => text)
|
34
|
+
end
|
35
|
+
|
36
|
+
Then /^I should not see a button that says "([^\"]*)"$/ do |text|
|
37
|
+
response.should_not have_button(:text => text)
|
38
|
+
end
|
39
|
+
|
40
|
+
Then /^the page title should be "([^\"]*)"$/ do |title|
|
41
|
+
if Suhyo.config.site_title_ends_in
|
42
|
+
title = title + Suhyo.config.site_title_ends_in
|
43
|
+
end
|
44
|
+
response.should have_selector('title', :content => title)
|
45
|
+
end
|
46
|
+
|
47
|
+
Then /^I should see "([^\"]*)" before "([^\"]*)"$/ do |first, second|
|
48
|
+
response.should contain_in_order(first, :before => second)
|
49
|
+
end
|
50
|
+
|
51
|
+
Then /^I should see "([^\"]*)" after "([^\"]*)"$/ do |second, first|
|
52
|
+
response.should contain_in_order(second, :after => first)
|
53
|
+
end
|
54
|
+
|
55
|
+
module Suhyo
|
56
|
+
module ParseQueryHelper
|
57
|
+
def parse_query_string(str)
|
58
|
+
str.split('&').inject({}) do |hash, pair|
|
59
|
+
key, value = pair.split('=')
|
60
|
+
hash[key] = value
|
61
|
+
hash
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
World(::Suhyo::ParseQueryHelper)
|
68
|
+
|
69
|
+
# "At" instead of "on" because "on" would create an ambiguous match
|
70
|
+
|
71
|
+
Then /^I should be at (.+) with the query string "([^\"]*)"$/ do |page_name, query_string|
|
72
|
+
uri = URI.parse(current_url)
|
73
|
+
uri.path.should == path_to(page_name)
|
74
|
+
expected_query_hash = parse_query_string(query_string)
|
75
|
+
actual_query_hash = parse_query_string(uri.query)
|
76
|
+
actual_query_hash.should == expected_query_hash
|
77
|
+
end
|
78
|
+
|
79
|
+
Then /^I should be at (.+) with the query string including "([^\"]*)"$/ do |page_name, query_string|
|
80
|
+
uri = URI.parse(current_url)
|
81
|
+
uri.path.should == path_to(page_name)
|
82
|
+
expected_query_hash = parse_query_string(query_string)
|
83
|
+
actual_query_hash = parse_query_string(uri.query)
|
84
|
+
actual_query_hash.should include_hash(expected_query_hash)
|
85
|
+
end
|
data/lib/suhyo.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
The feature files in this directory are invoked from RSpec examples that hook into the Cucumber library. They are not meant to be run from the Cucumber executable.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '../../../lib/suhyo/webrat_steps.rb')
|
3
|
+
|
4
|
+
module Suhyo
|
5
|
+
module WebratMocks
|
6
|
+
# Mock out some of the methods from Webrat
|
7
|
+
|
8
|
+
def response
|
9
|
+
@mock_response
|
10
|
+
end
|
11
|
+
|
12
|
+
def path_to(page_name)
|
13
|
+
'/path'
|
14
|
+
end
|
15
|
+
|
16
|
+
def current_url
|
17
|
+
@mock_current_url
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
World(Suhyo::WebratMocks)
|
25
|
+
|
26
|
+
Given /^the response is (.+)$/ do |str|
|
27
|
+
@mock_response = str
|
28
|
+
end
|
29
|
+
|
30
|
+
Given /^the current path is (.+)$/ do |str|
|
31
|
+
@mock_current_url = 'http://test.host/' + str
|
32
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
Feature: webrat
|
2
|
+
This feature file is used by RSpec to test Suhyo's library of step definitions.
|
3
|
+
|
4
|
+
Scenario: link text expected, found
|
5
|
+
Given the response is <a href="http://example.com">Correct Text</a>
|
6
|
+
Then I should see a link that says "Correct Text"
|
7
|
+
|
8
|
+
Scenario: link text expected, not found
|
9
|
+
Given the response is <a href="http://example.com">Wrong Text</a>
|
10
|
+
Then I should see a link that says "Correct Text"
|
11
|
+
|
12
|
+
Scenario: link text not expected, not found
|
13
|
+
Given the response is <a href="http://example.com">Wrong Text</a>
|
14
|
+
Then I should not see a link that says "Correct Text"
|
15
|
+
|
16
|
+
Scenario: link text not expected, found
|
17
|
+
Given the response is <a href="http://example.com">Correct Text</a>
|
18
|
+
Then I should not see a link that says "Correct Text"
|
19
|
+
|
20
|
+
Scenario: link URL expected, found
|
21
|
+
Given the response is <a href="http://correct.com">Text</a>
|
22
|
+
Then I should see a link to "http://correct.com"
|
23
|
+
|
24
|
+
Scenario: link URL expected, not found
|
25
|
+
Given the response is <a href="http://wrong.com">Text</a>
|
26
|
+
Then I should see a link to "http://correct.com"
|
27
|
+
|
28
|
+
Scenario: link URL not expected, not found
|
29
|
+
Given the response is <a href="http://wrong.com">Text</a>
|
30
|
+
Then I should not see a link to "http://correct.com"
|
31
|
+
|
32
|
+
Scenario: link URL not expected, found
|
33
|
+
Given the response is <a href="http://correct.com">Text</a>
|
34
|
+
Then I should not see a link to "http://correct.com"
|
35
|
+
|
36
|
+
Scenario: button text expected, found
|
37
|
+
Given the response is <input type="button" value="Correct Text"/>
|
38
|
+
Then I should see a button that says "Correct Text"
|
39
|
+
|
40
|
+
Scenario: button text expected, not found
|
41
|
+
Given the response is <input type="button" value="Wrong Text"/>
|
42
|
+
Then I should see a button that says "Correct Text"
|
43
|
+
|
44
|
+
Scenario: button text not expected, not found
|
45
|
+
Given the response is <input type="button" value="Wrong Text"/>
|
46
|
+
Then I should not see a button that says "Correct Text"
|
47
|
+
|
48
|
+
Scenario: button text not expected, found
|
49
|
+
Given the response is <input type="button" value="Correct Text"/>
|
50
|
+
Then I should not see a button that says "Correct Text"
|
51
|
+
|
52
|
+
Scenario: page title correct
|
53
|
+
Given the response is <head><title>Correct Title</title></head>
|
54
|
+
Then the page title should be "Correct Title"
|
55
|
+
|
56
|
+
Scenario: page title wrong
|
57
|
+
Given the response is <head><title>Wrong Title</title></head>
|
58
|
+
Then the page title should be "Correct Title"
|
59
|
+
|
60
|
+
Scenario: content expected before, found before
|
61
|
+
Given the response is <p>First</p><p>Second</p>
|
62
|
+
Then I should see "First" before "Second"
|
63
|
+
|
64
|
+
Scenario: content expected before, found after
|
65
|
+
Given the response is <p>Second</p><p>First</p>
|
66
|
+
Then I should see "First" before "Second"
|
67
|
+
|
68
|
+
Scenario: content expected after, found after
|
69
|
+
Given the response is <p>First</p><p>Second</p>
|
70
|
+
Then I should see "Second" after "First"
|
71
|
+
|
72
|
+
Scenario: content expected after, found before
|
73
|
+
Given the response is <p>Second</p><p>First</p>
|
74
|
+
Then I should see "Second" after "First"
|
75
|
+
|
76
|
+
Scenario: query string expected, found
|
77
|
+
Given the current path is path?a=alpha&b=beta
|
78
|
+
Then I should be at a page with the query string "a=alpha&b=beta"
|
79
|
+
|
80
|
+
Scenario: query string expected, not found
|
81
|
+
Given the current path is path?a=alpha
|
82
|
+
Then I should be at a page with the query string "a=alpha&b=beta"
|
83
|
+
|
84
|
+
Scenario: query string expected, path wrong
|
85
|
+
Given the current path is wrong_path?a=alpha&b=beta
|
86
|
+
Then I should be at a page with the query string "a=alpha&b=beta"
|
87
|
+
|
88
|
+
Scenario: partial query string expected, found
|
89
|
+
Given the current path is path?a=alpha&b=beta&z=omega
|
90
|
+
Then I should be at a page with the query string including "a=alpha&b=beta"
|
91
|
+
|
92
|
+
Scenario: partial query string expected, not found
|
93
|
+
Given the current path is path?a=alpha&z=omega
|
94
|
+
Then I should be at a page with the query string including "a=alpha&b=beta"
|
95
|
+
|
96
|
+
Scenario: partial query string expected, path wrong
|
97
|
+
Given the current path is wrong_path?a=alpha&b=beta&z=omega
|
98
|
+
Then I should be at a page with the query string including "a=alpha&b=beta"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Suhyo::HashMatchers do
|
4
|
+
include Suhyo::HashMatchers
|
5
|
+
|
6
|
+
describe '#include_hash' do
|
7
|
+
it 'matches if the target hash includes each pair in the expected hash' do
|
8
|
+
{:a => 1, :b => 2, :c => 3, :d => 4}.should include_hash(:a => 1, :c => 3)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'does not match if the target hash is missing one of the pairs in the expected hash' do
|
12
|
+
{:a => 1, :b => 2, :c => 3, :d => 4}.should_not include_hash(:a => 2, :c => 3)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec.opts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--color
|
1
|
+
--color
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
require 'suhyo'
|
4
|
-
require 'spec'
|
5
|
-
require 'spec/autorun'
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'suhyo'
|
4
|
+
require 'spec'
|
5
|
+
require 'spec/autorun'
|
6
|
+
require 'cuke-test'
|
7
|
+
# Require the matchers
|
8
|
+
Dir[File.expand_path(File.join(File.dirname(__FILE__), 'matchers', '**', '*.rb'))].each { |f| require f }
|
9
|
+
|
10
|
+
Spec::Runner.configure do |config|
|
11
|
+
|
12
|
+
end
|