jasmine_selenium_runner 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94aa68074fa6bd922eae4c54c51337a27881b366
4
- data.tar.gz: ffff97516d2a1241a7c2fa7f08fdc79d12683d3f
3
+ metadata.gz: 71c49524cded239d450de93167e2e595e783d265
4
+ data.tar.gz: 61c45501e41dbda1c35b7fbc8f07f881c6a956c1
5
5
  SHA512:
6
- metadata.gz: 57a3598792a25d6c482f9630804ef8884a36cac9c7f8a1e576bd75f17df9b216bfadb96756c7f8cbb725d6c120a27ef8623aa918bc99c1bf9e3746d003933ccf
7
- data.tar.gz: 222a273ad1d72480624e3676af3b256c8586c2e20f7aef078be1f6fccb4a069adb9d4746eb49e637680ece9890bd0f10fd1dd68e58ac5488ae20b2774dd7fd66
6
+ metadata.gz: f5e1c6a43f07697730c1309809aca6da84d9552df5e9224a6251ef1c86d3d0625a1b75b428ace67a64b7379708ed1c6258fd21869b4f846f41a343f250fd2b2b
7
+ data.tar.gz: 314d392cdc9071ceab94f0a5c5ef02769d1dc52ac40640f6f30ff450ccdc853f33caf0511f066cce74d725cf188c57d95bd5ff53ffe554ee918e5ecbd2ae8698
@@ -1,6 +1,6 @@
1
1
  before_script:
2
2
  - sh -e /etc/init.d/xvfb start
3
- - curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash
3
+ - curl -L https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash
4
4
  script: DISPLAY=:99.0 bundle exec rake
5
5
  rvm:
6
6
  - 2.0.0
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "bundler"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency 'rspec'
24
- spec.add_development_dependency 'rails'
24
+ spec.add_development_dependency 'rails', '> 3.0'
25
25
  spec.add_dependency 'jasmine', '~> 2.0.0.alpha'
26
26
  spec.add_dependency 'selenium-webdriver', '~> 2.35'
27
27
  spec.add_dependency 'sauce-connect'
@@ -52,14 +52,32 @@ module Jasmine
52
52
  spec_results = []
53
53
 
54
54
  loop do
55
- slice = driver.execute_script("return jsApiReporter.specResults(#{index}, #{result_batch_size})")
56
- spec_results << Jasmine::Result.map_raw_results(slice)
55
+ slice = results_without_circular_references(index)
56
+ spec_results << slice
57
57
  index += result_batch_size
58
58
  break if slice.size < result_batch_size
59
59
  end
60
60
  spec_results.flatten
61
61
  end
62
62
 
63
+ def results_without_circular_references(starting_index)
64
+ slice = driver.execute_script(<<-JS)
65
+ var specResults = jsApiReporter.specResults(#{starting_index}, #{result_batch_size})
66
+ for (var i = 0; i < specResults.length; i++) {
67
+ var expectations = specResults[i].failedExpectations;
68
+ if (specResults[i].passedExpectations) {
69
+ expectations = expectations.concat(specResults[i].passedExpectations);
70
+ }
71
+ for (var j = 0; j < expectations.length; j++) {
72
+ var expectation = expectations[j];
73
+ try { JSON.stringify(expectation.expected); } catch (e) { expectation.expected = '<circular expected>'; }
74
+ try { JSON.stringify(expectation.actual); } catch (e) { expectation.actual = '<circular actual>'; }
75
+ }
76
+ }
77
+ return specResults;
78
+ JS
79
+ Jasmine::Result.map_raw_results(slice)
80
+ end
63
81
  end
64
82
  end
65
83
  end
@@ -1,7 +1,7 @@
1
1
  module Jasmine
2
2
  module Runners
3
3
  class Selenium
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  end
@@ -21,7 +21,9 @@ module JasmineSeleniumRunner
21
21
  end
22
22
 
23
23
  def self.load_config
24
- filepath = File.join(Dir.pwd, 'spec', 'javascripts', 'support', 'jasmine_selenium_runner.yml')
24
+ filepath = ENV['JASMINE_SELENIUM_CONFIG_PATH']
25
+ filepath ||= File.join(Dir.pwd, 'spec', 'javascripts', 'support', 'jasmine_selenium_runner.yml')
26
+
25
27
  if File.exist?(filepath)
26
28
  YAML::load(ERB.new(File.read(filepath)).result(binding))
27
29
  else
@@ -5,4 +5,4 @@ namespace :jasmine_selenium_runner do
5
5
  end
6
6
  end
7
7
 
8
- task 'jasmine:require' => ['jasmine_selenium_runner:setup']
8
+ task 'jasmine:configure_plugins' => ['jasmine_selenium_runner:setup']
@@ -0,0 +1,7 @@
1
+ it("handles circular references", function() {
2
+ var objA = {};
3
+ var objB = {back_reference: objA};
4
+ objA.back_reference = objB;
5
+
6
+ expect(objA).not.toBe(objA);
7
+ });
@@ -10,7 +10,7 @@ describe "Configuring jasmine" do
10
10
  let(:config) { { 'selenium_server' => 'http://example.com/selenium/stuff' }}
11
11
 
12
12
  it "make a webdriver pointing to the custom server" do
13
- Selenium::WebDriver.should_receive(:for).with(:remote, hash_including(url: 'http://example.com/selenium/stuff'))
13
+ expect(Selenium::WebDriver).to receive(:for).with(:remote, hash_including(url: 'http://example.com/selenium/stuff'))
14
14
  configurer.make_runner
15
15
  end
16
16
  end
@@ -20,8 +20,8 @@ describe "Configuring jasmine" do
20
20
 
21
21
  it "should create a firebug profile and pass that to WebDriver" do
22
22
  profile = double(:profile, enable_firebug: nil)
23
- Selenium::WebDriver::Firefox::Profile.stub(:new).and_return(profile)
24
- Selenium::WebDriver.should_receive(:for).with('firefox-firebug'.to_sym, {profile: profile})
23
+ allow(Selenium::WebDriver::Firefox::Profile).to receive(:new).and_return(profile)
24
+ expect(Selenium::WebDriver).to receive(:for).with('firefox-firebug'.to_sym, {profile: profile})
25
25
  configurer.make_runner
26
26
  end
27
27
  end
@@ -32,17 +32,17 @@ describe "Configuring jasmine" do
32
32
  end
33
33
 
34
34
  def configure
35
- Dir.stub(:pwd).and_return(working_dir)
36
- Jasmine.stub(:configure).and_yield(fake_config)
35
+ allow(Dir).to receive(:pwd).and_return(working_dir)
36
+ allow(Jasmine).to receive(:configure).and_yield(fake_config)
37
37
  JasmineSeleniumRunner::ConfigureJasmine.install_selenium_runner
38
38
  end
39
39
 
40
- def stub_config_file(config_obj)
41
- config_path = File.join(working_dir, 'spec', 'javascripts', 'support', 'jasmine_selenium_runner.yml')
42
- File.stub(:exist?).and_call_original
43
- File.stub(:exist?).with(config_path).and_return(true)
44
- File.stub(:read).and_call_original
45
- File.stub(:read).with(config_path).and_return(YAML.dump(config_obj))
40
+ def stub_config_file(config_obj, config_path=nil)
41
+ config_path ||= File.join(working_dir, 'spec', 'javascripts', 'support', 'jasmine_selenium_runner.yml')
42
+ allow(File).to receive(:exist?).and_call_original
43
+ allow(File).to receive(:exist?).with(config_path).and_return(true)
44
+ allow(File).to receive(:read).and_call_original
45
+ allow(File).to receive(:read).with(config_path).and_return(YAML.dump(config_obj))
46
46
  end
47
47
 
48
48
  let(:working_dir) { 'hi' }
@@ -58,15 +58,35 @@ describe "Configuring jasmine" do
58
58
  end
59
59
  end
60
60
 
61
- before do
62
- stub_config_file 'configuration_class' => 'Foo::Bar'
63
- configure
61
+ context 'with the default config file location' do
62
+ before do
63
+ stub_config_file 'configuration_class' => 'Foo::Bar'
64
+ configure
65
+ end
66
+
67
+ it "should use the custom class" do
68
+ expect(Selenium::WebDriver).not_to receive(:for)
69
+ expect_any_instance_of(Foo::Bar).to receive(:make_runner)
70
+ fake_config.runner.call(nil, nil)
71
+ end
64
72
  end
65
73
 
66
- it "should use the custom class" do
67
- Selenium::WebDriver.should_not_receive(:for)
68
- Foo::Bar.any_instance.should_receive(:make_runner)
69
- fake_config.runner.call(nil, nil)
74
+ context 'with a custom config file path' do
75
+ before do
76
+ stub_config_file({ 'configuration_class' => 'Foo::Bar' }, '/tmp/config.yml')
77
+ ENV['JASMINE_SELENIUM_CONFIG_PATH'] = '/tmp/config.yml'
78
+ configure
79
+ end
80
+
81
+ after do
82
+ ENV.delete 'JASMINE_SELENIUM_CONFIG_PATH'
83
+ end
84
+
85
+ it "should use the custom class" do
86
+ expect(Selenium::WebDriver).not_to receive(:for)
87
+ expect_any_instance_of(Foo::Bar).to receive(:make_runner)
88
+ fake_config.runner.call(nil, nil)
89
+ end
70
90
  end
71
91
  end
72
92
  end
@@ -21,7 +21,27 @@ GEMFILE
21
21
  `bundle exec jasmine examples`
22
22
  FileUtils.cp(File.join(project_root, 'spec', 'fixtures', 'is_in_firefox_spec.js'), File.join(dir, 'spec', 'javascripts'))
23
23
  ci_output = `bundle exec rake -E "require 'jasmine_selenium_runner'" --trace jasmine:ci`
24
- ci_output.should =~ /[1-9][0-9]* specs, 0 failures/
24
+ expect(ci_output).to match(/[1-9][0-9]* specs, 0 failures/)
25
+ end
26
+ end
27
+ end
28
+
29
+ it "allows rake jasmine:ci to retrieve results even though Selenium can't transmit back circular JS objects" do
30
+ in_temp_dir do |dir, project_root|
31
+ File.open(File.join(dir, 'Gemfile'), 'w') do |file|
32
+ file.write <<-GEMFILE
33
+ source 'https://rubygems.org'
34
+ gem 'jasmine_selenium_runner', :path => '#{project_root}'
35
+ gem 'jasmine', :git => 'https://github.com/pivotal/jasmine-gem.git'
36
+ GEMFILE
37
+ end
38
+ Bundler.with_clean_env do
39
+ `bundle`
40
+ `bundle exec jasmine init`
41
+ `bundle exec jasmine examples`
42
+ FileUtils.cp(File.join(project_root, 'spec', 'fixtures', 'contains_circular_references_spec.js'), File.join(dir, 'spec', 'javascripts'))
43
+ ci_output = `bundle exec rake -E "require 'jasmine_selenium_runner'" --trace jasmine:ci`
44
+ expect(ci_output).to match(/[1-9][0-9]* specs, 1 failure/)
25
45
  end
26
46
  end
27
47
  end
@@ -68,13 +88,13 @@ YAML
68
88
  before = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
69
89
  http.request(job_list_request)
70
90
  end
71
- JSON.parse(before.body).should == []
91
+ expect(JSON.parse(before.body)).to be_empty
72
92
  ci_output = %x{bundle exec rake -E "require 'jasmine_selenium_runner'" --trace jasmine:ci}
73
- ci_output.should =~ (/[1-9][0-9]* specs, 0 failures/)
93
+ expect(ci_output).to match(/[1-9][0-9]* specs, 0 failures/)
74
94
  after = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
75
95
  http.request(job_list_request)
76
96
  end
77
- JSON.parse(after.body).should_not be_empty
97
+ expect(JSON.parse(after.body)).not_to be_empty
78
98
  end
79
99
  end
80
100
  end
@@ -107,7 +127,7 @@ YAML
107
127
  `bundle exec rails g jasmine:examples`
108
128
  FileUtils.cp(File.join(project_root, 'spec', 'fixtures', 'is_in_firefox_spec.js'), File.join(dir, 'rails-test', 'spec', 'javascripts'))
109
129
  output = `bundle exec rake jasmine:ci`
110
- output.should =~ /[1-9]\d* specs, 0 failures/
130
+ expect(output).to match(/[1-9]\d* specs, 0 failures/)
111
131
  end
112
132
  end
113
133
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jasmine_selenium_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajan Agaskar
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-03 00:00:00.000000000 Z
12
+ date: 2014-07-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - '>='
19
19
  - !ruby/object:Gem::Version
20
- version: '1.3'
20
+ version: '0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - '>='
26
26
  - !ruby/object:Gem::Version
27
- version: '1.3'
27
+ version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -57,16 +57,16 @@ dependencies:
57
57
  name: rails
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - '>='
60
+ - - '>'
61
61
  - !ruby/object:Gem::Version
62
- version: '0'
62
+ version: '3.0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - '>'
68
68
  - !ruby/object:Gem::Version
69
- version: '0'
69
+ version: '3.0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: jasmine
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -134,6 +134,7 @@ files:
134
134
  - lib/jasmine_selenium_runner/firebug/firebug.rb
135
135
  - lib/jasmine_selenium_runner/railtie.rb
136
136
  - lib/jasmine_selenium_runner/tasks/jasmine_selenium_runner.rake
137
+ - spec/fixtures/contains_circular_references_spec.js
137
138
  - spec/fixtures/is_in_firefox_spec.js
138
139
  - spec/fixtures/is_in_ie_spec.js
139
140
  - spec/jasmine_selenium_runner/configure_jasmine_spec.rb
@@ -159,11 +160,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
160
  version: '0'
160
161
  requirements: []
161
162
  rubyforge_project:
162
- rubygems_version: 2.0.5
163
+ rubygems_version: 2.0.3
163
164
  signing_key:
164
165
  specification_version: 4
165
166
  summary: Run your jasmine tests in a real live browser!
166
167
  test_files:
168
+ - spec/fixtures/contains_circular_references_spec.js
167
169
  - spec/fixtures/is_in_firefox_spec.js
168
170
  - spec/fixtures/is_in_ie_spec.js
169
171
  - spec/jasmine_selenium_runner/configure_jasmine_spec.rb