Sha256: f28330556a1ff051b721e9240163cd62b9aac3c4a6fd309c607df594d52923df

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'
require 'genspec'
require 'fileutils'

# Can work if we simulate the app repo. need to find a way to have it use
# the dummy repo
module CspReport
  describe :"csp_report:initializer_install" do

    INITIALIZER_PATH = "config/initializers"
    INITIALIZER_FILE = INITIALIZER_PATH + "/csp_report.rb"

    def content_regexp(mount_point)
      /MOUNT_POINT\s*=\s*['|"]#{mount_point}['|"]/
    end

    within_source_root do
      FileUtils.mkdir_p INITIALIZER_PATH
    end

    context "with no argument" do
      it "should generate successfully" do
        subject.should generate
      end

      it "should put the right content in the initializer" do
        # csp is the default mount point
        subject.should generate {
          File.read(INITIALIZER_FILE).should =~ content_regexp('csp')
        }
      end
    end

    with_args :foo do
      it "should generate successfully" do
        subject.should generate
      end

      it "should put the right content in the initializer" do
        # csp is the default mount point
        subject.should generate do
          File.read(INITIALIZER_FILE).should =~ content_regexp('foo')
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
csp_report-1.0.1 spec/generators/csp_report/initializer_install_generator_spec.rb
csp_report-1.0.0 spec/generators/csp_report/initializer_install_generator_spec.rb
csp_report-0.4.0 spec/generators/csp_report/initializer_install_generator_spec.rb
csp_report-0.3.0 spec/generators/csp_report/initializer_install_generator_spec.rb