My first rspec reports "undefined method `key?' for #<String:0x46b1df0>"


#1

this my first rspec test, it is very simple

require File.expand_path(File.dirname(FILE) + ‘/…/spec_helper’)

describe Doc do
fixtures :docs
before(:each) do
@doc=docs(:yjn_bjy)
end

it “should create a new instance given valid attributes” do
true
end
end
<-----------------------------------------------------------------------------------------------------------------------------------------
after run “spec -fs spec\models\doc_spec.rb” at cmd line,it report
this error

NoMethodError in ‘Doc should create a new instance given valid
attributes’
undefined method `key?’ for #String:0x46b1df0
<-----------------------------------------------------------------------------------------------------------------------------------------

My environment:
OS:Windows
Rails:2.2.2
RSpec:1.1.11
rspec-rails:1.1.11
IDE:Netbeans6.5
Ruby:1.8.6

I use rspec_scaffold to generate these codes,and really confused about
this problems.
Hope for your suggestion!


#2

There’s probably a stack trace associated with that error, try looking
in that.

Ryan B.
Freelancer
http://frozenplague.net