danieldkim-evergreen 0.4.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +155 -0
- data/bin/evergreen +18 -0
- data/config/routes.rb +3 -0
- data/lib/evergreen/application.rb +46 -0
- data/lib/evergreen/cli.rb +23 -0
- data/lib/evergreen/rails.rb +12 -0
- data/lib/evergreen/resources/evergreen.css +64 -0
- data/lib/evergreen/resources/evergreen.js +80 -0
- data/lib/evergreen/runner.rb +151 -0
- data/lib/evergreen/server.rb +22 -0
- data/lib/evergreen/spec.rb +55 -0
- data/lib/evergreen/suite.rb +44 -0
- data/lib/evergreen/tasks.rb +6 -0
- data/lib/evergreen/template.rb +28 -0
- data/lib/evergreen/version.rb +3 -0
- data/lib/evergreen/version.rb~ +3 -0
- data/lib/evergreen/views/layout.erb +19 -0
- data/lib/evergreen/views/list.erb +9 -0
- data/lib/evergreen/views/spec.erb +38 -0
- data/lib/evergreen.rb +35 -0
- data/lib/tasks/evergreen.rake +7 -0
- data/spec/evergreen_spec.rb +24 -0
- data/spec/meta_spec.rb +50 -0
- data/spec/runner_spec.rb +33 -0
- data/spec/spec_helper.rb +43 -0
- data/spec/spec_spec.rb +28 -0
- data/spec/suite1/public/jquery.js +152 -0
- data/spec/suite1/public/styles.css +3 -0
- data/spec/suite1/spec/javascripts/bar_spec.js +0 -0
- data/spec/suite1/spec/javascripts/coffeescript_spec.coffee +7 -0
- data/spec/suite1/spec/javascripts/failing_spec.js +12 -0
- data/spec/suite1/spec/javascripts/foo_spec.js +0 -0
- data/spec/suite1/spec/javascripts/invalid_coffee_spec.coffee +1 -0
- data/spec/suite1/spec/javascripts/slow_spec.coffee +8 -0
- data/spec/suite1/spec/javascripts/spec_helper.coffee +1 -0
- data/spec/suite1/spec/javascripts/spec_helper.js +1 -0
- data/spec/suite1/spec/javascripts/templates/another_template.html +1 -0
- data/spec/suite1/spec/javascripts/templates/one_template.html +1 -0
- data/spec/suite1/spec/javascripts/templates_spec.js +47 -0
- data/spec/suite1/spec/javascripts/testing_spec.js +11 -0
- data/spec/suite1/spec/javascripts/transactions_spec.js +14 -0
- data/spec/suite1/spec/javascripts/with_helper_spec.js +9 -0
- data/spec/suite2/config/evergreen.rb +5 -0
- data/spec/suite2/public_html/foo.js +1 -0
- data/spec/suite2/spec/awesome_spec.js +12 -0
- data/spec/suite2/spec/failing_spec.js +5 -0
- data/spec/suite2/templates/foo.html +1 -0
- data/spec/suite_spec.rb +26 -0
- data/spec/template_spec.rb +22 -0
- metadata +216 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
module Evergreen
|
2
|
+
class Template
|
3
|
+
attr_reader :name, :suite
|
4
|
+
|
5
|
+
def initialize(suite, name)
|
6
|
+
@suite = suite
|
7
|
+
@name = name
|
8
|
+
end
|
9
|
+
|
10
|
+
def root
|
11
|
+
suite.root
|
12
|
+
end
|
13
|
+
|
14
|
+
def full_path
|
15
|
+
File.join(root, Evergreen.template_dir, name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def read
|
19
|
+
File.read(full_path)
|
20
|
+
end
|
21
|
+
alias_method :contents, :read
|
22
|
+
|
23
|
+
def exist?
|
24
|
+
File.exist?(full_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>Evergreen</title>
|
6
|
+
<link rel="stylesheet" type="text/css" href="<%= url('/jasmine/jasmine.css') %>"/>
|
7
|
+
<link rel="stylesheet" type="text/css" href="<%= url('/resources/evergreen.css') %>"/>
|
8
|
+
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
<div id="footer">
|
14
|
+
Powered by <a href="http://github.com/jnicklas/evergreen">Evergreen</a>.
|
15
|
+
Evergreen is sponsored by <a href="http://elabs.se">Elabs</a>.
|
16
|
+
</div>
|
17
|
+
</body>
|
18
|
+
</html>
|
19
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<script type="text/javascript" src="<%= url("/jasmine/jasmine.js") %>"></script>
|
2
|
+
<script type="text/javascript" src="<%= url("/jasmine/jasmine-html.js") %>"></script>
|
3
|
+
<script type="text/javascript" src="<%= url("/resources/evergreen.js") %>"></script>
|
4
|
+
<script type="text/javascript">
|
5
|
+
// <![CDATA[
|
6
|
+
<% begin %>
|
7
|
+
<%= @js_spec_helper.read.to_s + ";" if @js_spec_helper.exist? %>
|
8
|
+
<%= @coffee_spec_helper.read.to_s + ";" if @coffee_spec_helper.exist? %>
|
9
|
+
<%= @spec.read %>;
|
10
|
+
<% rescue StandardError => e %>
|
11
|
+
describe("failure", function() {
|
12
|
+
it("should not fail", function() {
|
13
|
+
throw(<%= "#{e.class}: #{e.message}".to_json %>);
|
14
|
+
});
|
15
|
+
});
|
16
|
+
<% end %>
|
17
|
+
// ]]>
|
18
|
+
</script>
|
19
|
+
|
20
|
+
<div id="page">
|
21
|
+
<h1>Evergreen</h1>
|
22
|
+
<a class="back" href="<%= url("/") %>">Back to list</a>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<div id="test"></div>
|
26
|
+
|
27
|
+
<script type="text/javascript">
|
28
|
+
(function() {
|
29
|
+
Evergreen.driver = <%= Evergreen.driver.to_json %>;
|
30
|
+
<% @suite.templates.each do |template| %>
|
31
|
+
Evergreen.templates[<%= template.name.to_json %>] = <%= template.read.to_json %>;
|
32
|
+
<% end %>
|
33
|
+
var jasmineEnv = jasmine.getEnv();
|
34
|
+
jasmineEnv.addReporter(new jasmine.TrivialReporter());
|
35
|
+
jasmineEnv.addReporter(new Evergreen.ReflectiveReporter());
|
36
|
+
jasmineEnv.execute();
|
37
|
+
})();
|
38
|
+
</script>
|
data/lib/evergreen.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'capybara'
|
4
|
+
require 'launchy'
|
5
|
+
require 'evergreen/version'
|
6
|
+
require 'evergreen/application'
|
7
|
+
require 'json'
|
8
|
+
|
9
|
+
module Evergreen
|
10
|
+
autoload :Cli, 'evergreen/cli'
|
11
|
+
autoload :Server, 'evergreen/server'
|
12
|
+
autoload :Runner, 'evergreen/runner'
|
13
|
+
autoload :Suite, 'evergreen/suite'
|
14
|
+
autoload :Spec, 'evergreen/spec'
|
15
|
+
autoload :Template, 'evergreen/template'
|
16
|
+
|
17
|
+
class << self
|
18
|
+
attr_accessor :driver, :public_dir, :template_dir, :spec_dir
|
19
|
+
|
20
|
+
def configure
|
21
|
+
yield self
|
22
|
+
end
|
23
|
+
|
24
|
+
def use_defaults!
|
25
|
+
configure do |config|
|
26
|
+
config.driver = :selenium
|
27
|
+
config.public_dir = 'public'
|
28
|
+
config.spec_dir = 'spec/javascripts'
|
29
|
+
config.template_dir = 'spec/javascripts/templates'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Evergreen.use_defaults!
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evergreen, ".application" do
|
4
|
+
include Capybara
|
5
|
+
|
6
|
+
it "should show a successful test run" do
|
7
|
+
visit("/")
|
8
|
+
click_link("testing_spec.js")
|
9
|
+
page.should have_content("2 specs, 0 failures")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should show a successful test run for a coffeescript spec" do
|
13
|
+
visit("/")
|
14
|
+
click_link("coffeescript_spec.coffee")
|
15
|
+
page.should have_content("2 specs, 0 failures")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should show errors for a failing spec" do
|
19
|
+
visit("/")
|
20
|
+
click_link("failing_spec.js")
|
21
|
+
page.should have_content("2 specs, 1 failure")
|
22
|
+
page.should have_content("Expected 'bar' to equal 'noooooo'.")
|
23
|
+
end
|
24
|
+
end
|
data/spec/meta_spec.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evergreen::Runner do
|
4
|
+
let(:suite) { Evergreen::Suite.new(root) }
|
5
|
+
subject { Evergreen::Spec.new(suite, template) }
|
6
|
+
|
7
|
+
context "with standard setup" do
|
8
|
+
let(:root) { File.expand_path('suite1', File.dirname(__FILE__)) }
|
9
|
+
|
10
|
+
context "with transactions spec" do
|
11
|
+
let(:template) { 'transactions_spec.js' }
|
12
|
+
it { should pass }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "with spec helper" do
|
16
|
+
let(:template) { 'with_helper_spec.js' }
|
17
|
+
it { should pass }
|
18
|
+
end
|
19
|
+
|
20
|
+
context "with template spec" do
|
21
|
+
let(:template) { 'templates_spec.js' }
|
22
|
+
it { should pass }
|
23
|
+
end
|
24
|
+
|
25
|
+
context "invalid coffee" do
|
26
|
+
let(:template) { 'invalid_coffee_spec.coffee' }
|
27
|
+
it { should_not pass }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with slow failing spec" do
|
31
|
+
let(:template) { 'slow_spec.coffee' }
|
32
|
+
it { should_not pass }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "with modified setup" do
|
37
|
+
let(:root) { File.expand_path('suite2', File.dirname(__FILE__)) }
|
38
|
+
|
39
|
+
context "with awesome spec" do
|
40
|
+
let(:template) { 'awesome_spec.js' }
|
41
|
+
it { should pass }
|
42
|
+
end
|
43
|
+
|
44
|
+
context "with failing spec" do
|
45
|
+
let(:template) { 'failing_spec.js' }
|
46
|
+
it { should_not pass }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
data/spec/runner_spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evergreen::Runner do
|
4
|
+
let(:root) { File.expand_path('suite1', File.dirname(__FILE__)) }
|
5
|
+
let(:suite) { Evergreen::Suite.new(root) }
|
6
|
+
let(:runner) { Evergreen::Runner.new(suite, buffer) }
|
7
|
+
let(:buffer) { StringIO.new }
|
8
|
+
|
9
|
+
describe '#run' do
|
10
|
+
before { runner.run }
|
11
|
+
|
12
|
+
describe 'the buffer' do
|
13
|
+
subject { buffer.rewind; buffer.read }
|
14
|
+
|
15
|
+
it { should include('.F..') }
|
16
|
+
it { should include("Expected 'bar' to equal 'noooooo'") }
|
17
|
+
it { should include("17 examples, 3 failures") }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#run_spec' do
|
22
|
+
let(:spec) { suite.get_spec('failing_spec.js') }
|
23
|
+
before { runner.spec_runner(spec).run }
|
24
|
+
|
25
|
+
describe 'the buffer' do
|
26
|
+
subject { buffer.rewind; buffer.read }
|
27
|
+
|
28
|
+
it { should include('.F') }
|
29
|
+
it { should include("Expected 'bar' to equal 'noooooo'") }
|
30
|
+
it { should include("2 examples, 1 failures") }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'evergreen'
|
5
|
+
require 'rspec'
|
6
|
+
|
7
|
+
require 'capybara/dsl'
|
8
|
+
require 'capybara/envjs'
|
9
|
+
|
10
|
+
TEST_DRIVER = :envjs
|
11
|
+
|
12
|
+
Capybara.app = Evergreen::Suite.new(File.expand_path('suite1', File.dirname(__FILE__))).application
|
13
|
+
Capybara.default_driver = TEST_DRIVER
|
14
|
+
|
15
|
+
module EvergreenMatchers
|
16
|
+
class PassSpec # :nodoc:
|
17
|
+
def matches?(actual)
|
18
|
+
@actual = actual
|
19
|
+
@runner = Evergreen::Runner.new(actual.suite, StringIO.new).spec_runner(@actual)
|
20
|
+
@runner.passed?
|
21
|
+
end
|
22
|
+
|
23
|
+
def failure_message
|
24
|
+
"expected #{@actual.name} to pass, but it failed with:\n\n#{@runner.failure_messages}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def negative_failure_message
|
28
|
+
"expected #{@actual.name} not to pass, but it did"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def pass
|
33
|
+
PassSpec.new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec.configure do |config|
|
38
|
+
config.include EvergreenMatchers
|
39
|
+
config.before do
|
40
|
+
Evergreen.use_defaults!
|
41
|
+
Evergreen.driver = TEST_DRIVER
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_spec.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evergreen::Spec do
|
4
|
+
let(:root) { File.expand_path('suite1', File.dirname(__FILE__)) }
|
5
|
+
let(:suite) { Evergreen::Suite.new(root) }
|
6
|
+
subject { Evergreen::Spec.new(suite, 'testing_spec.js') }
|
7
|
+
|
8
|
+
its(:name) { should == 'testing_spec.js' }
|
9
|
+
its(:root) { should == root }
|
10
|
+
its(:full_path) { should == "#{root}/spec/javascripts/testing_spec.js" }
|
11
|
+
its(:url) { should == "/run/testing_spec.js" }
|
12
|
+
its(:contents) { should =~ /describe\('testing'/ }
|
13
|
+
|
14
|
+
context "with coffeescript" do
|
15
|
+
subject { Evergreen::Spec.new(suite, 'coffeescript_spec.coffee') }
|
16
|
+
its(:contents) { should =~ /describe\('coffeescript', function/ }
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with existing spec file" do
|
20
|
+
it { should exist }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with missing spec file" do
|
24
|
+
subject { Evergreen::Spec.new(suite, 'does_not_exist.js') }
|
25
|
+
it { should_not exist }
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|