Based on your stack trace, the problem appears to originate from this line of code:
https://github.com/cinchrb/cinch/blob/v2.3.2/lib/cinch/bot.rb#L354 Notice that it is calling `super(nil, self)`. It's passing 2 arguments up to the superclass's `initialize` method but the superclass's definition does not accept any arguments, so Ruby is giving you an error, indicating 2 args were passed but 0 are accepted. That class is subclassing `User` (presumably, `Cinch::User`, given it is defined within the `Cinch` module). `Cinch::User` accepts a variable number of arguments: https://github.com/cinchrb/cinch/blob/v2.3.2/lib/cinch/user.rb#L190 <https://github.com/cinchrb/cinch/blob/v2.3.2/lib/cinch/user.rb#L190> So it's quite strange you're getting the error. My best guess is that `User` is perhaps being resolved to `::User` (e.g. your application's User class) instead of `Cinch::User`, but that should only happen if `Cinch::User` is not defined -- and it certainly is being required at the top of `cinch/bot.rb`. I don't think there's any way RSpec can directly be causing this, but there is probably something different about the environment the code is running in via RSpec vs IRB. You might be able to figure it out by printing `$LOAD_PATH` and `$LOADED_FEATURES` to see the differences in load path and what files have been loaded in the two environments. I'd also suggest you check with the maintainers of the cinch library. Something weird is going on in it. HTH, Myron On Sun, Jul 24, 2016 at 9:09 AM, Jonas Osborn <[email protected]> wrote: > Hi > I am very new to ruby and rspec so apologies if this is a stupid question, > but I'm trying to start using rspec and am getting an error that is > confusing me. I have a spec that fails on an ArgumentError, the confusing > thing for me is running the same thing in a interactive ruby shell or my > script doesn't give an ArgumentError. So while I would normally think this > was a problem with the gem I am using or how I am using it, the fact that I > was having no problems until I tried to use rspec is making me wonder if I > have missed something about rspec. Anyway here is my spec file: > require "cinch" > > describe "Cinchbot" do > it "why does this not work" do > > Failure/Error: Cinch::Bot.new > > ArgumentError: > wrong number of arguments (2 for 0) > # > /usr/local/rvm/gems/ruby-2.2.4/gems/cinch-2.3.2/lib/cinch/bot.rb:354:in > `initialize' > # > /usr/local/rvm/gems/ruby-2.2.4/gems/cinch-2.3.2/lib/cinch/bot.rb:354:in > `initialize' > # ./spec/bot/bot_spec.rb:5:in `new' > # ./spec/bot/bot_spec.rb:5:in `block (2 levels) in <top (required)>' > > -- > You received this message because you are subscribed to the Google Groups > "rspec" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rspec/913967f7-9e85-4087-a393-e2a4d1cf397c%40googlegroups.com > <https://groups.google.com/d/msgid/rspec/913967f7-9e85-4087-a393-e2a4d1cf397c%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "rspec" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/CADUxQmvTdEw3KqmPprcdSVXTupZ9fd%3Dne4mUOYja%2Bo6HuTY3SQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
