Rails 3.1.3
rspec-rails (2.11.4)
rspec 2.11.1


I have generated a scaffold named Plan. And I have not done RSpec tests
for controllers at all.


schema.rb

create_table "plans", :force => true do |t|
t.integer "give_take"
t.integer "weight"
t.boolean "check_in"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "flight_name_id"
end

plans_controller.rb

def index
@plans = Plan.all

respond_to do |format|
format.html # index.html.erb
format.json { render json: @plans }
end
end

spec/factories/plans.rb

FactoryGirl.define do
factory :plan do
give_take 1
weight 1
check_in false
flight_name_id 11
end
end


plans_controller_spec.rb

describe "GET index" do
it "populates an array of plans" do
plan = create(:plan) #######HERE!!!!!
get :index
assigns(:plans).should eq [plan]
end

it "renders the :index view" do
get :index
response.should render_template :index
end
end


It raises a failure for index

2) PlansController GET index populates an array of plans
Failure/Error: plan = create(:plan)
NoMethodError:
undefined method `create' for
#<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x000001037a8e70>
# ./spec/controllers/plans_controller_spec.rb:45:in `block (3
levels) in <top (required)>'


Certainly I haven't defined method "create" anywhere except the one
generated by scaffold, which is not shown here.

How can I CREATE an instance here?

soichi

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 11, '12 at 11:11a
activeNov 11, '12 at 11:11a
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Soichi Ishida: 1 post

People

Translate

site design / logo © 2022 Grokbase