Sha256: 01067be0d8ab74b7d70003d3b89149faa136fd641a88815f55153d0aa0e2e566
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
require 'spec_helper' describe Roboto::ContentProvider do include FakeFS::SpecHelpers let(:content_provider) { Roboto::ContentProvider.new } let(:relative_robots_dir) { 'config/robots' } let(:relative_path_to_default) do "#{relative_robots_dir}/default.txt" end before(:each) do FileUtils.mkdir_p(Roboto::Engine.root.join(relative_path_to_default)) FileUtils.mkdir_p(Rails.root.join(relative_robots_dir)) end it 'uses the environment specific file if found' do path = Rails.root.join("config/robots/test.txt") File.open(path, 'wb') { |f| f.write(Rails.env) } expect(content_provider.path).to eq(path) expect(content_provider.contents).to eq(Rails.env) end it 'supports erb pre-processing' do path = Rails.root.join("config/robots/test.txt.erb") File.open(path, 'wb') { |f| f.write('<%= Rails.env %>') } expect(content_provider.path).to eq(path) expect(content_provider.contents).to eq(Rails.env) end it 'strips newlines in closing erb tags' do path = Rails.root.join("config/robots/test.txt.erb") File.open(path, 'wb') { |f| f.write("<% if true %>\n<%= Rails.env %>\n<% end %>") } expect(content_provider.path).to eq(path) expect(content_provider.contents).to eq(Rails.env) end it 'uses the default robots file if found in the rails root' do path = Rails.root.join(relative_path_to_default) FileUtils.touch(path) expect(content_provider.path).to eq(path) end it 'defaults to the gem provided robots if not found in rails root' do path = Roboto::Engine.root.join(relative_path_to_default) FileUtils.touch(path) expect(content_provider.path).to eq(Roboto::Engine.root.join(relative_path_to_default)) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
roboto-1.0.1 | spec/roboto/content_provider_spec.rb |
roboto-1.0.0 | spec/roboto/content_provider_spec.rb |