are_we_there_yet 0.1.0
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/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +30 -0
- data/LICENSE.txt +20 -0
- data/README.md +41 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/are_we_there_yet.gemspec +64 -0
- data/lib/are_we_there_yet.rb +74 -0
- data/spec/are_we_there_yet_spec.rb +173 -0
- data/spec/spec_helper.rb +44 -0
- metadata +164 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
gem "sqlite3", "~>1.3.0"
|
3
|
+
# Add dependencies to develop your gem here.
|
4
|
+
# Include everything needed to run rake, tests, features, etc.
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem "rspec", "~> 2.7.0"
|
8
|
+
gem "bundler", "~> 1.0.0"
|
9
|
+
gem "jeweler", "~> 1.6.4"
|
10
|
+
gem "rcov", ">= 0"
|
11
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.6.4)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
rake (0.9.2.2)
|
11
|
+
rcov (0.9.11)
|
12
|
+
rspec (2.7.0)
|
13
|
+
rspec-core (~> 2.7.0)
|
14
|
+
rspec-expectations (~> 2.7.0)
|
15
|
+
rspec-mocks (~> 2.7.0)
|
16
|
+
rspec-core (2.7.1)
|
17
|
+
rspec-expectations (2.7.0)
|
18
|
+
diff-lcs (~> 1.1.2)
|
19
|
+
rspec-mocks (2.7.0)
|
20
|
+
sqlite3 (1.3.5)
|
21
|
+
|
22
|
+
PLATFORMS
|
23
|
+
ruby
|
24
|
+
|
25
|
+
DEPENDENCIES
|
26
|
+
bundler (~> 1.0.0)
|
27
|
+
jeweler (~> 1.6.4)
|
28
|
+
rcov
|
29
|
+
rspec (~> 2.7.0)
|
30
|
+
sqlite3 (~> 1.3.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Rory McKinley
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# README
|
2
|
+
|
3
|
+
## About
|
4
|
+
|
5
|
+
AreWeThereYet is a gem that provides alternative profiling for RSpec 1.3.x for those who are not blessed enough to be using all the
|
6
|
+
crunchy goodness that is RSpec 2.x. Metrics are tracked per file and per example in a SQLite3 database. The location of the
|
7
|
+
database is passed through as a parameter when running the specs
|
8
|
+
|
9
|
+
AWTY only logs data, so you are currently required to handroll any reporting functionality. There is also, currently no data output
|
10
|
+
to STDOUT when spec runs with this formatter.
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
Usage is fairly simple:
|
15
|
+
|
16
|
+
1. Add `require 'are_we_there_yet'` to your `spec_helper.rb` file.
|
17
|
+
2. When running the specs pass the name of the class together with the location of your SQLite3 database, e.g:
|
18
|
+
`spec -fAreWeThereYet:/path/to/db.sqlite3 spec`
|
19
|
+
|
20
|
+
## License
|
21
|
+
|
22
|
+
Copyright (c) 2012 Rory McKinley
|
23
|
+
|
24
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
25
|
+
a copy of this software and associated documentation files (the
|
26
|
+
"Software"), to deal in the Software without restriction, including
|
27
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
28
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
29
|
+
permit persons to whom the Software is furnished to do so, subject to
|
30
|
+
the following conditions:
|
31
|
+
|
32
|
+
The above copyright notice and this permission notice shall be
|
33
|
+
included in all copies or substantial portions of the Software.
|
34
|
+
|
35
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
36
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
37
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
38
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
39
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
40
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
41
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "are_we_there_yet"
|
18
|
+
gem.homepage = "http://github.com/rorymckinley/are_we_there_yet"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Profiler for RSpec 1.3.x}
|
21
|
+
gem.description = %Q{Provides detailed profiling data for RSpec runs in a SQLite3 DB}
|
22
|
+
gem.email = "rorymckinley@gmail.com"
|
23
|
+
gem.authors = ["Rory McKinley"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "are_we_there_yet #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{are_we_there_yet}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Rory McKinley"]
|
12
|
+
s.date = %q{2012-01-09}
|
13
|
+
s.description = %q{Provides detailed profiling data for RSpec runs in a SQLite3 DB}
|
14
|
+
s.email = %q{rorymckinley@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.md",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"are_we_there_yet.gemspec",
|
29
|
+
"lib/are_we_there_yet.rb",
|
30
|
+
"spec/are_we_there_yet_spec.rb",
|
31
|
+
"spec/spec_helper.rb"
|
32
|
+
]
|
33
|
+
s.homepage = %q{http://github.com/rorymckinley/are_we_there_yet}
|
34
|
+
s.licenses = ["MIT"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = %q{1.3.7}
|
37
|
+
s.summary = %q{Profiler for RSpec 1.3.x}
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
41
|
+
s.specification_version = 3
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
+
s.add_runtime_dependency(%q<sqlite3>, ["~> 1.3.0"])
|
45
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.7.0"])
|
46
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
47
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
48
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<sqlite3>, ["~> 1.3.0"])
|
51
|
+
s.add_dependency(%q<rspec>, ["~> 2.7.0"])
|
52
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
53
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
54
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
55
|
+
end
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<sqlite3>, ["~> 1.3.0"])
|
58
|
+
s.add_dependency(%q<rspec>, ["~> 2.7.0"])
|
59
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
61
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require "spec/runner/formatter/base_formatter" unless defined? AWTY_SPEC_RUN
|
2
|
+
require 'sqlite3'
|
3
|
+
|
4
|
+
class AreWeThereYet < Spec::Runner::Formatter::BaseFormatter
|
5
|
+
def initialize(options,where)
|
6
|
+
@db = SQLite3::Database.new(where)
|
7
|
+
|
8
|
+
create_tables
|
9
|
+
end
|
10
|
+
|
11
|
+
def example_started(example)
|
12
|
+
@start = Time.now
|
13
|
+
end
|
14
|
+
|
15
|
+
def example_passed(example)
|
16
|
+
@db.transaction do |db|
|
17
|
+
location_id = persist_file(db, example)
|
18
|
+
|
19
|
+
example_id = persist_example(db, example, location_id)
|
20
|
+
|
21
|
+
db.execute(
|
22
|
+
"INSERT INTO metrics(example_id, execution_time) VALUES(:example_id, :execution_time)",
|
23
|
+
:example_id => db.last_insert_row_id,
|
24
|
+
:execution_time => Time.now - @start
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def persist_file(db, example)
|
32
|
+
path = example.location.split(':').first
|
33
|
+
|
34
|
+
locations = db.execute("SELECT id FROM files WHERE path = :path", :path => path)
|
35
|
+
if locations.empty?
|
36
|
+
db.execute("INSERT INTO files(path) VALUES(:path)", :path => path)
|
37
|
+
db.last_insert_row_id
|
38
|
+
else
|
39
|
+
locations.first[0]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def persist_example(db, example, file_id)
|
44
|
+
examples = db.execute(
|
45
|
+
"SELECT id FROM examples WHERE file_id = :file_id AND description = :description",
|
46
|
+
:file_id => file_id,
|
47
|
+
:description => example.description
|
48
|
+
)
|
49
|
+
if examples.empty?
|
50
|
+
db.execute(
|
51
|
+
"INSERT INTO examples(file_id, description) VALUES(:file_id, :description)",
|
52
|
+
:file_id => file_id,
|
53
|
+
:description => example.description
|
54
|
+
)
|
55
|
+
db.last_insert_row_id
|
56
|
+
else
|
57
|
+
examples.first[0]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def create_tables
|
62
|
+
existing_tables = @db.execute("SELECT name FROM sqlite_master")
|
63
|
+
|
64
|
+
if existing_tables.empty?
|
65
|
+
@db.transaction do |db|
|
66
|
+
db.execute("CREATE TABLE files(id INTEGER PRIMARY KEY, path VARCHAR(255))")
|
67
|
+
db.execute("CREATE INDEX path ON files (path)")
|
68
|
+
db.execute("CREATE TABLE examples(id INTEGER PRIMARY KEY, file_id INTEGER, description TEXT)")
|
69
|
+
db.execute("CREATE INDEX file_description ON examples (file_id, description)")
|
70
|
+
db.execute("CREATE TABLE metrics(id INTEGER PRIMARY KEY, example_id INTEGER, execution_time FLOAT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AreWeThereYet do
|
4
|
+
before(:each) do
|
5
|
+
@db_name = "/tmp/arewethereyet.sqlite"
|
6
|
+
File.unlink(@db_name) if File.exists? @db_name
|
7
|
+
end
|
8
|
+
|
9
|
+
it "extends the RSpec formatter" do
|
10
|
+
AreWeThereYet.should < Spec::Runner::Formatter::BaseFormatter
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#initialize" do
|
14
|
+
it "opens a connection to the specified database" do
|
15
|
+
SQLite3::Database.should_receive(:new).with('/path/to/db.sqlite').and_return(mock(SQLite3::Database).as_null_object)
|
16
|
+
AreWeThereYet.new({},'/path/to/db.sqlite')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "creates the necessary tables in the database" do
|
20
|
+
AreWeThereYet.new({},@db_name)
|
21
|
+
table_exists?(@db_name, 'files').should be_true
|
22
|
+
table_exists?(@db_name, 'examples').should be_true
|
23
|
+
table_exists?(@db_name, 'metrics').should be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "creates the necessary indexes" do
|
27
|
+
AreWeThereYet.new({},@db_name)
|
28
|
+
index_exists?(@db_name, 'files', 'path').should be_true
|
29
|
+
index_exists?(@db_name, 'examples', 'file_description').should be_true
|
30
|
+
end
|
31
|
+
|
32
|
+
it "does not create the tables if they already exist" do
|
33
|
+
AreWeThereYet.new({},@db_name)
|
34
|
+
SQLite3::Database.any_instance.should_not_receive(:execute)
|
35
|
+
|
36
|
+
AreWeThereYet.new({}, @db_name)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "rolls back table creation on error" do
|
40
|
+
connection = SQLite3::Database.new(@db_name)
|
41
|
+
connection.stub(:execute) do |arg|
|
42
|
+
if arg =~ /metrics/
|
43
|
+
raise RuntimeError
|
44
|
+
else
|
45
|
+
connection.execute2(arg)
|
46
|
+
[]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
SQLite3::Database.should_receive(:new).and_return(connection)
|
50
|
+
|
51
|
+
expect { AreWeThereYet.new({},@db_name) }.should raise_error
|
52
|
+
|
53
|
+
connection.execute2("SELECT name FROM sqlite_master").size.should == 1 # Execute2 lists fields - size 1 means empty response
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "logging a metric for a new file" do
|
58
|
+
before(:each) do
|
59
|
+
@awty = AreWeThereYet.new({}, @db_name)
|
60
|
+
@mock_example = mock(Spec::Example::ExampleProxy, :location => "/path/to/spec:42", :description => "blaah")
|
61
|
+
end
|
62
|
+
|
63
|
+
it "creates an entry for the example's file" do
|
64
|
+
@awty.example_started(@mock_example)
|
65
|
+
@awty.example_passed(@mock_example)
|
66
|
+
|
67
|
+
files = SQLite3::Database.new(@db_name).execute("SELECT id, path FROM files")
|
68
|
+
files.size.should == 1
|
69
|
+
files.first[1].should == @mock_example.location.split(':').first
|
70
|
+
end
|
71
|
+
|
72
|
+
it "creates an entry for the example itself" do
|
73
|
+
@awty.example_started(@mock_example)
|
74
|
+
@awty.example_passed(@mock_example)
|
75
|
+
|
76
|
+
connection = SQLite3::Database.new(@db_name)
|
77
|
+
file = connection.get_first_row("SELECT id FROM files")
|
78
|
+
file_id = file.first
|
79
|
+
examples = connection.execute("SELECT id, file_id, description FROM examples")
|
80
|
+
|
81
|
+
examples.size.should == 1
|
82
|
+
examples.first[1].should == file_id
|
83
|
+
examples.first[2].should == @mock_example.description
|
84
|
+
end
|
85
|
+
|
86
|
+
it "creates an entry for the total execution time" do
|
87
|
+
start_time = Time.now - 10
|
88
|
+
end_time = Time.now
|
89
|
+
|
90
|
+
Time.should_receive(:now).and_return(start_time)
|
91
|
+
@awty.example_started(@mock_example)
|
92
|
+
|
93
|
+
Time.should_receive(:now).and_return(end_time)
|
94
|
+
@awty.example_passed(@mock_example)
|
95
|
+
|
96
|
+
connection = SQLite3::Database.new(@db_name)
|
97
|
+
example = connection.get_first_row("SELECT id FROM examples")
|
98
|
+
example_id = example.first
|
99
|
+
|
100
|
+
Time.stub!(:now)
|
101
|
+
metrics = connection.execute("SELECT id, example_id, execution_time, created_at FROM metrics")
|
102
|
+
metrics.size.should == 1
|
103
|
+
metrics.first[1].should == example_id
|
104
|
+
metrics.first[2].should == end_time - start_time
|
105
|
+
metrics.first[3].should_not be_nil
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "logging a metric for an existing file" do
|
110
|
+
before(:each) do
|
111
|
+
@awty = AreWeThereYet.new({}, @db_name)
|
112
|
+
@mock_example = mock(Spec::Example::ExampleProxy, :location => "/path/to/spec", :description => "blaah")
|
113
|
+
@another_example = mock(Spec::Example::ExampleProxy, :location => "/path/to/spec", :description => "yippee!")
|
114
|
+
end
|
115
|
+
|
116
|
+
it "creates an example linked to the existing location" do
|
117
|
+
@awty.example_started(@mock_example)
|
118
|
+
@awty.example_passed(@mock_example)
|
119
|
+
|
120
|
+
@awty.example_started(@another_example)
|
121
|
+
@awty.example_passed(@another_example)
|
122
|
+
|
123
|
+
connection = SQLite3::Database.new(@db_name)
|
124
|
+
|
125
|
+
examples = connection.execute("SELECT description FROM examples")
|
126
|
+
examples.size.should == 2
|
127
|
+
|
128
|
+
files = connection.execute("SELECT id FROM files")
|
129
|
+
files.size.should == 1
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "logging a metric for an existing example" do
|
134
|
+
before(:each) do
|
135
|
+
@awty = AreWeThereYet.new({}, @db_name)
|
136
|
+
@mock_example = mock(Spec::Example::ExampleProxy, :location => "/path/to/spec", :description => "blaah")
|
137
|
+
end
|
138
|
+
|
139
|
+
it "creates a metric linked to the example" do
|
140
|
+
@awty.example_started(@mock_example)
|
141
|
+
@awty.example_passed(@mock_example)
|
142
|
+
|
143
|
+
@awty.example_started(@mock_example)
|
144
|
+
@awty.example_passed(@mock_example)
|
145
|
+
|
146
|
+
connection = SQLite3::Database.new(@db_name)
|
147
|
+
|
148
|
+
metrics = connection.execute("SELECT id FROM metrics")
|
149
|
+
metrics.size.should == 2
|
150
|
+
|
151
|
+
examples = connection.execute("SELECT description FROM examples")
|
152
|
+
examples.size.should == 1
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "handling errors when logging" do
|
157
|
+
before(:each) do
|
158
|
+
@awty = AreWeThereYet.new({}, @db_name)
|
159
|
+
@mock_example = mock(Spec::Example::ExampleProxy, :location => "/path/to/spec", :description => "blaah")
|
160
|
+
@awty.example_started(@mock_example)
|
161
|
+
end
|
162
|
+
|
163
|
+
it "allows the error through and any changes are undone" do
|
164
|
+
connection = SQLite3::Database.new(@db_name)
|
165
|
+
connection.execute("DROP TABLE metrics")
|
166
|
+
|
167
|
+
expect { @awty.example_passed(@mock_example) }.should raise_error
|
168
|
+
|
169
|
+
connection.execute("SELECT * FROM files").should be_empty
|
170
|
+
connection.execute("SELECT * FROM examples").should be_empty
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
|
5
|
+
#Create an empty class that we will need to inherit from
|
6
|
+
|
7
|
+
module Spec
|
8
|
+
module Runner
|
9
|
+
module Formatter
|
10
|
+
class BaseFormatter
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
AWTY_SPEC_RUN = true
|
17
|
+
require 'are_we_there_yet'
|
18
|
+
|
19
|
+
# Requires supporting files with custom matchers and macros, etc,
|
20
|
+
# in ./support/ and its subdirectories.
|
21
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def table_exists?(database_location,table_name)
|
28
|
+
SQLite3::Database.new(database_location).execute(
|
29
|
+
"SELECT name FROM sqlite_master WHERE type = 'table' AND name = '#{table_name}'"
|
30
|
+
).any?
|
31
|
+
end
|
32
|
+
|
33
|
+
def index_exists?(database_location,table_name,index_name)
|
34
|
+
SQLite3::Database.new(database_location).execute(
|
35
|
+
"SELECT name FROM sqlite_master WHERE type = 'index' AND name = '#{index_name}' AND tbl_name = '#{table_name}'"
|
36
|
+
).any?
|
37
|
+
end
|
38
|
+
|
39
|
+
module Spec
|
40
|
+
module Example
|
41
|
+
class ExampleProxy
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: are_we_there_yet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
segments_generated: true
|
11
|
+
version: 0.1.0
|
12
|
+
platform: ruby
|
13
|
+
authors:
|
14
|
+
- Rory McKinley
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2012-01-09 00:00:00 +02:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 27
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 3
|
32
|
+
- 0
|
33
|
+
segments_generated: true
|
34
|
+
version: 1.3.0
|
35
|
+
requirement: *id001
|
36
|
+
prerelease: false
|
37
|
+
type: :runtime
|
38
|
+
name: sqlite3
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 19
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 7
|
49
|
+
- 0
|
50
|
+
segments_generated: true
|
51
|
+
version: 2.7.0
|
52
|
+
requirement: *id002
|
53
|
+
prerelease: false
|
54
|
+
type: :development
|
55
|
+
name: rspec
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 23
|
63
|
+
segments:
|
64
|
+
- 1
|
65
|
+
- 0
|
66
|
+
- 0
|
67
|
+
segments_generated: true
|
68
|
+
version: 1.0.0
|
69
|
+
requirement: *id003
|
70
|
+
prerelease: false
|
71
|
+
type: :development
|
72
|
+
name: bundler
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ~>
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
hash: 7
|
80
|
+
segments:
|
81
|
+
- 1
|
82
|
+
- 6
|
83
|
+
- 4
|
84
|
+
segments_generated: true
|
85
|
+
version: 1.6.4
|
86
|
+
requirement: *id004
|
87
|
+
prerelease: false
|
88
|
+
type: :development
|
89
|
+
name: jeweler
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
hash: 3
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
segments_generated: true
|
100
|
+
version: "0"
|
101
|
+
requirement: *id005
|
102
|
+
prerelease: false
|
103
|
+
type: :development
|
104
|
+
name: rcov
|
105
|
+
description: Provides detailed profiling data for RSpec runs in a SQLite3 DB
|
106
|
+
email: rorymckinley@gmail.com
|
107
|
+
executables: []
|
108
|
+
|
109
|
+
extensions: []
|
110
|
+
|
111
|
+
extra_rdoc_files:
|
112
|
+
- LICENSE.txt
|
113
|
+
- README.md
|
114
|
+
files:
|
115
|
+
- .document
|
116
|
+
- .rspec
|
117
|
+
- Gemfile
|
118
|
+
- Gemfile.lock
|
119
|
+
- LICENSE.txt
|
120
|
+
- README.md
|
121
|
+
- Rakefile
|
122
|
+
- VERSION
|
123
|
+
- are_we_there_yet.gemspec
|
124
|
+
- lib/are_we_there_yet.rb
|
125
|
+
- spec/are_we_there_yet_spec.rb
|
126
|
+
- spec/spec_helper.rb
|
127
|
+
has_rdoc: true
|
128
|
+
homepage: http://github.com/rorymckinley/are_we_there_yet
|
129
|
+
licenses:
|
130
|
+
- MIT
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
hash: 3
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
segments_generated: true
|
145
|
+
version: "0"
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
hash: 3
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
segments_generated: true
|
155
|
+
version: "0"
|
156
|
+
requirements: []
|
157
|
+
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 1.3.7
|
160
|
+
signing_key:
|
161
|
+
specification_version: 3
|
162
|
+
summary: Profiler for RSpec 1.3.x
|
163
|
+
test_files: []
|
164
|
+
|