Skip to content

Commit 103fb94

Browse files
committed
Extract be_at_url to a new file
1 parent 2b300ed commit 103fb94

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

tests/spec/features/navigation_spec.rb

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
require 'spec_helper'
22
require 'support/editor'
3+
require 'support/matchers/be_at_url'
34
require 'support/playground_actions'
45

56
RSpec.feature "Navigating between pages", type: :feature, js: true do
67
include PlaygroundActions
78

8-
RSpec::Matchers.define :be_at_url do |path, query = {}|
9-
match do |page|
10-
uri = URI::parse(page.current_url)
11-
expect(uri.path).to eql(path)
12-
13-
query = query.map { |k, v| [k.to_s, Array(v).map(&:to_s)] }.to_h
14-
query_hash = CGI::parse(uri.query || '')
15-
expect(query_hash).to include(query)
16-
end
17-
18-
failure_message do |page|
19-
"expected that #{page.current_url} would be #{path} with the query parameters #{query}"
20-
end
21-
end
22-
239
# This is kind of a test of the router library too, so if that ever
2410
# gets extracted, a chunk of these tests can be removed.
2511

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
RSpec::Matchers.define :be_at_url do |path, query = {}|
2+
match do |page|
3+
uri = URI::parse(page.current_url)
4+
expect(uri.path).to eql(path)
5+
6+
query = query.map { |k, v| [k.to_s, Array(v).map(&:to_s)] }.to_h
7+
query_hash = CGI::parse(uri.query || '')
8+
expect(query_hash).to include(query)
9+
end
10+
11+
failure_message do |page|
12+
"expected that #{page.current_url} would be #{path} with the query parameters #{query}"
13+
end
14+
end

0 commit comments

Comments
 (0)