<commit_before>require 'spec_helper'

describe Roark::ImageCreateWorkflow do
  before do
    logger_stub = stub 'logger'
    @response_stub = mock 'response'
    Roark.logger logger_stub
    Roark.logger.stub :info => true
    @image_mock            = mock 'image mock'
    @image_create_workflow = Roark::ImageCreateWorkflow.new :image      => @image_mock,
                                                            :parameters => { 'key' => 'val' },
                                                            :template   => 'template'
  end

  it "should create and execute a new workflow" do
    @response_stub.stub :success? => true
    @image_mock.should_receive(:create_instance).with(:parameters => { 'key' => 'val' },
                                                      :template   => 'template').and_return @response_stub
    @image_mock.should_receive(:wait_for_instance).and_return @response_stub
    @image_mock.should_receive(:stop_instance).and_return @response_stub
    @image_mock.should_receive(:wait_for_instance_to_stop).and_return @response_stub
    @image_mock.should_receive(:create_ami).and_return @response_stub
    @image_mock.should_receive(:wait_for_ami).and_return @response_stub
    @image_mock.should_receive(:destroy_instance).and_return @response_stub
    @image_create_workflow.execute
  end

  it "should raise ImageCreateWorkflowError exception" do
    @response_stub.stub :success? => false, :message => 'error'
    @image_mock.should_receive(:create_instance).with(:parameters => { 'key' => 'val' },
                                                      :template   => 'template').and_return @response_stub
    expect(@image_create_workflow.execute.success?).to be_false
  end
end<commit_msg>adding spec<commit_after>require 'spec_helper'

describe Roark::ImageCreateWorkflow do
  before do
    logger_stub = stub 'logger'
    @response_stub = mock 'response'
    Roark.logger logger_stub
    Roark.logger.stub :info => true
    @image_mock            = mock 'image mock'
    @image_create_workflow = Roark::ImageCreateWorkflow.new :image      => @image_mock,
                                                            :parameters => { 'key' => 'val' },
                                                            :template   => 'template'
  end

  it "should create and execute a new workflow" do
    @response_stub.stub :success? => true
    @image_mock.should_receive(:create_instance).with(:parameters => { 'key' => 'val' },
                                                      :template   => 'template').and_return @response_stub
    @image_mock.should_receive(:wait_for_instance).and_return @response_stub
    @image_mock.should_receive(:stop_instance).and_return @response_stub
    @image_mock.should_receive(:wait_for_instance_to_stop).and_return @response_stub
    @image_mock.should_receive(:create_ami).and_return @response_stub
    @image_mock.should_receive(:wait_for_ami).and_return @response_stub
    @image_mock.should_receive(:destroy_instance).and_return @response_stub
    expect(@image_create_workflow.execute.success?).to be_true
  end

  it "should raise ImageCreateWorkflowError exception" do
    @response_stub.stub :success? => false, :message => 'error'
    @image_mock.should_receive(:create_instance).with(:parameters => { 'key' => 'val' },
                                                      :template   => 'template').and_return @response_stub
    expect(@image_create_workflow.execute.success?).to be_false
  end
end
{'fraction_non_alphanumeric': 0.1033791523482245, 'fraction_numerical': 0.0, 'mean_word_length': 2.6729758149316507, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2744840', 'n_tokens_mistral': 961, 'n_tokens_neox': 965, 'n_words': 171}