ruby on rails - Is using assert_select correct for RSpec controller tests? -


i've been unable find documentation or advice on writing rspec controller tests. specifically, should use rails' assert_select feels unlike rspec or there alternative it?

is example below best practice?

describe articlescontroller   render_views   let(:article) { create(:article) }    describe "show"     "should display article title"       :show, id: article       response.should be_success       assert_select "h1", article.title     end   end end 

i don't wish write separate view tests that's pretty inconvenient.

you should able use following code check title content:

page.should have_selector("h1", :text => article.title) 

update: noted (with -1) answer wrong, page variable set capybara after call visit method (i young when answered :p). it's use in integration tests not in functional tests (controller) you're trying do.

short answer: no, it's not correct use assert_select in controller tests (used check request responses, if variables set, etc...)


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -