Sha256: bec301040733c13868590af34f0d99bc4773d688703871dfd856964fe5a2fdbf

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 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:mount" do

    def mount_string(mount_point)
      "\n  mount CspReport::Engine, at: '#{mount_point}'"
    end

    within_source_root do
      FileUtils.mkdir_p "config"
      FileUtils.touch "config/routes.rb"
    end

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

      it "should mount the gem in the routes" do
        # This checks that you call the inject_into_file with exactly this content.
        # not very practical.
        # csp is the default mount point
        subject.should inject_into_file("config/routes.rb", 
                                        mount_string('csp'))
      end
    end

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

      it "should mount the gem in the routes" do
        subject.should inject_into_file("config/routes.rb", 
                                        mount_string('foo'))
      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/mount_generator_spec.rb
csp_report-1.0.0 spec/generators/csp_report/mount_generator_spec.rb
csp_report-0.4.0 spec/generators/csp_report/mount_generator_spec.rb
csp_report-0.3.0 spec/generators/csp_report/mount_generator_spec.rb