diagnostics 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/.gitignore +4 -4
- data/.specification +0 -0
- data/Gemfile.lock +39 -0
- data/LICENSE +20 -0
- data/README.md +7 -0
- data/app/controllers/diagnostics_application_controller.rb +12 -0
- data/app/controllers/diagnostics_controller.rb +6 -0
- data/app/controllers/statuses_controller.rb +20 -0
- data/app/views/diagnostics/_check.html.erb +1 -0
- data/app/views/diagnostics/index.html.erb +22 -0
- data/app/views/layouts/diagnostics.html.erb +114 -0
- data/app/views/statuses/show.html.erb +15 -0
- data/config/routes.rb +6 -0
- data/diagnostics.gemspec +2 -2
- data/features/diagnostic_checks.feature +167 -0
- data/features/step_definitions/aruba.rb +5 -0
- data/features/support/env.rb +2 -0
- data/lib/diagnostics/check.rb +66 -0
- data/lib/diagnostics/data/attribute.rb +15 -0
- data/lib/diagnostics/data/elements.rb +40 -0
- data/lib/diagnostics/data/list.rb +15 -0
- data/lib/diagnostics/data/table.rb +47 -0
- data/lib/diagnostics/data/text.rb +15 -0
- data/lib/diagnostics/data_group.rb +37 -0
- data/lib/diagnostics/methods.rb +46 -0
- data/lib/diagnostics/version.rb +1 -1
- data/rails/init.rb +1 -0
- data/spec/diagnostics/check_spec.rb +78 -0
- data/spec/diagnostics/data/attribute_spec.rb +22 -0
- data/spec/diagnostics/data/list_spec.rb +22 -0
- data/spec/diagnostics/data/table_spec.rb +63 -0
- data/spec/diagnostics/data/text_spec.rb +22 -0
- data/spec/diagnostics/data_group_spec.rb +177 -0
- data/spec/diagnostics/methods_spec.rb +128 -0
- data/spec/diagnostics_spec.rb +11 -0
- data/spec/spec_helper.rb +13 -0
- data/spec_rails/rails2/Gemfile +13 -0
- data/spec_rails/rails2/Gemfile.lock +91 -0
- data/spec_rails/rails2/Rakefile +13 -0
- data/spec_rails/rails2/app_root/README +243 -0
- data/spec_rails/rails2/app_root/Rakefile +10 -0
- data/spec_rails/rails2/app_root/app/controllers/application_controller.rb +10 -0
- data/spec_rails/rails2/app_root/app/helpers/application_helper.rb +3 -0
- data/spec_rails/rails2/app_root/config/boot.rb +114 -0
- data/spec_rails/rails2/app_root/config/database.yml +25 -0
- data/spec_rails/rails2/app_root/config/environment.rb +45 -0
- data/spec_rails/rails2/app_root/config/environments/cucumber.rb +29 -0
- data/spec_rails/rails2/app_root/config/environments/development.rb +17 -0
- data/spec_rails/rails2/app_root/config/environments/production.rb +28 -0
- data/spec_rails/rails2/app_root/config/environments/test.rb +28 -0
- data/spec_rails/rails2/app_root/config/initializers/backtrace_silencers.rb +7 -0
- data/spec_rails/rails2/app_root/config/initializers/cookie_verification_secret.rb +7 -0
- data/spec_rails/rails2/app_root/config/initializers/inflections.rb +10 -0
- data/spec_rails/rails2/app_root/config/initializers/load_diagnostics.rb +2 -0
- data/spec_rails/rails2/app_root/config/initializers/mime_types.rb +5 -0
- data/spec_rails/rails2/app_root/config/initializers/new_rails_defaults.rb +21 -0
- data/spec_rails/rails2/app_root/config/initializers/session_store.rb +15 -0
- data/spec_rails/rails2/app_root/config/locales/en.yml +5 -0
- data/spec_rails/rails2/app_root/config/routes.rb +43 -0
- data/spec_rails/rails2/app_root/db/seeds.rb +7 -0
- data/spec_rails/rails2/app_root/doc/README_FOR_APP +2 -0
- data/spec_rails/rails2/app_root/lib/diagnostics/mysql_check.rb +18 -0
- data/spec_rails/rails2/app_root/lib/diagnostics/server_check.rb +4 -0
- data/spec_rails/rails2/app_root/lib/tasks/cucumber.rake +53 -0
- data/spec_rails/rails2/app_root/public/404.html +30 -0
- data/spec_rails/rails2/app_root/public/422.html +30 -0
- data/spec_rails/rails2/app_root/public/500.html +30 -0
- data/spec_rails/rails2/app_root/public/favicon.ico +0 -0
- data/spec_rails/rails2/app_root/public/images/rails.png +0 -0
- data/spec_rails/rails2/app_root/public/index.html +275 -0
- data/spec_rails/rails2/app_root/public/javascripts/application.js +2 -0
- data/spec_rails/rails2/app_root/public/javascripts/controls.js +963 -0
- data/spec_rails/rails2/app_root/public/javascripts/dragdrop.js +973 -0
- data/spec_rails/rails2/app_root/public/javascripts/effects.js +1128 -0
- data/spec_rails/rails2/app_root/public/javascripts/prototype.js +4320 -0
- data/spec_rails/rails2/app_root/public/robots.txt +5 -0
- data/spec_rails/rails2/app_root/script/about +4 -0
- data/spec_rails/rails2/app_root/script/console +3 -0
- data/spec_rails/rails2/app_root/script/cucumber +10 -0
- data/spec_rails/rails2/app_root/script/dbconsole +3 -0
- data/spec_rails/rails2/app_root/script/destroy +3 -0
- data/spec_rails/rails2/app_root/script/generate +3 -0
- data/spec_rails/rails2/app_root/script/performance/benchmarker +3 -0
- data/spec_rails/rails2/app_root/script/performance/profiler +3 -0
- data/spec_rails/rails2/app_root/script/plugin +3 -0
- data/spec_rails/rails2/app_root/script/runner +3 -0
- data/spec_rails/rails2/app_root/script/server +3 -0
- data/spec_rails/rails2/app_root/test/performance/browsing_test.rb +9 -0
- data/spec_rails/rails2/app_root/test/test_helper.rb +38 -0
- data/spec_rails/rails2/controllers/diagnostics_controller_spec.rb +12 -0
- data/spec_rails/rails2/controllers/statuses_controller_spec.rb +34 -0
- data/spec_rails/rails2/features/diagnostics_page.feature +34 -0
- data/spec_rails/rails2/features/status_page.feature +43 -0
- data/spec_rails/rails2/features/step_definitions/diagnostic_steps.rb +39 -0
- data/spec_rails/rails2/features/step_definitions/web_steps.rb +219 -0
- data/spec_rails/rails2/features/support/env.rb +61 -0
- data/spec_rails/rails2/features/support/hooks.rb +3 -0
- data/spec_rails/rails2/features/support/paths.rb +36 -0
- data/spec_rails/rails2/spec.opts +1 -0
- data/spec_rails/rails2/spec_helper.rb +4 -0
- data/spec_rails/rails3/Gemfile +0 -0
- metadata +119 -7
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
|
4
|
+
if vendored_cucumber_bin
|
|
5
|
+
load File.expand_path(vendored_cucumber_bin)
|
|
6
|
+
else
|
|
7
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
|
8
|
+
require 'cucumber'
|
|
9
|
+
load Cucumber::BINARY
|
|
10
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
|
3
|
+
require 'test_help'
|
|
4
|
+
|
|
5
|
+
class ActiveSupport::TestCase
|
|
6
|
+
# Transactional fixtures accelerate your tests by wrapping each test method
|
|
7
|
+
# in a transaction that's rolled back on completion. This ensures that the
|
|
8
|
+
# test database remains unchanged so your fixtures don't have to be reloaded
|
|
9
|
+
# between every test method. Fewer database queries means faster tests.
|
|
10
|
+
#
|
|
11
|
+
# Read Mike Clark's excellent walkthrough at
|
|
12
|
+
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
|
|
13
|
+
#
|
|
14
|
+
# Every Active Record database supports transactions except MyISAM tables
|
|
15
|
+
# in MySQL. Turn off transactional fixtures in this case; however, if you
|
|
16
|
+
# don't care one way or the other, switching from MyISAM to InnoDB tables
|
|
17
|
+
# is recommended.
|
|
18
|
+
#
|
|
19
|
+
# The only drawback to using transactional fixtures is when you actually
|
|
20
|
+
# need to test transactions. Since your test is bracketed by a transaction,
|
|
21
|
+
# any transactions started in your code will be automatically rolled back.
|
|
22
|
+
self.use_transactional_fixtures = true
|
|
23
|
+
|
|
24
|
+
# Instantiated fixtures are slow, but give you @david where otherwise you
|
|
25
|
+
# would need people(:david). If you don't want to migrate your existing
|
|
26
|
+
# test cases which use the @david style and don't mind the speed hit (each
|
|
27
|
+
# instantiated fixtures translates to a database query per test method),
|
|
28
|
+
# then set this back to true.
|
|
29
|
+
self.use_instantiated_fixtures = false
|
|
30
|
+
|
|
31
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
|
32
|
+
#
|
|
33
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
|
34
|
+
# -- they do not yet inherit this setting
|
|
35
|
+
fixtures :all
|
|
36
|
+
|
|
37
|
+
# Add more helper methods to be used by all tests here...
|
|
38
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DiagnosticsController, :type => :controller do
|
|
4
|
+
integrate_views
|
|
5
|
+
|
|
6
|
+
describe '#index' do
|
|
7
|
+
before { get :index }
|
|
8
|
+
specify { response.should be_success }
|
|
9
|
+
specify { response.should render_template(:index) }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe StatusesController, :type => :controller do
|
|
4
|
+
integrate_views
|
|
5
|
+
|
|
6
|
+
describe '#show' do
|
|
7
|
+
before { get :show }
|
|
8
|
+
specify { response.should be_success }
|
|
9
|
+
specify { response.should render_template(:show) }
|
|
10
|
+
|
|
11
|
+
context 'given .txt format' do
|
|
12
|
+
context 'successful response' do
|
|
13
|
+
before do
|
|
14
|
+
subject.should_receive(:diagnostic_status).and_return(:passed)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
before { get :show, :format => 'txt' }
|
|
18
|
+
specify { response.should be_success }
|
|
19
|
+
specify { response.body.should == 'PASS' }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context 'failed response' do
|
|
23
|
+
before do
|
|
24
|
+
subject.should_receive(:diagnostic_status).and_return(:failed)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
before { get :show, :format => 'txt' }
|
|
28
|
+
specify { response.should be_error }
|
|
29
|
+
specify { response.body.should == 'FAIL' }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Feature: Diagnostics page
|
|
2
|
+
|
|
3
|
+
The diagnostics page lists the diagnostic checks and also
|
|
4
|
+
the data for each check.
|
|
5
|
+
|
|
6
|
+
Scenario: View the diagnostics page
|
|
7
|
+
When I go to the diagnostics page
|
|
8
|
+
Then I should be on the diagnostics page
|
|
9
|
+
|
|
10
|
+
Scenario: A passing diagnostic check with data attributes
|
|
11
|
+
Given a diagnostic check named "mysql" with the following statuses:
|
|
12
|
+
| passed | warning | failed |
|
|
13
|
+
| true | false | false |
|
|
14
|
+
And diagnostic check "mysql" has the following data attributes:
|
|
15
|
+
| a | b | c |
|
|
16
|
+
| 1 | 2 | 3 |
|
|
17
|
+
When I go to the diagnostics page
|
|
18
|
+
Then I should see a passed diagnostic check named "mysql"
|
|
19
|
+
And should see "a: 1" within diagnostic data
|
|
20
|
+
And should see "b: 2" within diagnostic data
|
|
21
|
+
And should see "c: 3" within diagnostic data
|
|
22
|
+
And should see "All Systems Operational" as the title
|
|
23
|
+
|
|
24
|
+
Scenario: A failed diagnostic check with a data list
|
|
25
|
+
Given a diagnostic check named "mysql" with the following statuses:
|
|
26
|
+
| passed | warning | failed |
|
|
27
|
+
| false | false | true |
|
|
28
|
+
And diagnostic check "mysql" has a data list: "a,b,c"
|
|
29
|
+
When I go to the diagnostics page
|
|
30
|
+
Then I should see a failed diagnostic check named "mysql"
|
|
31
|
+
And should see "a" within diagnostic data
|
|
32
|
+
And should see "b" within diagnostic data
|
|
33
|
+
And should see "c" within diagnostic data
|
|
34
|
+
And should see "System Failure" as the title
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Feature: Status page
|
|
2
|
+
|
|
3
|
+
The status page displays whether the diagnostic checks
|
|
4
|
+
have passed, gave a warning, or failed.
|
|
5
|
+
|
|
6
|
+
There is also a title that gives an overall status of the
|
|
7
|
+
checks.
|
|
8
|
+
|
|
9
|
+
Scenario: View the status page
|
|
10
|
+
When I go to the status page
|
|
11
|
+
Then I should be on the status page
|
|
12
|
+
|
|
13
|
+
Scenario: A simple passing diagnostic check
|
|
14
|
+
Given a diagnostic check named "mysql" with the following statuses:
|
|
15
|
+
| passed | warning | failed |
|
|
16
|
+
| true | false | false |
|
|
17
|
+
When I go to the status page
|
|
18
|
+
Then I should see a passed diagnostic check named "mysql"
|
|
19
|
+
And should see "All Systems Operational" as the title
|
|
20
|
+
|
|
21
|
+
Scenario: Diagnostic checks that contain one warning check
|
|
22
|
+
Given a diagnostic check named "mysql" with the following statuses:
|
|
23
|
+
| passed | warning | failed |
|
|
24
|
+
| true | false | false |
|
|
25
|
+
Given a diagnostic check named "postgresql" with the following statuses:
|
|
26
|
+
| passed | warning | failed |
|
|
27
|
+
| false | true | false |
|
|
28
|
+
When I go to the status page
|
|
29
|
+
Then I should see a passed diagnostic check named "mysql"
|
|
30
|
+
And should see a warning diagnostic check named "postgresql"
|
|
31
|
+
And should see "Experiencing Issues" as the title
|
|
32
|
+
|
|
33
|
+
Scenario: Diagnostic checks that contain one failing check
|
|
34
|
+
Given a diagnostic check named "mysql" with the following statuses:
|
|
35
|
+
| passed | warning | failed |
|
|
36
|
+
| true | false | false |
|
|
37
|
+
Given a diagnostic check named "postgresql" with the following statuses:
|
|
38
|
+
| passed | warning | failed |
|
|
39
|
+
| false | false | true |
|
|
40
|
+
When I go to the status page
|
|
41
|
+
Then I should see a passed diagnostic check named "mysql"
|
|
42
|
+
And should see a failed diagnostic check named "postgresql"
|
|
43
|
+
And should see "System Failure" as the title
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Given /^a diagnostic check named "([^"]*)" with the following statuses:$/ do |name, table|
|
|
2
|
+
statuses = table.hashes[0]
|
|
3
|
+
|
|
4
|
+
diagnostic_check name do |c|
|
|
5
|
+
c.passed { eval(statuses[:passed]) }
|
|
6
|
+
c.warning { eval(statuses[:warning]) }
|
|
7
|
+
c.failed { eval(statuses[:failed]) }
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Given /^diagnostic check "([^"]*)" has the following data attributes:$/ do |name, table|
|
|
12
|
+
data = diagnostic_check(name).data
|
|
13
|
+
|
|
14
|
+
table.hashes[0].each do |k, v|
|
|
15
|
+
data[k] = v
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Given /^diagnostic check "([^"]*)" has a data list: "([^"]*)"$/ do |name, list|
|
|
20
|
+
diagnostic_check(name).data << list.split(',')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Then /^(?:|I )should see a (.+) diagnostic check named "([^"]*)"$/ do |status, name|
|
|
24
|
+
with_scope(".diagnostic-check.#{status}") do
|
|
25
|
+
page.should have_content(name)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Then /^(?:|I )should see "([^"]*)" as the title$/ do |text|
|
|
30
|
+
with_scope("#system-status") do
|
|
31
|
+
page.should have_content(text)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
Then /^(?:|I )should see "([^"]*)" within diagnostic data$/ do |text|
|
|
36
|
+
with_scope(".diagnostic-data") do
|
|
37
|
+
page.should have_content(text)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
|
5
|
+
# files.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
require 'uri'
|
|
9
|
+
require 'cgi'
|
|
10
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
|
11
|
+
|
|
12
|
+
module WithinHelpers
|
|
13
|
+
def with_scope(locator)
|
|
14
|
+
locator ? within(locator) { yield } : yield
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
World(WithinHelpers)
|
|
18
|
+
|
|
19
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
|
20
|
+
visit path_to(page_name)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
|
24
|
+
visit path_to(page_name)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
|
|
28
|
+
with_scope(selector) do
|
|
29
|
+
click_button(button)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
|
|
34
|
+
with_scope(selector) do
|
|
35
|
+
click_link(link)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
|
|
40
|
+
with_scope(selector) do
|
|
41
|
+
fill_in(field, :with => value)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
|
|
46
|
+
with_scope(selector) do
|
|
47
|
+
fill_in(field, :with => value)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Use this to fill in an entire form with data from a table. Example:
|
|
52
|
+
#
|
|
53
|
+
# When I fill in the following:
|
|
54
|
+
# | Account Number | 5002 |
|
|
55
|
+
# | Expiry date | 2009-11-01 |
|
|
56
|
+
# | Note | Nice guy |
|
|
57
|
+
# | Wants Email? | |
|
|
58
|
+
#
|
|
59
|
+
# TODO: Add support for checkbox, select og option
|
|
60
|
+
# based on naming conventions.
|
|
61
|
+
#
|
|
62
|
+
When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
|
|
63
|
+
with_scope(selector) do
|
|
64
|
+
fields.rows_hash.each do |name, value|
|
|
65
|
+
When %{I fill in "#{name}" with "#{value}"}
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
|
|
71
|
+
with_scope(selector) do
|
|
72
|
+
select(value, :from => field)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
|
|
77
|
+
with_scope(selector) do
|
|
78
|
+
check(field)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
|
|
83
|
+
with_scope(selector) do
|
|
84
|
+
uncheck(field)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
|
|
89
|
+
with_scope(selector) do
|
|
90
|
+
choose(field)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
|
|
95
|
+
with_scope(selector) do
|
|
96
|
+
attach_file(field, path)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
Then /^(?:|I )should see JSON:$/ do |expected_json|
|
|
101
|
+
require 'json'
|
|
102
|
+
expected = JSON.pretty_generate(JSON.parse(expected_json))
|
|
103
|
+
actual = JSON.pretty_generate(JSON.parse(response.body))
|
|
104
|
+
expected.should == actual
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
|
|
108
|
+
with_scope(selector) do
|
|
109
|
+
if page.respond_to? :should
|
|
110
|
+
page.should have_content(text)
|
|
111
|
+
else
|
|
112
|
+
assert page.has_content?(text)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
|
118
|
+
regexp = Regexp.new(regexp)
|
|
119
|
+
with_scope(selector) do
|
|
120
|
+
if page.respond_to? :should
|
|
121
|
+
page.should have_xpath('//*', :text => regexp)
|
|
122
|
+
else
|
|
123
|
+
assert page.has_xpath?('//*', :text => regexp)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
|
|
129
|
+
with_scope(selector) do
|
|
130
|
+
if page.respond_to? :should
|
|
131
|
+
page.should have_no_content(text)
|
|
132
|
+
else
|
|
133
|
+
assert page.has_no_content?(text)
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
|
139
|
+
regexp = Regexp.new(regexp)
|
|
140
|
+
with_scope(selector) do
|
|
141
|
+
if page.respond_to? :should
|
|
142
|
+
page.should have_no_xpath('//*', :text => regexp)
|
|
143
|
+
else
|
|
144
|
+
assert page.has_no_xpath?('//*', :text => regexp)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
|
|
150
|
+
with_scope(selector) do
|
|
151
|
+
field = find_field(field)
|
|
152
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
|
153
|
+
if field_value.respond_to? :should
|
|
154
|
+
field_value.should =~ /#{value}/
|
|
155
|
+
else
|
|
156
|
+
assert_match(/#{value}/, field_value)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
|
|
162
|
+
with_scope(selector) do
|
|
163
|
+
field = find_field(field)
|
|
164
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
|
165
|
+
if field_value.respond_to? :should_not
|
|
166
|
+
field_value.should_not =~ /#{value}/
|
|
167
|
+
else
|
|
168
|
+
assert_no_match(/#{value}/, field_value)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
|
|
174
|
+
with_scope(selector) do
|
|
175
|
+
field_checked = find_field(label)['checked']
|
|
176
|
+
if field_checked.respond_to? :should
|
|
177
|
+
field_checked.should be_true
|
|
178
|
+
else
|
|
179
|
+
assert field_checked
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
|
|
185
|
+
with_scope(selector) do
|
|
186
|
+
field_checked = find_field(label)['checked']
|
|
187
|
+
if field_checked.respond_to? :should
|
|
188
|
+
field_checked.should be_false
|
|
189
|
+
else
|
|
190
|
+
assert !field_checked
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
|
196
|
+
current_path = URI.parse(current_url).path
|
|
197
|
+
if current_path.respond_to? :should
|
|
198
|
+
current_path.should == path_to(page_name)
|
|
199
|
+
else
|
|
200
|
+
assert_equal path_to(page_name), current_path
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
|
205
|
+
query = URI.parse(current_url).query
|
|
206
|
+
actual_params = query ? CGI.parse(query) : {}
|
|
207
|
+
expected_params = {}
|
|
208
|
+
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
|
209
|
+
|
|
210
|
+
if actual_params.respond_to? :should
|
|
211
|
+
actual_params.should == expected_params
|
|
212
|
+
else
|
|
213
|
+
assert_equal expected_params, actual_params
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
Then /^show me the page$/ do
|
|
218
|
+
save_and_open_page
|
|
219
|
+
end
|