Created
May 9, 2012 15:32
-
-
Save alext/2645573 to your computer and use it in GitHub Desktop.
Some path helpers for rspec request specs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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