Skip to content

Instantly share code, notes, and snippets.

@alext
Created May 9, 2012 15:32
Show Gist options
  • Save alext/2645573 to your computer and use it in GitHub Desktop.
Save alext/2645573 to your computer and use it in GitHub Desktop.
Some path helpers for rspec request specs.
module PathHelpers
# Takes a URL path (with optional query string), and asserts that it matches the current URL.
def i_should_be_on(path_with_query, options = {})
expected = URI.parse(path_with_query)
current = URI.parse(current_url)
current.path.should == expected.path
unless options[:ignore_query]
Rack::Utils.parse_query(current.query).should == Rack::Utils.parse_query(expected.query)
end
end
end
RSpec.configuration.include PathHelpers, :type => :request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment