Sha256: 116d436196fec553608092ad136cf6e823ca4b7735c0637ba35cd05877193848

Contents?: true

Size: 1.76 KB

Versions: 3

Compression:

Stored size: 1.76 KB

Contents

require 'rspec'

When /^my S3 website is in "(.*?)"$/ do |blog_dir|
  @blog_dir = blog_dir
end

When /^s3_website will push my blog to S3$/ do
  push_files
end

Then /^s3_website will push my blog to S(\d+) and invalidate the Cloudfront distribution$/ do |args|
  push_files
end

Then /^the output should equal$/ do |expected_console_output|
  @console_output.should eq(expected_console_output)
end

Then /^the output should contain$/ do |expected_console_output|
  @console_output.should include(expected_console_output)
end

Then /^report that it uploaded (\d+) new and (\d+) changed files into S3$/ do
  |new_count, changed_count|
  @amount_of_new_files.should == new_count.to_i
  @amount_of_changed_files.should == changed_count.to_i
end

Then /^report that it invalidated (\d+) Cloudfront item$/ do |expected|
  @amount_of_invalidated_items.should == expected.to_i
end

Then /^report that it created (\d+) new redirects$/ do |expected|
  @amount_of_new_redirects.should == expected.to_i
end

Then /^report that it deleted (\d+) file from S3$/ do |amount_of_deleted_files|
  @amount_of_deleted_files.should == amount_of_deleted_files.to_i
end

def push_files
  @console_output = capture_stdout {
    in_headless_mode = true
    result = S3Website::Tasks.push(
      "#{@blog_dir}/_site", 
      in_headless_mode
    )
    @amount_of_new_files = result[:new_files_count]
    @amount_of_changed_files = result[:changed_files_count]
    @amount_of_deleted_files = result[:deleted_files_count]
    @amount_of_invalidated_items = result[:invalidated_items_count]
    @amount_of_new_redirects = result[:changed_redirects_count]
  }
end

module Kernel
  require 'stringio'

  def capture_stdout
    out = StringIO.new
    $stdout = out
    yield
    out.string
  ensure
    $stdout = STDOUT
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
s3_website-0.2.1 features/step_definitions/steps.rb
s3_website-0.2.0 features/step_definitions/steps.rb
s3_website-0.1.0 features/step_definitions/steps.rb