Sha256: 99355507b46ba0c803c8191829270f617d230436c80e5726542767c55a08a992

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe PagesController, type: :controller do
  render_views

  let(:fixture) { YAML.load_file('spec/fixtures/user_agents.yml') }

  shared_examples_for 'separate view' do
    it 'should render separate view' do
      user_agents.each do |user_agent|
        request.env['HTTP_USER_AGENT'] = user_agent

        get :show

        expect(response.body).to match Regexp.escape(content)
      end
    end
  end

  describe 'GET #show' do
    context 'when accessed from phone' do
      it_behaves_like 'separate view' do
        let(:user_agents) { fixture['phone'] }
        let(:content) { 'show.html+phone.erb' }
      end
    end

    context 'when accessed from tablet' do
      it_behaves_like 'separate view' do
        let(:user_agents) { fixture['tablet'] }
        let(:content) { 'show.html+tablet.erb' }
      end
    end

    context 'when accessed from desktop' do
      it_behaves_like 'separate view' do
        let(:user_agents) { fixture['desktop'] }
        let(:content) { 'show.html.erb' }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
separation-0.3.0 spec/controllers/separation_spec.rb
separate_views-0.2.0 spec/controllers/separate_views_spec.rb