Sha256: dff15d071b56f0b4e5f3460474c48841da8712db053562ba4444dc318e9fad14

Contents?: true

Size: 1.32 KB

Versions: 15

Compression:

Stored size: 1.32 KB

Contents

module Sauce
  module Generators
    class InstallGenerator < Rails::Generators::Base
      source_root File.expand_path("../templates", __FILE__)

      desc "Prep application for Sauce OnDemand Selenium tests"

      argument :username, :type => :string, :required => false
      argument :api_key, :type => :string, :required => false

      def copy_rake_tasks
        copy_file "sauce.rake", "lib/tasks/sauce.rake"
      end

      def configure_credentials
        if username
          system("sauce config #{username} #{api_key}")
        end
      end

      def setup_spec
        if File.directory? 'spec'
          empty_directory "spec/selenium"
          append_file "spec/spec_helper.rb", generate_config
        end
      end

      def setup_test
        if File.directory? 'test'
          empty_directory "test/selenium"
          append_file "test/test_helper.rb", generate_config
        end
      end

      private

      def generate_config
        @random_id ||= rand(100000)
        return <<-CONFIG
    require 'sauce'

    Sauce.config do |conf|
        conf.browser_url = "http://#{@random_id}.test/"
        conf.browsers = [
            ["Windows 2003", "firefox", "3."]
        ]
        conf.application_host = "127.0.0.1"
        conf.application_port = "3001"
    end
          CONFIG
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
sauce-0.17.6 lib/generators/sauce/install/install_generator.rb
sauce-0.17.5 lib/generators/sauce/install/install_generator.rb
sauce-0.17.4 lib/generators/sauce/install/install_generator.rb
sauce-0.17.3 lib/generators/sauce/install/install_generator.rb
sauce-0.17.3.alpha2 lib/generators/sauce/install/install_generator.rb
sauce-0.17.3.alpha1 lib/generators/sauce/install/install_generator.rb
sauce-0.17.2 lib/generators/sauce/install/install_generator.rb
sauce-0.17.1 lib/generators/sauce/install/install_generator.rb
sauce-0.17.0 lib/generators/sauce/install/install_generator.rb
sauce-0.16.2 lib/generators/sauce/install/install_generator.rb
sauce-0.16.1 lib/generators/sauce/install/install_generator.rb
sauce-0.15.1 lib/generators/sauce/install/install_generator.rb
sauce-0.15.0 lib/generators/sauce/install/install_generator.rb
sauce-0.15.0.alpha.2 lib/generators/sauce/install/install_generator.rb
sauce-0.15.0.alpha.1 lib/generators/sauce/install/install_generator.rb