Skip to content

Commit

Permalink
Change assertions depending on version of grape.
Browse files Browse the repository at this point in the history
  • Loading branch information
kakubin committed Aug 3, 2024
1 parent 4a9889b commit ad773c3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-07-25 11:34:20 UTC using RuboCop version 1.65.0.
# on 2024-08-03 08:32:56 UTC using RuboCop version 1.65.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -71,7 +71,7 @@ RSpec/DescribedClass:
# Offense count: 6
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 8
Max: 12

# Offense count: 2
# Configuration parameters: AssignmentOnly.
Expand All @@ -81,7 +81,7 @@ RSpec/InstanceVariable:

# Offense count: 12
RSpec/MultipleExpectations:
Max: 4
Max: 6

# Offense count: 2
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
Expand Down
33 changes: 27 additions & 6 deletions spec/features/swagger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,26 @@
find_by_id('endpointListTogger_headers', visible: true).click
first('span[class="http_method"] a', visible: true).click
click_button 'Try it out!'
expect(page).to have_css 'span.hljs-attr', text: 'X-Test-Header'
if Gem::Version.new(Grape::VERSION) >= Gem::Version.new('2.0.0')
expect(page).to have_css 'span.hljs-attr', text: 'x-test-header'
else
expect(page).to have_css 'span.hljs-attr', text: 'X-Test-Header'
end
expect(page).to have_css 'span.hljs-string', text: 'Test Value'
end

it 'supports multiple headers' do
find_by_id('endpointListTogger_headers', visible: true).click
first('span[class="http_method"] a', visible: true).click
click_button 'Try it out!'
expect(page).to have_css 'span.hljs-attr', text: 'X-Test-Header'
if Gem::Version.new(Grape::VERSION) >= Gem::Version.new('2.0.0')
expect(page).to have_css 'span.hljs-attr', text: 'x-test-header'
expect(page).to have_css 'span.hljs-attr', text: 'x-another-header'
else
expect(page).to have_css 'span.hljs-attr', text: 'X-Test-Header'
expect(page).to have_css 'span.hljs-attr', text: 'X-Another-Header'
end
expect(page).to have_css 'span.hljs-string', text: 'Test Value'
expect(page).to have_css 'span.hljs-attr', text: 'X-Another-Header'
expect(page).to have_css 'span.hljs-string', text: 'Another Value'
end
end
Expand Down Expand Up @@ -108,7 +117,11 @@
find_by_id('endpointListTogger_headers', visible: true).click
first('span[class="http_method"] a', visible: true).click
click_button 'Try it out!'
expect(page).to have_css 'span.hljs-attr', text: 'Authorization'
if Gem::Version.new(Grape::VERSION) >= Gem::Version.new('2.0.0')
expect(page).to have_css 'span.hljs-attr', text: 'authorization'
else
expect(page).to have_css 'span.hljs-attr', text: 'Authorization'
end
expect(page).to have_css 'span.hljs-string', text: "Basic #{Base64.encode64('username:password').strip}"
end
end
Expand All @@ -127,7 +140,11 @@
find_by_id('endpointListTogger_headers', visible: true).click
first('span[class="http_method"] a', visible: true).click
click_button 'Try it out!'
expect(page).to have_css 'span.hljs-attr', text: 'Authorization'
if Gem::Version.new(Grape::VERSION) >= Gem::Version.new('2.0.0')
expect(page).to have_css 'span.hljs-attr', text: 'authorization'
else
expect(page).to have_css 'span.hljs-attr', text: 'Authorization'
end
expect(page).to have_css 'span.hljs-string', text: 'Bearer token'
end
end
Expand All @@ -146,7 +163,11 @@
find_by_id('endpointListTogger_headers', visible: true).click
first('span[class="http_method"] a', visible: true).click
click_button 'Try it out!'
expect(page).to have_css 'span.hljs-attr', text: 'Authorization'
if Gem::Version.new(Grape::VERSION) >= Gem::Version.new('2.0.0')
expect(page).to have_css 'span.hljs-attr', text: 'authorization'
else
expect(page).to have_css 'span.hljs-attr', text: 'Authorization'
end
expect(page).to have_css 'span.hljs-string', text: 'Token token'
end
end
Expand Down

0 comments on commit ad773c3

Please sign in to comment.