I want to check if my 'style.css' is attached to my page when rendering with a specific layout, for example 'application.html.erb':
So here is spec:
specs / views / layouts / application.html.erb_spec.rb
it 'should include styles for screen media' do render rendered.should have_selector('link', :href => '/stylesheets/style.css', :media => 'screen', :rel => 'stylesheet', :type => 'text/css' ) end
And my application.html.erb application looks like this:
application / views / layouts / application.html.erb
<html> <head> <meta content="text/html; charset=utf-8" http-equiv="content-type"> <%= stylesheet_link_tag :style, :media => 'screen' %> <%= javascript_include_tag :defaults %> <%= csrf_meta_tag %> </head> <body> <%= yield %> </body> </html>
When I run a spec of my kind, it fails because
<link href="/stylesheets/style.css?1289599022" media="screen" rel="stylesheet" type="text/css">
and
<link rel='stylesheet' type='text/css' media='screen' href='/stylesheets/reset.css'/>
.
And is it all about quantity? 1289599022 'rails adding after the file name. Any ideas on how to test this functionality?
source share