Forum: RSpec rspec and should eql

78e7109f5fd74ae07678541288f0a417?d=identicon&s=25 slavix tube (slavix)
on 2011-09-06 03:13
(Received via mailing list)
Having troubles with rspec and should eql.. in a rails 3.1 app

spec has this
  User.first.name.should eql('admin')

get this error
.rvm/gems/ruby-1.9.2-p290/gems/remarkable-4.0.0.alpha4/lib/remarkable/
core/macros.rb:15:in `method_missing': undefined method `eql' for
#<Class:0xf51ab30> (NoMethodError)


btw, I am using

  gem "rspec"
  gem "rspec-rails"
  gem "remarkable_activerecord", "~> 4.0.0.alpha4"
  gem 'rspec-rails-ext'
  gem 'rspec-rails-matchers'
  gem "cucumber-rails"
  gem "webrat"
  gem "capybara"
  gem "mocha"
  gem "rcov"
  gem "faker"
  gem "shoulda-matchers"
49de4cd2f26705785cbef2b15a9df7aa?d=identicon&s=25 Nick Hoffman (nickh)
on 2011-09-06 05:17
(Received via mailing list)
Try "eq" or "equal".
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2011-09-06 06:07
(Received via mailing list)
On Sep 5, 2011, at 8:10 PM, slavix wrote:

> Having troubles with rspec and should eql.. in a rails 3.1 app
>
> spec has this
>  User.first.name.should eql('admin')
>
> get this error
> .rvm/gems/ruby-1.9.2-p290/gems/remarkable-4.0.0.alpha4/lib/remarkable/
> core/macros.rb:15:in `method_missing': undefined method `eql' for
> #<Class:0xf51ab30> (NoMethodError)

Please post the example that is failing and the full error message.
78e7109f5fd74ae07678541288f0a417?d=identicon&s=25 slavix tube (slavix)
on 2011-09-06 06:22
(Received via mailing list)
thanks. tried both with same result.
btw documentation says to use eql

  5.should eql(5)
http://rspec.rubyforge.org/rspec/1.1.9/classes/Spe...
78e7109f5fd74ae07678541288f0a417?d=identicon&s=25 slavix tube (slavix)
on 2011-09-06 07:13
(Received via mailing list)
Here is another example that is failing due to same problem..

class Currency < ActiveRecord::Base
end

class Bitcoin < Currency
  include ActiveRecord::Singleton
  default_scope where(:char_code => 'BTC')
end


spec:
describe Bitcoin do
..
  Bitcoin.instance.char_code.should eql('BTC')
..
end

error:
/home/slava/.rvm/gems/ruby-1.9.2-p290/gems/remarkable-4.0.0.alpha4/lib/
remarkable/core/macros.rb:15:in `method_missing': undefined method
`eql' for #<Class:0xe314990> (NoMethodError)
  from /home/slava/dev/projects/bitcoin-derivatives/spec/models/
bitcoin_spec.rb:4:in `block in <top (required)>'
  from /home/slava/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/
rspec/core/example_group.rb:142:in `module_eval'
  from /home/slava/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/
rspec/core/example_group.rb:142:in `subclass'
  from /home/slava/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/
rspec/core/example_group.rb:129:in `describe'
  from /home/slava/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/
rspec/core/dsl.rb:5:in `describe'
  from /home/slava/dev/projects/bitcoin-derivatives/spec/models/
bitcoin_spec.rb:3:in `<top (required)>'
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2011-09-06 12:57
(Received via mailing list)
On Sep 5, 2011, at 11:27 PM, slavix wrote:

>
> spec:
> describe Bitcoin do
> ..
>  Bitcoin.instance.char_code.should eql('BTC')

The describe() method creates an example group, and the it() method
creates an example. This ^^ line needs to be in an example:

describe Bitcoin do
  it "defaults to BTC for char_code" do
    Bitcoin.instance.char_code.should eq('BTC')
  end
end

re: whether to use eq, eql, or equal, see
http://relishapp.com/rspec/rspec-expectations/docs...

HTH,
David
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2011-09-06 14:09
(Received via mailing list)
On Sep 5, 2011, at 9:34 PM, slavix wrote:

> thanks. tried both with same result.
> btw documentation says to use eql
>
>  5.should eql(5)
> http://rspec.rubyforge.org/rspec/1.1.9/classes/Spe...

This is not why you're having trouble, but rspec-1.1.9 is nearly three
years old: http://rubygems.org/gems/rspec/versions/1.1.9.

See http://relishapp.com/rspec and http://rubydoc.info/gems/rspec/frames
for the latest.

Cheers,
David
This topic is locked and can not be replied to.