Sha256: 785868af8a89a71de9dc19a35d097da82395549556a0d13a50ac406cdd901a2b

Contents?: true

Size: 1.6 KB

Versions: 13

Compression:

Stored size: 1.6 KB

Contents

Before do
  Radiant::Cache.use_x_sendfile = false
  Radiant::Cache.use_x_accel_redirect = nil
end

Given /^the page cache is clear$/ do
  # No-op until we have Rack::Cache installed
  Radiant::Cache.clear if defined?(Radiant::Cache)
end

When(/^I go to page "(.*)"$/) do |url|
  visit url
  @old_headers ||= response.headers.dup
end

When(/^I go to page ['"](.*)['"] sending the ([-\w]+)$/) do |url, header_key|
  send_header_key = case header_key
  when 'ETag'
    'If-None-Match'
  when 'Last-Modified'
    'If-Modified-Since'
  end
  get url, {}, send_header_key => @old_headers[header_key]
end

Then /^I should get a (\d+) response code$/ do |code|
  response.response_code.should == code.to_i
end

Then /^I should get the same ([-\w]+) header$/ do |header_key|
  response.headers[header_key].should == @old_headers[header_key]
end

Given /^I have turned on X\-Sendfile headers$/ do
  Radiant::Cache.use_x_sendfile = true
end

Then /^I should( not)? get an "([^\"]*)" header in the response$/ do |status, header_key|
  if status.nil?
    response.headers.to_hash[header_key].should_not be_empty
  else
    response.headers.to_hash[header_key].should be_empty
  end
end

Given /^I have turned on X\-Accel\-Redirect headers$/ do
  Radiant::Cache.use_x_accel_redirect = "/cache"
end

Given /^I have page caching (on|off)$/ do |status|
  set_page_cache status
end

Then /^The "([^\"]*)" header should be "([^\"]*)"$/ do |header_key, value|
  response.headers.to_hash[header_key].should =~ Regexp.new(value)
end

def set_page_cache(status)
  Page.class_eval %{
    def cache?
      #{status != 'off'}
    end
  }, __FILE__, __LINE__
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
radiantcms-couchrest_model-0.2.4 features/step_definitions/page_serving_steps.rb
radiantcms-couchrest_model-0.2.2 features/step_definitions/page_serving_steps.rb
radiantcms-couchrest_model-0.2.1 features/step_definitions/page_serving_steps.rb
radiantcms-couchrest_model-0.2 features/step_definitions/page_serving_steps.rb
radiantcms-couchrest_model-0.1.9 features/step_definitions/page_serving_steps.rb
radiantcms-couchrest_model-0.1.8 features/step_definitions/page_serving_steps.rb
radiantcms-couchrest_model-0.1.7 features/step_definitions/page_serving_steps.rb
radiantcms-couchrest_model-0.1.6 features/step_definitions/page_serving_steps.rb
radiantcms-couchrest_model-0.1.5 features/step_definitions/page_serving_steps.rb
radiant-0.8.2 features/step_definitions/page_serving_steps.rb
radiant-rc-0.9.0 features/step_definitions/page_serving_steps.rb
radiant-0.8.1 features/step_definitions/page_serving_steps.rb
radiant-0.8.0 features/step_definitions/page_serving_steps.rb