Sha256: 7f5d3f8915889041708a2757529dda55221eb72691ab2077638205d3f2f52e03

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require 'rspec'
require 'yaml'
require 'selenium-webdriver'
require 'jasmine_selenium_runner/configure_jasmine'

describe "Configuring jasmine" do

  class FakeConfig
    attr_accessor :port, :runner
  end

  def configure
    Dir.stub(:pwd).and_return(working_dir)
    Jasmine.stub(:configure).and_yield(fake_config)
    JasmineSeleniumRunner::ConfigureJasmine.install_selenium_runner
  end

  def stub_config_file(config_obj)
    config_path = File.join(working_dir, 'spec', 'javascripts', 'support', 'jasmine_selenium_runner.yml')
    File.stub(:exist?).with(config_path).and_return(true)
    File.stub(:read).with(config_path).and_return(YAML.dump(config_obj))
  end

  let(:working_dir) { 'hi' }
  let(:fake_config) { FakeConfig.new }

  context "when a custom selenium server is specified" do
    before do
      stub_config_file 'selenium_server' => 'http://example.com/selenium/stuff'
      configure
    end

    it "make a webdriver pointing to the custom server" do
      Selenium::WebDriver.should_receive(:for).with(:remote, hash_including(url: 'http://example.com/selenium/stuff'))
      fake_config.runner.call(nil, nil)
    end
  end

  context "when the user wants firebug installed" do
    before do
      stub_config_file 'browser' => 'firefox-firebug'
      configure
    end

    it "should create a firebug profile and pass that to WebDriver" do
      profile = double(:profile, enable_firebug: nil)
      Selenium::WebDriver::Firefox::Profile.stub(:new).and_return(profile)
      Selenium::WebDriver.should_receive(:for).with('firefox-firebug'.to_sym, {profile: profile})
      fake_config.runner.call(nil, nil)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jasmine_selenium_runner-0.1.0 spec/jasmine_selenium_runner/configure_jasmine_spec.rb