surveyor 0.18.0 → 0.18.1

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 (40) hide show
  1. data/.gitignore +21 -4
  2. data/CHANGELOG +19 -0
  3. data/README.md +2 -3
  4. data/Rakefile +6 -93
  5. data/VERSION +1 -1
  6. data/ci-env.sh +29 -0
  7. data/features/step_definitions/surveyor_steps.rb +11 -1
  8. data/features/step_definitions/web_steps.rb +62 -54
  9. data/features/support/env.rb +40 -2
  10. data/features/support/paths.rb +12 -4
  11. data/features/surveyor.feature +34 -0
  12. data/generators/surveyor/surveyor_generator.rb +1 -1
  13. data/hudson.rakefile +33 -0
  14. data/init_testbed.rakefile +55 -0
  15. data/lib/surveyor/models/answer_methods.rb +9 -5
  16. data/lib/surveyor/models/dependency_condition_methods.rb +12 -7
  17. data/lib/surveyor/models/dependency_methods.rb +12 -7
  18. data/lib/surveyor/models/question_methods.rb +11 -6
  19. data/lib/surveyor/models/response_methods.rb +9 -4
  20. data/lib/surveyor/models/response_set_methods.rb +11 -6
  21. data/lib/surveyor/models/survey_methods.rb +9 -4
  22. data/lib/surveyor/models/survey_section_methods.rb +10 -5
  23. data/lib/surveyor/models/validation_condition_methods.rb +13 -8
  24. data/lib/surveyor/models/validation_methods.rb +11 -6
  25. data/lib/surveyor/parser.rb +7 -10
  26. data/lib/surveyor/redcap_parser.rb +2 -9
  27. data/lib/surveyor/unparser.rb +10 -9
  28. data/rails/init.rb +1 -0
  29. data/spec/rcov.opts +1 -1
  30. data/spec/spec_helper.rb +50 -15
  31. data/surveyor.gemspec +9 -54
  32. data/testbed/Gemfile +13 -0
  33. metadata +22 -99
  34. data/Gemfile +0 -17
  35. data/Gemfile.lock +0 -86
  36. data/init.rb +0 -1
  37. data/install.rb +0 -1
  38. data/spec/test_Gemfile +0 -15
  39. data/spec/test_boot.rb +0 -128
  40. data/spec/test_preinitializer.rb +0 -21
data/.gitignore CHANGED
@@ -1,8 +1,25 @@
1
- *.sw?
1
+ ## MAC OS
2
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
3
17
  coverage
4
18
  rdoc
5
19
  pkg
6
- spec/test_app/**
7
- .bundle
8
- surveys/fixtures/*.yml
20
+
21
+ ## PROJECT::SPECIFIC
22
+ testbed/log/*.log
23
+ testbed/db/*
24
+ testbed/.bundle
25
+ surveys/fixtures/*.yml
data/CHANGELOG CHANGED
@@ -1,3 +1,22 @@
1
+ 0.18.1
2
+
3
+ * group dependencies. closes #96
4
+ * fixing grid answers error with parser. closes #95
5
+ * prevent double inclusion of validations
6
+ * cleaner setup for hudson
7
+ * only resolve dependencies during redcap parsing
8
+ * forgot to uncomment
9
+ * fix hudson env setup
10
+ * setup hudson env after rails
11
+ * add hudson env to testbed init
12
+ * ci setup
13
+ * changing path for features files with new testbed
14
+ * don't double include model methods in unparser
15
+ * new testbed setup
16
+ * don't double include model methods in unparser
17
+ * don't double include model methods in redcap parser
18
+ * don't double include model methods
19
+
1
20
  0.18.0
2
21
 
3
22
  * finalizing redcap feature. parse dependencies. closes #93
data/README.md CHANGED
@@ -97,9 +97,8 @@ Surveyor depends on Ruby (1.8.7 - 1.9.1), Rails 2.3 and HAML/SASS http://haml.ha
97
97
 
98
98
  To work on the code fork this github project. Run:
99
99
 
100
- `bundler install`
101
- `rake testbed`
100
+ `rake -f init_testbed.rakefile`
102
101
 
103
- and start writing tests!
102
+ which will generate a test app in testbed. Run rake spec and rake cucumber there, and start writing tests!
104
103
 
105
104
  Copyright (c) 2008-2010 Brian Chamberlain and Mark Yoon, released under the MIT license
data/Rakefile CHANGED
@@ -11,106 +11,19 @@ begin
11
11
  gem.authors = ["Brian Chamberlain", "Mark Yoon"]
12
12
  gem.add_dependency 'haml'
13
13
  gem.add_dependency 'fastercsv'
14
+ gem.add_development_dependency "yard", ">= 0"
14
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
16
  end
16
17
  Jeweler::GemcutterTasks.new
17
-
18
18
  rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
20
  end
21
21
 
22
22
  begin
23
- require 'cucumber/rake/task'
24
- Cucumber::Rake::Task.new(:features)
25
-
26
- task :features => :check_dependencies
23
+ require 'yard'
24
+ YARD::Rake::YardocTask.new
27
25
  rescue LoadError
28
- task :features do
29
- abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
30
- end
31
- end
32
-
33
- desc "Set up a rails app for testing in the spec dir"
34
- task :testbed => [:"testbed:build_app", :"testbed:copy_files", :"testbed:install_surveyor"]
35
-
36
- namespace "testbed" do
37
- RAPPNAME = "test_app" #This is also hardcoded in the spec/spec_helper.rb and gitignore file. Change it there too...
38
-
39
- "Generate rails app in spec dir"
40
- task :build_app do
41
- directory "spec"
42
- chdir("spec") do
43
- sh "rails #{RAPPNAME}"
44
- puts "Put a test_app in the spec folder"
45
- chdir("#{RAPPNAME}") do
46
- sh "ruby script/generate rspec"
47
- puts "Ran installer for rspec in #{RAPPNAME}"
48
- sh "ruby script/generate cucumber --webrat"
49
- puts "Ran installer for cucumber in #{RAPPNAME}"
50
- end
51
- end
52
- end
53
-
54
- desc "Copy in setup files to test app"
55
- task :copy_files do
56
- chdir("spec/#{RAPPNAME}") do
57
- sh "cp ../test_Gemfile Gemfile"
58
- sh "cp ../test_preinitializer.rb config/preinitializer.rb"
59
- sh "cp ../test_boot.rb config/boot.rb"
60
- puts "NOTE: These files were created/modified as described here: http://gembundler.com/rails23.html"
61
- end
62
- end
63
-
64
- desc "Install surveyor in test app, run migrations, prep test db"
65
- task :install_surveyor do
66
- sh "gem install surveyor"
67
- chdir("spec/#{RAPPNAME}") do
68
- sh "bundle install"
69
- sh "bundle exec script/generate surveyor"
70
- sh "rake db:migrate"
71
- sh "rake db:test:prepare"
72
- end
73
- # I don't think this is needed anymore
74
- puts "NOTE: We installed the surveyor gem using 'gem install surveyor' to fix a problem where RVM (or bundler or both) don't let Rails see generators in a gem. ('script/generate surveyor' for example). To remove the gem run `gem uninstall surveyor` to remove the gem version of surveyor leaving the dev version" # Getting around a bug/problem in bundler. see: http://bit.ly/9NZOEz
75
- end
76
-
77
- desc "Remove rails test app from spec dir"
78
- task :remove do
79
- puts "Removing the test_app in the spec folder"
80
- sh "rm -rf spec/#{RAPPNAME}"
26
+ task :yardoc do
27
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
81
28
  end
82
- end # namespace
83
-
84
- require 'spec/rake/spectask'
85
- Spec::Rake::SpecTask.new(:spec) do |spec|
86
- spec.libs << 'lib' << 'spec'
87
- spec.spec_files = FileList.new('spec/**/*_spec.rb') do |fl|
88
- fl.exclude(/vendor\/plugins/) #excluding the stuff inthe embedded rails app
89
- fl.exclude(/unparse/) #not sure why but this breaks a bunch of specs
90
- end
91
- end
92
-
93
- Spec::Rake::SpecTask.new(:rcov) do |spec|
94
- spec.libs << 'lib' << 'spec'
95
- spec.pattern = 'spec/**/*_spec.rb'
96
- spec.rcov = true
97
29
  end
98
-
99
-
100
- task :default => :spec
101
-
102
- require 'rake/rdoctask'
103
- Rake::RDocTask.new do |rdoc|
104
- if File.exist?('VERSION.yml')
105
- config = YAML.load(File.read('VERSION.yml'))
106
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
107
- else
108
- version = ""
109
- end
110
-
111
- rdoc.rdoc_dir = 'rdoc'
112
- rdoc.title = "surveyor #{version}"
113
- rdoc.rdoc_files.include('README*')
114
- rdoc.rdoc_files.include('lib/**/*.rb')
115
- end
116
-
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.18.0
1
+ 0.18.1
data/ci-env.sh ADDED
@@ -0,0 +1,29 @@
1
+ ######
2
+ # This is not an executable script. It selects and configures rvm for
3
+ # bcsec's CI process based on the RVM_RUBY environment variable.
4
+ #
5
+ # Use it by sourcing it:
6
+ #
7
+ # . ci-env.sh
8
+ #
9
+ # Assumes that the create-on-use settings are set in your ~/.rvmrc:
10
+ #
11
+ # rvm_install_on_use_flag=1
12
+ # rvm_gemset_create_on_use_flag=1
13
+ #
14
+ # Hudson Build Execute Shell Commands:
15
+ #
16
+ # source ci-env.sh
17
+ # rake -f hudson.rakefile --trace
18
+ # cd testbed
19
+ # export RAILS_ENV="hudson"
20
+ # bundle exec rake spec cucumber
21
+
22
+ export rvm_gemset_create_on_use_flag=1
23
+ export rvm_project_rvmrc=0
24
+
25
+ set +xe
26
+ echo "Loading RVM ree@surveyor-dev"
27
+ source ~/.rvm/scripts/rvm
28
+ rvm use ree@surveyor-dev
29
+ set -xe
@@ -3,7 +3,7 @@ Given /^I parse$/ do |string|
3
3
  end
4
4
 
5
5
  Given /^I parse redcap file "([^"]*)"$/ do |name|
6
- Surveyor::RedcapParser.parse File.read(File.join(RAILS_ROOT, '..', '..', 'features', 'support', name)), name
6
+ Surveyor::RedcapParser.parse File.read(File.join(RAILS_ROOT, '..', 'features', 'support', name)), name
7
7
  end
8
8
 
9
9
  Then /^there should be (\d+) survey(?:s?) with:$/ do |x, table|
@@ -44,6 +44,16 @@ Then /^there should be (\d+) dependenc(?:y|ies) with:$/ do |x, table|
44
44
  end
45
45
  end
46
46
 
47
+ Then /^there should be (\d+) group dependenc(?:y|ies) with:$/ do |x, table|
48
+ Dependency.count(:conditions => ["question_group_id NOT NULL"]).should == x.to_i
49
+ table.hashes.each do |hash|
50
+ (d = Dependency.find(:first, :conditions => hash)).should_not be_nil
51
+ d.question_group_id.should_not be_nil
52
+ d.question_id.should be_nil
53
+ end
54
+ end
55
+
56
+
47
57
  Then /^there should be (\d+) resolved dependency_condition(?:s?) with:$/ do |x, table|
48
58
  DependencyCondition.count.should == x.to_i
49
59
  table.hashes.each do |hash|
@@ -6,6 +6,7 @@
6
6
 
7
7
 
8
8
  require 'uri'
9
+ require 'cgi'
9
10
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
10
11
 
11
12
  # Commonly used webrat steps
@@ -19,23 +20,23 @@ When /^(?:|I )go to (.+)$/ do |page_name|
19
20
  visit path_to(page_name)
20
21
  end
21
22
 
22
- When /^(?:|I )press "([^\"]*)"$/ do |button|
23
+ When /^(?:|I )press "([^"]*)"$/ do |button|
23
24
  click_button(button)
24
25
  end
25
26
 
26
- When /^(?:|I )follow "([^\"]*)"$/ do |link|
27
+ When /^(?:|I )follow "([^"]*)"$/ do |link|
27
28
  click_link(link)
28
29
  end
29
30
 
30
- When /^(?:|I )follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
31
+ When /^(?:|I )follow "([^"]*)" within "([^"]*)"$/ do |link, parent|
31
32
  click_link_within(parent, link)
32
33
  end
33
34
 
34
- When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
35
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
35
36
  fill_in(field, :with => value)
36
37
  end
37
38
 
38
- When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
39
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
39
40
  fill_in(field, :with => value)
40
41
  end
41
42
 
@@ -56,13 +57,13 @@ When /^(?:|I )fill in the following:$/ do |fields|
56
57
  end
57
58
  end
58
59
 
59
- When /^(?:|I )select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
60
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
60
61
  select(value, :from => field)
61
62
  end
62
63
 
63
64
  # Use this step in conjunction with Rail's datetime_select helper. For example:
64
65
  # When I select "December 25, 2008 10:00" as the date and time
65
- When /^(?:|I )select "([^\"]*)" as the date and time$/ do |time|
66
+ When /^(?:|I )select "([^"]*)" as the date and time$/ do |time|
66
67
  select_datetime(time)
67
68
  end
68
69
 
@@ -75,7 +76,7 @@ end
75
76
  # The following steps would fill out the form:
76
77
  # When I select "November 23, 2004 11:20" as the "Preferred" date and time
77
78
  # And I select "November 25, 2004 10:30" as the "Alternative" date and time
78
- When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
79
+ When /^(?:|I )select "([^"]*)" as the "([^"]*)" date and time$/ do |datetime, datetime_label|
79
80
  select_datetime(datetime, :from => datetime_label)
80
81
  end
81
82
 
@@ -83,46 +84,46 @@ end
83
84
  # When I select "2:20PM" as the time
84
85
  # Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
85
86
  # will convert the 2:20PM to 14:20 and then select it.
86
- When /^(?:|I )select "([^\"]*)" as the time$/ do |time|
87
+ When /^(?:|I )select "([^"]*)" as the time$/ do |time|
87
88
  select_time(time)
88
89
  end
89
90
 
90
91
  # Use this step when using multiple time_select helpers on a page or you want to
91
92
  # specify the name of the time on the form. For example:
92
93
  # When I select "7:30AM" as the "Gym" time
93
- When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
94
+ When /^(?:|I )select "([^"]*)" as the "([^"]*)" time$/ do |time, time_label|
94
95
  select_time(time, :from => time_label)
95
96
  end
96
97
 
97
98
  # Use this step in conjunction with Rail's date_select helper. For example:
98
99
  # When I select "February 20, 1981" as the date
99
- When /^(?:|I )select "([^\"]*)" as the date$/ do |date|
100
+ When /^(?:|I )select "([^"]*)" as the date$/ do |date|
100
101
  select_date(date)
101
102
  end
102
103
 
103
104
  # Use this step when using multiple date_select helpers on one page or
104
105
  # you want to specify the name of the date on the form. For example:
105
106
  # When I select "April 26, 1982" as the "Date of Birth" date
106
- When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
107
+ When /^(?:|I )select "([^"]*)" as the "([^"]*)" date$/ do |date, date_label|
107
108
  select_date(date, :from => date_label)
108
109
  end
109
110
 
110
- When /^(?:|I )check "([^\"]*)"$/ do |field|
111
+ When /^(?:|I )check "([^"]*)"$/ do |field|
111
112
  check(field)
112
113
  end
113
114
 
114
- When /^(?:|I )uncheck "([^\"]*)"$/ do |field|
115
+ When /^(?:|I )uncheck "([^"]*)"$/ do |field|
115
116
  uncheck(field)
116
117
  end
117
118
 
118
- When /^(?:|I )choose "([^\"]*)"$/ do |field|
119
+ When /^(?:|I )choose "([^"]*)"$/ do |field|
119
120
  choose(field)
120
121
  end
121
122
 
122
123
  # Adds support for validates_attachment_content_type. Without the mime-type getting
123
124
  # passed to attach_file() you will get a "Photo file is not one of the allowed file types."
124
125
  # error message
125
- When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"$/ do |path, field|
126
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
126
127
  type = path.split(".")[1]
127
128
 
128
129
  case type
@@ -139,17 +140,17 @@ When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"$/ do |path, field|
139
140
  attach_file(field, path, type)
140
141
  end
141
142
 
142
- Then /^(?:|I )should see "([^\"]*)"$/ do |text|
143
- if defined?(Spec::Rails::Matchers)
143
+ Then /^(?:|I )should see "([^"]*)"$/ do |text|
144
+ if response.respond_to? :should
144
145
  response.should contain(text)
145
146
  else
146
147
  assert_contain text
147
148
  end
148
149
  end
149
150
 
150
- Then /^(?:|I )should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
151
+ Then /^(?:|I )should see "([^"]*)" within "([^"]*)"$/ do |text, selector|
151
152
  within(selector) do |content|
152
- if defined?(Spec::Rails::Matchers)
153
+ if content.respond_to? :should
153
154
  content.should contain(text)
154
155
  else
155
156
  hc = Webrat::Matchers::HasContent.new(text)
@@ -160,17 +161,17 @@ end
160
161
 
161
162
  Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
162
163
  regexp = Regexp.new(regexp)
163
- if defined?(Spec::Rails::Matchers)
164
+ if response.respond_to? :should
164
165
  response.should contain(regexp)
165
166
  else
166
167
  assert_match(regexp, response_body)
167
168
  end
168
169
  end
169
170
 
170
- Then /^(?:|I )should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
171
+ Then /^(?:|I )should see \/([^\/]*)\/ within "([^"]*)"$/ do |regexp, selector|
171
172
  within(selector) do |content|
172
173
  regexp = Regexp.new(regexp)
173
- if defined?(Spec::Rails::Matchers)
174
+ if content.respond_to? :should
174
175
  content.should contain(regexp)
175
176
  else
176
177
  assert_match(regexp, content)
@@ -178,17 +179,17 @@ Then /^(?:|I )should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
178
179
  end
179
180
  end
180
181
 
181
- Then /^(?:|I )should not see "([^\"]*)"$/ do |text|
182
- if defined?(Spec::Rails::Matchers)
182
+ Then /^(?:|I )should not see "([^"]*)"$/ do |text|
183
+ if response.respond_to? :should_not
183
184
  response.should_not contain(text)
184
185
  else
185
186
  assert_not_contain(text)
186
187
  end
187
188
  end
188
189
 
189
- Then /^(?:|I )should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
190
+ Then /^(?:|I )should not see "([^"]*)" within "([^"]*)"$/ do |text, selector|
190
191
  within(selector) do |content|
191
- if defined?(Spec::Rails::Matchers)
192
+ if content.respond_to? :should_not
192
193
  content.should_not contain(text)
193
194
  else
194
195
  hc = Webrat::Matchers::HasContent.new(text)
@@ -199,17 +200,17 @@ end
199
200
 
200
201
  Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
201
202
  regexp = Regexp.new(regexp)
202
- if defined?(Spec::Rails::Matchers)
203
+ if response.respond_to? :should_not
203
204
  response.should_not contain(regexp)
204
205
  else
205
206
  assert_not_contain(regexp)
206
207
  end
207
208
  end
208
209
 
209
- Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
210
+ Then /^(?:|I )should not see \/([^\/]*)\/ within "([^"]*)"$/ do |regexp, selector|
210
211
  within(selector) do |content|
211
212
  regexp = Regexp.new(regexp)
212
- if defined?(Spec::Rails::Matchers)
213
+ if content.respond_to? :should_not
213
214
  content.should_not contain(regexp)
214
215
  else
215
216
  assert_no_match(regexp, content)
@@ -217,51 +218,58 @@ Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, select
217
218
  end
218
219
  end
219
220
 
220
- Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
221
- if defined?(Spec::Rails::Matchers)
222
- field_labeled(field).value.should =~ /#{value}/
221
+ Then /^the "([^"]*)" field should contain "([^"]*)"$/ do |field, value|
222
+ field_value = field_labeled(field).value
223
+ if field_value.respond_to? :should
224
+ field_value.should =~ /#{value}/
223
225
  else
224
- assert_match(/#{value}/, field_labeled(field).value)
226
+ assert_match(/#{value}/, field_value)
225
227
  end
226
228
  end
227
229
 
228
- Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
229
- if defined?(Spec::Rails::Matchers)
230
- field_labeled(field).value.should_not =~ /#{value}/
230
+ Then /^the "([^"]*)" field should not contain "([^"]*)"$/ do |field, value|
231
+ field_value = field_labeled(field).value
232
+ if field_value.respond_to? :should_not
233
+ field_value.should_not =~ /#{value}/
231
234
  else
232
- assert_no_match(/#{value}/, field_labeled(field).value)
235
+ assert_no_match(/#{value}/, field_value)
233
236
  end
234
237
  end
235
238
 
236
- Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
237
- if defined?(Spec::Rails::Matchers)
238
- field_labeled(label).should be_checked
239
+ Then /^the "([^"]*)" checkbox should be checked$/ do |label|
240
+ field = field_labeled(label)
241
+ if field.respond_to? :should
242
+ field.should be_checked
239
243
  else
240
- assert field_labeled(label).checked?
244
+ assert field.checked?
241
245
  end
242
246
  end
243
247
 
244
- Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
245
- if defined?(Spec::Rails::Matchers)
246
- field_labeled(label).should_not be_checked
248
+ Then /^the "([^"]*)" checkbox should not be checked$/ do |label|
249
+ field = field_labeled(label)
250
+ if field.respond_to? :should_not
251
+ field.should_not be_checked
247
252
  else
248
- assert !field_labeled(label).checked?
253
+ assert !field.checked?
249
254
  end
250
255
  end
251
256
 
252
257
  Then /^(?:|I )should be on (.+)$/ do |page_name|
253
- if defined?(Spec::Rails::Matchers)
254
- URI.parse(current_url).path.should == path_to(page_name)
258
+ current_path = URI.parse(current_url).path
259
+ if current_path.respond_to? :should
260
+ current_path.should == path_to(page_name)
255
261
  else
256
- assert_equal path_to(page_name), URI.parse(current_url).path
262
+ assert_equal path_to(page_name), current_path
257
263
  end
258
264
  end
259
265
 
260
266
  Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
261
- actual_params = CGI.parse(URI.parse(current_url).query)
262
- expected_params = Hash[expected_pairs.rows_hash.map{|k,v| [k,[v]]}]
263
-
264
- if defined?(Spec::Rails::Matchers)
267
+ query = URI.parse(current_url).query
268
+ actual_params = query ? CGI.parse(query) : {}
269
+ expected_params = {}
270
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
271
+
272
+ if actual_params.respond_to? :should
265
273
  actual_params.should == expected_params
266
274
  else
267
275
  assert_equal expected_params, actual_params
@@ -270,4 +278,4 @@ end
270
278
 
271
279
  Then /^show me the page$/ do
272
280
  save_and_open_page
273
- end
281
+ end