2014-07-05 89 views
0

我只是試圖測試我的模型,但這個錯誤不斷彈出,我檢查出我的代碼,我找不到錯誤。 錯誤的參數數目(0爲1..4)錯誤的參數數量(0代表1..4)在軌道上

show_movie.spec.rb

it "Shows Flop! if total gross is under $30000000" do 

     movie = Movie.create(movie_attributes(total_gross: 25000000.00)) 

     visit movie_url(movie) 

     expect(page).to have_text("Flop!") 

    end 

    it "Shows total gross if total gross is between $30000000 and $50000000" do 

     movie = Movie.create(movie_attributes(total_gross: 40000000.00)) 

     visit movie_url(movie) 

     expect(page).to have_text("$40,000,000.00") 

    end 

    it "Shows Hot! if total gross is higher than $50000000" do 

     movie = Movie.create(movie_attributes(total_gross: 60000000.00)) 

     visit movie_url(movie) 

     expect(page).to have_text("Hot!") 

    end 

show.html.erb

<h3>Rating</h3> 
    <p> 
     <%= format_total_gross(@movie) %> 
     </p> 

movie_helpers.rb

def format_total_gross(movie) 
    if movie.flop? 
     content_tag[:strong, "Flop!"] 
    elsif movie.hot? 
     content_tag[:strong, "Hot!"] 
    else 
     movie.attachment.thumb 
    end 
end 

movie.rb模型

def flop? total_gross.blank? || total_gross 端

def hot? 
    total_gross > 50000000 
end 

回答

相關問題