Undefined method for a class in rspec
The next RSpec 2 test.
describe "GET new" do describe "gets a report form" do xhr :get, :new, :post_id => @post response.should be_success end end gives this nice error:
undefined method xhr for #<Class:0xb5c72404> (NoMethodError)
Any idea what's wrong?
+8
0x4a6f4672
source share1 answer
Turns out you need to use the it operator in the describe block. Then the error disappears. If you do not use the required sum of describe and it blocks, then RSpec produces all kinds of strange errors. This is the correct code:
describe "GET new" do it "gets a report form" do xhr :get, :new, :post_id => @post response.should be_success end end +16
0x4a6f4672
source share