kimjunh/giver-game

View on GitHub
features/step_definitions/game_steps.rb

Summary

Maintainability
A
0 mins
Test Coverage

Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
Open

Then /^I should see the image "(.+)"$/ do |image|

This cop checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.

Example:

# bad

# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

Example:

# good

# With parentheses, there's no ambiguity.
do_something(/pattern/i)

Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
Open

When /^I fill out the form$/ do

This cop checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.

Example:

# bad

# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

Example:

# good

# With parentheses, there's no ambiguity.
do_something(/pattern/i)

Line is too long. [97/80]
Open

    And I fill in "DescriptionA" with "Provides money directly to groups of impoverished people."

Use % instead of %Q.
Open

  steps %Q{

This cop checks if usage of %() or %Q() matches configuration.

Example: EnforcedStyle: bare_percent (default)

# bad
%Q(He said: "#{greeting}")
%q{She said: 'Hi'}

# good
%(He said: "#{greeting}")
%{She said: 'Hi'}

Example: EnforcedStyle: percent_q

# bad
%|He said: "#{greeting}"|
%/She said: 'Hi'/

# good
%Q|He said: "#{greeting}"|
%q/She said: 'Hi'/

Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
Open

When /^I fill out the form with a second game$/ do

This cop checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.

Example:

# bad

# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

Example:

# good

# With parentheses, there's no ambiguity.
do_something(/pattern/i)

Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
Open

When /^I upload an image to the form$/ do

This cop checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.

Example:

# bad

# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

Example:

# good

# With parentheses, there's no ambiguity.
do_something(/pattern/i)

%Q-literals should be delimited by ( and ).
Open

  steps %Q{
    And I fill in "Title" with "First Game"
    And I fill in "Description" with "Descriptive description to describe"
    And I fill in "TotalMoney" with "1000"
    And I fill in "AmountPerVote" with "10"

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Line is too long. [85/80]
Open

  attach_file("CharityA-Image", File.absolute_path("features/upload-files/#{image}"))

Use the new Ruby 1.9 hash syntax.
Open

  GivingGame.where(:title => game).first.show_results.should == false

This cop checks hash literal syntax.

It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

A separate offense is registered for each problematic pair.

The supported styles are:

  • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
  • hash_rockets - forces use of hash rockets for all hashes
  • nomixedkeys - simply checks for hashes with mixed syntaxes
  • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

Example: EnforcedStyle: ruby19 (default)

# bad
{:a => 2}
{b: 1, :c => 2}

# good
{a: 2, b: 1}
{:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
{d: 1, 'e' => 2} # technically not forbidden

Example: EnforcedStyle: hash_rockets

# bad
{a: 1, b: 2}
{c: 1, 'd' => 5}

# good
{:a => 1, :b => 2}

Example: EnforcedStyle: nomixedkeys

# bad
{:a => 1, b: 2}
{c: 1, 'd' => 2}

# good
{:a => 1, :b => 2}
{c: 1, d: 2}

Example: EnforcedStyle: ruby19nomixed_keys

# bad
{:a => 1, :b => 2}
{c: 2, 'd' => 3} # should just use hash rockets

# good
{a: 1, b: 2}
{:c => 3, 'd' => 4}

%Q-literals should be delimited by ( and ).
Open

  steps %Q{
    When I fill out the form
    And I fill in "TotalMoney" with "-1000"
    And I fill in "AmountPerVote" with "-10"
  }

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Use 2 (not 3) spaces for indentation.
Open

   expect(page).to have_xpath("//img[contains(@src,'#{image}')]")

This cops checks for indentation that doesn't use the specified number of spaces.

See also the IndentationConsistency cop which is the companion to this one.

Example:

# bad
class A
 def test
  puts 'hello'
 end
end

# good
class A
  def test
    puts 'hello'
  end
end

Example: IgnoredPatterns: ['^\s*module']

# bad
module A
class B
  def test
  puts 'hello'
  end
end
end

# good
module A
class B
  def test
    puts 'hello'
  end
end
end

Trailing whitespace detected.
Open

end    

Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
Open

When /^I fill out the form without descriptions$/ do

This cop checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.

Example:

# bad

# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

Example:

# good

# With parentheses, there's no ambiguity.
do_something(/pattern/i)

Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
Open

And /^The game "(.*)" should be able to show results$/ do |game|

This cop checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.

Example:

# bad

# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

Example:

# good

# With parentheses, there's no ambiguity.
do_something(/pattern/i)

Line is too long. [88/80]
Open

  attach_file(:png_file, File.join(Rails.root, 'features', 'upload-files', 'img_1.png'))

Use % instead of %Q.
Open

  steps %Q{

This cop checks if usage of %() or %Q() matches configuration.

Example: EnforcedStyle: bare_percent (default)

# bad
%Q(He said: "#{greeting}")
%q{She said: 'Hi'}

# good
%(He said: "#{greeting}")
%{She said: 'Hi'}

Example: EnforcedStyle: percent_q

# bad
%|He said: "#{greeting}"|
%/She said: 'Hi'/

# good
%Q|He said: "#{greeting}"|
%q/She said: 'Hi'/

%Q-literals should be delimited by ( and ).
Open

  steps %Q{
    And I fill in "Title" with "First Game"
    And I fill in "Description" with "Descriptive description to describe"
    And I fill in "TotalMoney" with "1000"
    And I fill in "AmountPerVote" with "10"

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Trailing whitespace detected.
Open

  

Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
Open

Then /^I should see "(.*)" in my table$/ do |game|

This cop checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.

Example:

# bad

# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

Example:

# good

# With parentheses, there's no ambiguity.
do_something(/pattern/i)

Line is too long. [93/80]
Open

    And I fill in "DescriptionA" with "Provides money to Syrians displaced by the civil war."

Use %Q only for strings that contain both single quotes and double quotes, or for dynamic strings that contain double quotes.
Open

  steps %Q{
    When I fill out the form
    And I fill in "TotalMoney" with "-1000"
    And I fill in "AmountPerVote" with "-10"
  }

Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
Open

And /^The game "(.*)" should not be able to show results$/ do |game|

This cop checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.

Example:

# bad

# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

Example:

# good

# With parentheses, there's no ambiguity.
do_something(/pattern/i)

Use % instead of %Q.
Open

  steps %Q{

This cop checks if usage of %() or %Q() matches configuration.

Example: EnforcedStyle: bare_percent (default)

# bad
%Q(He said: "#{greeting}")
%q{She said: 'Hi'}

# good
%(He said: "#{greeting}")
%{She said: 'Hi'}

Example: EnforcedStyle: percent_q

# bad
%|He said: "#{greeting}"|
%/She said: 'Hi'/

# good
%Q|He said: "#{greeting}"|
%q/She said: 'Hi'/

Use the new Ruby 1.9 hash syntax.
Open

  GivingGame.where(:title => game).first.show_results.should == true

This cop checks hash literal syntax.

It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

A separate offense is registered for each problematic pair.

The supported styles are:

  • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
  • hash_rockets - forces use of hash rockets for all hashes
  • nomixedkeys - simply checks for hashes with mixed syntaxes
  • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

Example: EnforcedStyle: ruby19 (default)

# bad
{:a => 2}
{b: 1, :c => 2}

# good
{a: 2, b: 1}
{:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
{d: 1, 'e' => 2} # technically not forbidden

Example: EnforcedStyle: hash_rockets

# bad
{a: 1, b: 2}
{c: 1, 'd' => 5}

# good
{:a => 1, :b => 2}

Example: EnforcedStyle: nomixedkeys

# bad
{:a => 1, b: 2}
{c: 1, 'd' => 2}

# good
{:a => 1, :b => 2}
{c: 1, d: 2}

Example: EnforcedStyle: ruby19nomixed_keys

# bad
{:a => 1, :b => 2}
{c: 2, 'd' => 3} # should just use hash rockets

# good
{a: 1, b: 2}
{:c => 3, 'd' => 4}

Use %Q only for strings that contain both single quotes and double quotes, or for dynamic strings that contain double quotes.
Open

  steps %Q{
    And I fill in "Title" with ""
    And I fill in "Description" with ""
    And I fill in "TotalMoney" with ""
    And I fill in "AmountPerVote" with ""

Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
Open

When /^I follow "(.*)" in my table$/ do |game|

This cop checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.

Example:

# bad

# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

Example:

# good

# With parentheses, there's no ambiguity.
do_something(/pattern/i)

Use % instead of %Q.
Open

  steps %Q{

This cop checks if usage of %() or %Q() matches configuration.

Example: EnforcedStyle: bare_percent (default)

# bad
%Q(He said: "#{greeting}")
%q{She said: 'Hi'}

# good
%(He said: "#{greeting}")
%{She said: 'Hi'}

Example: EnforcedStyle: percent_q

# bad
%|He said: "#{greeting}"|
%/She said: 'Hi'/

# good
%Q|He said: "#{greeting}"|
%q/She said: 'Hi'/

%Q-literals should be delimited by ( and ).
Open

  steps %Q{
    And I fill in "Title" with ""
    And I fill in "Description" with ""
    And I fill in "TotalMoney" with ""
    And I fill in "AmountPerVote" with ""

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Use %Q only for strings that contain both single quotes and double quotes, or for dynamic strings that contain double quotes.
Open

  steps %Q{
    And I fill in "Title" with "New Game"
    And I fill in "Description" with "Descriptive description to describe"
    And I fill in "TotalMoney" with "100"
    And I fill in "AmountPerVote" with "10"

Use %Q only for strings that contain both single quotes and double quotes, or for dynamic strings that contain double quotes.
Open

  steps %Q{
    And I fill in "Title" with "First Game"
    And I fill in "Description" with "Descriptive description to describe"
    And I fill in "TotalMoney" with "1000"
    And I fill in "AmountPerVote" with "10"

%Q-literals should be delimited by ( and ).
Open

  steps %Q{
    And I fill in "Title" with "New Game"
    And I fill in "Description" with "Descriptive description to describe"
    And I fill in "TotalMoney" with "100"
    And I fill in "AmountPerVote" with "10"

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

  click_button "Attach image"

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
Open

When /^I fill out the form with negative numbers$/ do

This cop checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.

Example:

# bad

# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

Example:

# good

# With parentheses, there's no ambiguity.
do_something(/pattern/i)

Line is too long. [110/80]
Open

    And I fill in "DescriptionB" with "Donates directly to people leaving America because of Trump's policies"

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

  attach_file("CharityA-Image", File.absolute_path("features/upload-files/#{image}"))

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Final newline missing.
Open

end

Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
Open

When /^the form is blank$/ do

This cop checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.

Example:

# bad

# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

Example:

# good

# With parentheses, there's no ambiguity.
do_something(/pattern/i)

Line is too long. [94/80]
Open

Then(/^I should see: "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)"$/) do |arg1, arg2, arg3, arg4|

Use % instead of %Q.
Open

  steps %Q{

This cop checks if usage of %() or %Q() matches configuration.

Example: EnforcedStyle: bare_percent (default)

# bad
%Q(He said: "#{greeting}")
%q{She said: 'Hi'}

# good
%(He said: "#{greeting}")
%{She said: 'Hi'}

Example: EnforcedStyle: percent_q

# bad
%|He said: "#{greeting}"|
%/She said: 'Hi'/

# good
%Q|He said: "#{greeting}"|
%q/She said: 'Hi'/

There are no issues that match your filters.

Category
Status