granular_permissions 0.0.0

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.
Files changed (76) hide show
  1. data/.bundle/config +2 -0
  2. data/.config/cucumber.yml +8 -0
  3. data/.gitignore +3 -0
  4. data/.rvmrc +1 -0
  5. data/Gemfile +29 -0
  6. data/Gemfile.lock +161 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README +13 -0
  9. data/Rakefile +56 -0
  10. data/VERSION +1 -0
  11. data/features/step_definitions/bernie_steps.rb +5 -0
  12. data/features/step_definitions/mislav_steps.rb +13 -0
  13. data/features/step_definitions/web_steps.rb +226 -0
  14. data/features/support/blueprints.rb +13 -0
  15. data/features/support/env.rb +39 -0
  16. data/features/support/models.rb +7 -0
  17. data/features/support/paths.rb +41 -0
  18. data/fixture_rails_root/.gitignore +4 -0
  19. data/fixture_rails_root/Gemfile +25 -0
  20. data/fixture_rails_root/Gemfile.lock +177 -0
  21. data/fixture_rails_root/README +256 -0
  22. data/fixture_rails_root/Rakefile +7 -0
  23. data/fixture_rails_root/app/controllers/application_controller.rb +3 -0
  24. data/fixture_rails_root/app/helpers/application_helper.rb +2 -0
  25. data/fixture_rails_root/app/views/layouts/application.html.erb +14 -0
  26. data/fixture_rails_root/config.ru +4 -0
  27. data/fixture_rails_root/config/application.rb +16 -0
  28. data/fixture_rails_root/config/boot.rb +13 -0
  29. data/fixture_rails_root/config/database.yml +28 -0
  30. data/fixture_rails_root/config/environment.rb +5 -0
  31. data/fixture_rails_root/config/environments/development.rb +11 -0
  32. data/fixture_rails_root/config/environments/production.rb +9 -0
  33. data/fixture_rails_root/config/environments/test.rb +10 -0
  34. data/fixture_rails_root/config/initializers/backtrace_silencers.rb +7 -0
  35. data/fixture_rails_root/config/initializers/inflections.rb +10 -0
  36. data/fixture_rails_root/config/initializers/mime_types.rb +5 -0
  37. data/fixture_rails_root/config/initializers/reporter.rb +1 -0
  38. data/fixture_rails_root/config/initializers/secret_token.rb +7 -0
  39. data/fixture_rails_root/config/initializers/session_store.rb +2 -0
  40. data/fixture_rails_root/config/locales/en.yml +5 -0
  41. data/fixture_rails_root/config/routes.rb +3 -0
  42. data/fixture_rails_root/db/schema.rb +30 -0
  43. data/fixture_rails_root/db/seeds.rb +7 -0
  44. data/fixture_rails_root/doc/README_FOR_APP +2 -0
  45. data/fixture_rails_root/lib/tasks/.gitkeep +0 -0
  46. data/fixture_rails_root/public/404.html +26 -0
  47. data/fixture_rails_root/public/422.html +26 -0
  48. data/fixture_rails_root/public/500.html +26 -0
  49. data/fixture_rails_root/public/favicon.ico +0 -0
  50. data/fixture_rails_root/public/images/rails.png +0 -0
  51. data/fixture_rails_root/public/index.html +239 -0
  52. data/fixture_rails_root/public/javascripts/application.js +2 -0
  53. data/fixture_rails_root/public/javascripts/controls.js +965 -0
  54. data/fixture_rails_root/public/javascripts/dragdrop.js +974 -0
  55. data/fixture_rails_root/public/javascripts/effects.js +1123 -0
  56. data/fixture_rails_root/public/javascripts/prototype.js +6001 -0
  57. data/fixture_rails_root/public/javascripts/rails.js +175 -0
  58. data/fixture_rails_root/public/robots.txt +5 -0
  59. data/fixture_rails_root/public/stylesheets/.gitkeep +0 -0
  60. data/fixture_rails_root/script/rails +6 -0
  61. data/fixture_rails_root/test/performance/browsing_test.rb +9 -0
  62. data/fixture_rails_root/test/test_helper.rb +13 -0
  63. data/granular_permissions.gemspec +122 -0
  64. data/init.rb +1 -0
  65. data/install.rb +1 -0
  66. data/lib/flag_shih_tzu.rb +210 -0
  67. data/lib/generators/USAGE +8 -0
  68. data/lib/generators/granular_permissions_generator.rb +3 -0
  69. data/lib/granular_permissions.rb +3 -0
  70. data/spec/database.yml +4 -0
  71. data/spec/schema.rb +22 -0
  72. data/spec/spec_helper.rb +25 -0
  73. data/spec/support/blueprints.rb +13 -0
  74. data/spec/support/models.rb +3 -0
  75. data/uninstall.rb +1 -0
  76. metadata +161 -0
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_DISABLE_SHARED_GEMS: "1"
@@ -0,0 +1,8 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -0,0 +1,3 @@
1
+ *.swp
2
+ debug.log
3
+ *.db
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm ree@rails3
data/Gemfile ADDED
@@ -0,0 +1,29 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'bundler', '~> 1.0.0'
4
+ gem 'orm_adapter'
5
+ gem 'actionpack', '~> 3.0.0'
6
+ gem 'activesupport', '~> 3.0.0'
7
+ gem 'jeweler', '~> 1.4.0'
8
+ gem 'haml'
9
+ gem 'compass'
10
+ gem 'formtastic'
11
+ gem 'meta_search'
12
+ gem 'decent_exposure', '~> 1.0.0.rc1'
13
+
14
+ group :development, :test do
15
+ gem 'sqlite3-ruby', :require => 'sqlite3'
16
+ gem 'rspec'
17
+ gem 'rspec-core'
18
+ gem 'rspec-expectations'
19
+ gem 'rspec-mocks'
20
+ gem 'rspec-rails'
21
+ gem 'cucumber'
22
+ gem 'cucumber-rails'
23
+ gem 'nokogiri'
24
+ gem 'webrat'
25
+ gem 'capybara'
26
+ gem 'capybara-envjs'
27
+ gem 'ruby-debug'
28
+ gem 'machinist'
29
+ end
@@ -0,0 +1,161 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionpack (3.0.1)
6
+ activemodel (= 3.0.1)
7
+ activesupport (= 3.0.1)
8
+ builder (~> 2.1.2)
9
+ erubis (~> 2.6.6)
10
+ i18n (~> 0.4.1)
11
+ rack (~> 1.2.1)
12
+ rack-mount (~> 0.6.12)
13
+ rack-test (~> 0.5.4)
14
+ tzinfo (~> 0.3.23)
15
+ activemodel (3.0.1)
16
+ activesupport (= 3.0.1)
17
+ builder (~> 2.1.2)
18
+ i18n (~> 0.4.1)
19
+ activerecord (3.0.1)
20
+ activemodel (= 3.0.1)
21
+ activesupport (= 3.0.1)
22
+ arel (~> 1.0.0)
23
+ tzinfo (~> 0.3.23)
24
+ activesupport (3.0.1)
25
+ arel (1.0.1)
26
+ activesupport (~> 3.0.0)
27
+ builder (2.1.2)
28
+ capybara (0.4.0)
29
+ celerity (>= 0.7.9)
30
+ culerity (>= 0.2.4)
31
+ mime-types (>= 1.16)
32
+ nokogiri (>= 1.3.3)
33
+ rack (>= 1.0.0)
34
+ rack-test (>= 0.5.4)
35
+ selenium-webdriver (>= 0.0.27)
36
+ xpath (~> 0.1.2)
37
+ capybara-envjs (0.4.0)
38
+ capybara (~> 0.4.0)
39
+ envjs (>= 0.3.7)
40
+ celerity (0.8.2)
41
+ childprocess (0.1.3)
42
+ ffi (~> 0.6.3)
43
+ columnize (0.3.1)
44
+ compass (0.10.5)
45
+ haml (>= 3.0.4)
46
+ cucumber (0.9.3)
47
+ builder (~> 2.1.2)
48
+ diff-lcs (~> 1.1.2)
49
+ gherkin (~> 2.2.9)
50
+ json (~> 1.4.6)
51
+ term-ansicolor (~> 1.0.5)
52
+ cucumber-rails (0.3.2)
53
+ cucumber (>= 0.8.0)
54
+ culerity (0.2.12)
55
+ decent_exposure (1.0.0.rc1)
56
+ diff-lcs (1.1.2)
57
+ envjs (0.3.8)
58
+ johnson (>= 2.0.0.pre3)
59
+ erubis (2.6.6)
60
+ abstract (>= 1.0.0)
61
+ ffi (0.6.3)
62
+ rake (>= 0.8.7)
63
+ formtastic (1.1.0)
64
+ actionpack (>= 2.3.0)
65
+ activesupport (>= 2.3.0)
66
+ i18n (>= 0.4.0)
67
+ gemcutter (0.6.1)
68
+ gherkin (2.2.9)
69
+ json (~> 1.4.6)
70
+ term-ansicolor (~> 1.0.5)
71
+ git (1.2.5)
72
+ haml (3.0.22)
73
+ i18n (0.4.1)
74
+ jeweler (1.4.0)
75
+ gemcutter (>= 0.1.0)
76
+ git (>= 1.2.5)
77
+ rubyforge (>= 2.0.0)
78
+ johnson (2.0.0.pre3)
79
+ stackdeck (~> 0.2)
80
+ json (1.4.6)
81
+ json_pure (1.4.6)
82
+ linecache (0.43)
83
+ machinist (1.0.6)
84
+ meta_search (0.9.8)
85
+ actionpack (~> 3.0.0)
86
+ activerecord (~> 3.0.0)
87
+ activesupport (~> 3.0.0)
88
+ arel (~> 1.0.1)
89
+ mime-types (1.16)
90
+ nokogiri (1.4.3.1)
91
+ orm_adapter (0.0.3)
92
+ rack (1.2.1)
93
+ rack-mount (0.6.13)
94
+ rack (>= 1.0.0)
95
+ rack-test (0.5.6)
96
+ rack (>= 1.0)
97
+ rake (0.8.7)
98
+ rspec (2.0.1)
99
+ rspec-core (~> 2.0.1)
100
+ rspec-expectations (~> 2.0.1)
101
+ rspec-mocks (~> 2.0.1)
102
+ rspec-core (2.0.1)
103
+ rspec-expectations (2.0.1)
104
+ diff-lcs (>= 1.1.2)
105
+ rspec-mocks (2.0.1)
106
+ rspec-core (~> 2.0.1)
107
+ rspec-expectations (~> 2.0.1)
108
+ rspec-rails (2.0.1)
109
+ rspec (~> 2.0.0)
110
+ ruby-debug (0.10.3)
111
+ columnize (>= 0.1)
112
+ ruby-debug-base (~> 0.10.3.0)
113
+ ruby-debug-base (0.10.3)
114
+ linecache (>= 0.3)
115
+ rubyforge (2.0.4)
116
+ json_pure (>= 1.1.7)
117
+ rubyzip (0.9.4)
118
+ selenium-webdriver (0.0.29)
119
+ childprocess (>= 0.0.7)
120
+ ffi (~> 0.6.3)
121
+ json_pure
122
+ rubyzip
123
+ sqlite3-ruby (1.3.2)
124
+ stackdeck (0.2.0)
125
+ term-ansicolor (1.0.5)
126
+ tzinfo (0.3.23)
127
+ webrat (0.7.2)
128
+ nokogiri (>= 1.2.0)
129
+ rack (>= 1.0)
130
+ rack-test (>= 0.5.3)
131
+ xpath (0.1.2)
132
+ nokogiri (~> 1.3)
133
+
134
+ PLATFORMS
135
+ ruby
136
+
137
+ DEPENDENCIES
138
+ actionpack (~> 3.0.0)
139
+ activesupport (~> 3.0.0)
140
+ bundler (~> 1.0.0)
141
+ capybara
142
+ capybara-envjs
143
+ compass
144
+ cucumber
145
+ cucumber-rails
146
+ decent_exposure (~> 1.0.0.rc1)
147
+ formtastic
148
+ haml
149
+ jeweler (~> 1.4.0)
150
+ machinist
151
+ meta_search
152
+ nokogiri
153
+ orm_adapter
154
+ rspec
155
+ rspec-core
156
+ rspec-expectations
157
+ rspec-mocks
158
+ rspec-rails
159
+ ruby-debug
160
+ sqlite3-ruby
161
+ webrat
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 [name of plugin creator]
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 ADDED
@@ -0,0 +1,13 @@
1
+ GranularPermissions
2
+ ===================
3
+
4
+ Introduction goes here.
5
+
6
+
7
+ Example
8
+ =======
9
+
10
+ Example goes here.
11
+
12
+
13
+ Copyright (c) 2010 [name of plugin creator], released under the MIT license
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "granular_permissions"
8
+ gem.summary = %Q{engine that allows users to specify really tiny permissions levels}
9
+ gem.description= %Q{engine that allows users to specify really tiny permissions levels}
10
+ gem.email = "btelles@gmail.com"
11
+ gem.homepage = "http://github.com/btelles/granular_permissions"
12
+ gem.authors = ["Bernardo Telles"]
13
+ gem.add_development_dependency "rspec", "= 2.0.1"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ begin
22
+ require 'reek/adapters/rake_task'
23
+ Reek::RakeTask.new do |t|
24
+ t.fail_on_error = true
25
+ t.verbose = false
26
+ t.source_files = 'lib/**/*.rb'
27
+ end
28
+ rescue LoadError
29
+ task :reek do
30
+ abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
31
+ end
32
+ end
33
+
34
+ begin
35
+ require 'roodi'
36
+ require 'roodi_task'
37
+ RoodiTask.new do |t|
38
+ t.verbose = false
39
+ end
40
+ rescue LoadError
41
+ task :roodi do
42
+ abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
43
+ end
44
+ end
45
+
46
+ task :default => :spec
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "rep #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,5 @@
1
+ When /^(?:|I )click the dialog's Ok button?$/ do
2
+ with_scope('.ui-dialog') do
3
+ click_button("[@class='ui-button-text']")
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ {
2
+ 'in the title' => 'h1, h2, h3',
3
+ 'as a movie title in the results' => 'ol.movies h1',
4
+ 'in a button' => 'button, input[type=submit]',
5
+ 'in the navigation' => 'nav'
6
+ }.
7
+ each do |within, selector|
8
+ Then /^(.+) #{within}$/ do |step|
9
+ with_scope(selector) do
10
+ Then step
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,226 @@
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
+ require File.dirname(__FILE__) + '/mislav_steps'
19
+
20
+ Given /^(?:|I )am on (.+)$/ do |page_name|
21
+ visit path_to(page_name)
22
+ end
23
+
24
+ Given /^An? existing "([^"]*)" with "([^"]*)" "([^"]*)"/ do |model, property, value|
25
+ @current = instance_variable_set("@#{model}".to_sym, model.classify.constantize.make(property.to_sym => value))
26
+ end
27
+ Given /^with "([^"]*)" "(.*)"$/ do |property, value|
28
+ @current.update_attribute(property.to_sym, value)
29
+ end
30
+ When /^(?:|I )go to (.+)$/ do |page_name|
31
+ visit path_to(page_name)
32
+ end
33
+
34
+ When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
35
+ with_scope(selector) do
36
+ click_button(button)
37
+ end
38
+ end
39
+
40
+ When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
41
+ with_scope(selector) do
42
+ click_link(link)
43
+ end
44
+ end
45
+
46
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
47
+ with_scope(selector) do
48
+ fill_in(field, :with => value)
49
+ end
50
+ end
51
+
52
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
53
+ with_scope(selector) do
54
+ fill_in(field, :with => value)
55
+ end
56
+ end
57
+
58
+ # Use this to fill in an entire form with data from a table. Example:
59
+ #
60
+ # When I fill in the following:
61
+ # | Account Number | 5002 |
62
+ # | Expiry date | 2009-11-01 |
63
+ # | Note | Nice guy |
64
+ # | Wants Email? | |
65
+ #
66
+ # TODO: Add support for checkbox, select og option
67
+ # based on naming conventions.
68
+ #
69
+ When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
70
+ with_scope(selector) do
71
+ fields.rows_hash.each do |name, value|
72
+ When %{I fill in "#{name}" with "#{value}"}
73
+ end
74
+ end
75
+ end
76
+
77
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
78
+ with_scope(selector) do
79
+ select(value, :from => field)
80
+ end
81
+ end
82
+
83
+ When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
84
+ with_scope(selector) do
85
+ check(field)
86
+ end
87
+ end
88
+
89
+ When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
90
+ with_scope(selector) do
91
+ uncheck(field)
92
+ end
93
+ end
94
+
95
+ When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
96
+ with_scope(selector) do
97
+ choose(field)
98
+ end
99
+ end
100
+
101
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
102
+ with_scope(selector) do
103
+ attach_file(field, path)
104
+ end
105
+ end
106
+
107
+ Then /^(?:|I )should see JSON:$/ do |expected_json|
108
+ require 'json'
109
+ expected = JSON.pretty_generate(JSON.parse(expected_json))
110
+ actual = JSON.pretty_generate(JSON.parse(response.body))
111
+ expected.should == actual
112
+ end
113
+
114
+ Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
115
+ with_scope(selector) do
116
+ if page.respond_to? :should
117
+ page.should have_content(text)
118
+ else
119
+ assert page.has_content?(text)
120
+ end
121
+ end
122
+ end
123
+
124
+ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
125
+ regexp = Regexp.new(regexp)
126
+ with_scope(selector) do
127
+ if page.respond_to? :should
128
+ page.should have_xpath('//*', :text => regexp)
129
+ else
130
+ assert page.has_xpath?('//*', :text => regexp)
131
+ end
132
+ end
133
+ end
134
+
135
+ Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
136
+ with_scope(selector) do
137
+ if page.respond_to? :should
138
+ page.should have_no_content(text)
139
+ else
140
+ assert page.has_no_content?(text)
141
+ end
142
+ end
143
+ end
144
+
145
+ Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
146
+ regexp = Regexp.new(regexp)
147
+ with_scope(selector) do
148
+ if page.respond_to? :should
149
+ page.should have_no_xpath('//*', :text => regexp)
150
+ else
151
+ assert page.has_no_xpath?('//*', :text => regexp)
152
+ end
153
+ end
154
+ end
155
+
156
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
157
+ with_scope(selector) do
158
+ field = find_field(field)
159
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
160
+ if field_value.respond_to? :should
161
+ field_value.should =~ /#{value}/
162
+ else
163
+ assert_match(/#{value}/, field_value)
164
+ end
165
+ end
166
+ end
167
+
168
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
169
+ with_scope(selector) do
170
+ field = find_field(field)
171
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
172
+ if field_value.respond_to? :should_not
173
+ field_value.should_not =~ /#{value}/
174
+ else
175
+ assert_no_match(/#{value}/, field_value)
176
+ end
177
+ end
178
+ end
179
+
180
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
181
+ with_scope(selector) do
182
+ field_checked = find_field(label)['checked']
183
+ if field_checked.respond_to? :should
184
+ field_checked.should be_true
185
+ else
186
+ assert field_checked
187
+ end
188
+ end
189
+ end
190
+
191
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
192
+ with_scope(selector) do
193
+ field_checked = find_field(label)['checked']
194
+ if field_checked.respond_to? :should
195
+ field_checked.should be_false
196
+ else
197
+ assert !field_checked
198
+ end
199
+ end
200
+ end
201
+
202
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
203
+ current_path = URI.parse(current_url).path
204
+ if current_path.respond_to? :should
205
+ current_path.should == path_to(page_name)
206
+ else
207
+ assert_equal path_to(page_name), current_path
208
+ end
209
+ end
210
+
211
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
212
+ query = URI.parse(current_url).query
213
+ actual_params = query ? CGI.parse(query) : {}
214
+ expected_params = {}
215
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
216
+
217
+ if actual_params.respond_to? :should
218
+ actual_params.should == expected_params
219
+ else
220
+ assert_equal expected_params, actual_params
221
+ end
222
+ end
223
+
224
+ Then /^show me the page$/ do
225
+ save_and_open_page
226
+ end