1

In my app I am testing creating a new project. Currently I do it with integration test using rspec. Here's my code:

  3 describe "Projects" do
  4   describe "create project" do
  5     it "should create a new project" do
  6       lambda do
  7         visit root_path
  8         click_link 'new project'        
  9         fill_in :name, :with => 'Project name'
 10         fill_in :description, :with => 'This is a description'
 11         click_button 'Create'
 12       end.should change(Project, :count).by(1)
 13     end
 14   end
 15 end

I would also like to add after line 11 something like :

response.should render_template 'new'

...but I keep getting this error

@request must be an ActionDispatch::Request

Am I doing this right? What is the best practice?

oFca
  • 2,830
  • 6
  • 31
  • 43

1 Answers1

0
current_path.should == new_project_path
page.should have_selector('div#error_explanation')

According to this https://stackoverflow.com/a/9105371/724036

Community
  • 1
  • 1
zishe
  • 10,665
  • 12
  • 64
  • 103