Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison of Array with Array failed for marks and text #1108

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

TeresaP
Copy link
Contributor

@TeresaP TeresaP commented Jun 17, 2016

When I called marks and text on my app, I got:

irb(main):001:0> marks
ArgumentError: comparison of Array with Array failed
    from /Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.19.1/lib/calabash-cucumber/console_helpers.rb:41:in `sort'
    from /Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.19.1/lib/calabash-cucumber/console_helpers.rb:41:in `marks'
    from (irb):1
    from /usr/bin/irb:12:in `<main>'
irb(main):002:0> text
ArgumentError: comparison of Array with Array failed
    from /Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.19.1/lib/calabash-cucumber/console_helpers.rb:158:in `sort'
    from /Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.19.1/lib/calabash-cucumber/console_helpers.rb:158:in `print_marks'
    from /Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.19.1/lib/calabash-cucumber/console_helpers.rb:223:in `text_marks'
    from /Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.19.1/lib/calabash-cucumber/console_helpers.rb:25:in `text'
    from (irb):2
    from /usr/bin/irb:12:in `<main>'

When I called `marks` and `text` on my app, I got:

```irb(main):001:0> marks
ArgumentError: comparison of Array with Array failed
	from /Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.19.1/lib/calabash-cucumber/console_helpers.rb:41:in `sort'
	from /Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.19.1/lib/calabash-cucumber/console_helpers.rb:41:in `marks'
	from (irb):1
	from /usr/bin/irb:12:in `<main>'
```
```irb(main):002:0> text
ArgumentError: comparison of Array with Array failed
	from /Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.19.1/lib/calabash-cucumber/console_helpers.rb:158:in `sort'
	from /Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.19.1/lib/calabash-cucumber/console_helpers.rb:158:in `print_marks'
	from /Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.19.1/lib/calabash-cucumber/console_helpers.rb:223:in `text_marks'
	from /Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.19.1/lib/calabash-cucumber/console_helpers.rb:25:in `text'
	from (irb):2
	from /usr/bin/irb:12:in `<main>'
```
@jmoody
Copy link
Contributor

jmoody commented Jun 17, 2016

@TeresaP The unit tests are failing.

$ be rspec spec/lib/console_helpers_spec.rb

@TeresaP
Copy link
Contributor Author

TeresaP commented Jun 17, 2016

Thanks @jmoody. I think the original method is choking because some of the array values are nil, like this:

screen shot 2016-06-17 at 9 58 38 am

What's another way we can solve this?

@jmoody
Copy link
Contributor

jmoody commented Jun 17, 2016

On the array with nils - call compact which will remove nils.

@TeresaP
Copy link
Contributor Author

TeresaP commented Jun 17, 2016

@jmoody I think that causes a problem because sometimes we would end up with 2-element arrays and sometimes we would end up with 3-element arrays. Substituting empty strings for nil values seems to work though.

Replace nil elements with empty string for marks and print_marks
@jmoody
Copy link
Contributor

jmoody commented Jun 18, 2016

@TeresaP Don't be afraid to update the tests if you think the behavior can be improved.

# Replace nil elements with empty string to avoid "ArgumentError: comparison of Array with Array failed" error
marks.each { |elm|
elm.map! {|e| e ? e : ''}
}
marks.sort_by.each { |elm|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you replace at this line sort_by with 'sort'?
I think this is the root cause for failing tests ;)

@ark-konopacki
Copy link
Contributor

ark-konopacki commented Aug 9, 2016

@TeresaP please take a look on my comment i think i find why tests failing.
You can check tests locally with rspec spec/lib/console_helpers_spec.rb

@TeresaP
Copy link
Contributor Author

TeresaP commented Aug 9, 2016

@ark-konopacki thanks for taking a look :). I will have to give that a shot!

@jmoody
Copy link
Contributor

jmoody commented Sep 30, 2016

@TeresaP I want to get this merged. Can you provide me a way to reproduce?

@jmoody
Copy link
Contributor

jmoody commented Oct 6, 2016

I reproduced!!!!

@ark-konopacki
Copy link
Contributor

@jmoody the only one issue with this PR is failing tests
please take a look at my previous comments it really easy to fix, but i cannot modify code at this PR ;)

@ark-konopacki
Copy link
Contributor

@TeresaP @jmoody it can be really usefull to have this merged.
Teresa if you don't have time to fix it just give me know i'll create new PR and we can close yours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants