Permalink
Browse files

Fixed Cucumber's step for Ruby 1.8.*.

  • Loading branch information...
baldowl committed Jul 15, 2012
1 parent 977d099 commit 6d936b1cbd3ab0b381590e84b2ce0c1edbed04f6
Showing with 11 additions and 7 deletions.
  1. +11 −7 features/step_definitions/setup_steps.rb
@@ -80,7 +80,8 @@
end
When /^I insert the anti\-CSRF middleware with the :skip_if option$/ do |table|
- skippable = table.hashes.collect {|t| t.values}
+ skippable = {}
+ table.hashes.each {|row| skippable[row['name']] = row['value']}
@rack_builder.use Rack:: Csrf, :skip_if => Proc.new { |request|
skippable.any? { |name, value| request.env[name] == value }
}
@@ -89,12 +90,15 @@
end
When /^I insert the anti\-CSRF middleware with the :skip and :skip_if options$/ do |table|
- data = table.hashes.collect {|t| t.values}[0]
- headers = data[0..1]
- skippable = data[2]
-
- @rack_builder.use Rack:: Csrf, :skip => [skippable], :skip_if => Proc.new { |request|
- skippable.any? { |name, value| request.env[name] == value }
+ skip_option_arguments = []
+ skip_if_option_arguments = {}
+ table.hashes.each do |row|
+ skip_option_arguments << row['path']
+ skip_if_option_arguments[row['name']] = row['value']
+ end
+
+ @rack_builder.use Rack:: Csrf, :skip => skip_option_arguments, :skip_if => Proc.new { |request|
+ skip_if_option_arguments.any? { |name, value| request.env[name] == value }
}
@app = toy_app
@browser = Rack::Test::Session.new(Rack::MockSession.new(@app))

0 comments on commit 6d936b1

Please sign in to comment.