ruby-plsql-spec 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --backtrace
data/Gemfile CHANGED
@@ -1,9 +1,9 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'jeweler'
4
- gem 'rspec', '~> 1.3.0'
4
+ gem 'rspec', '~> 2.0.1'
5
5
  gem 'thor', '~> 0.14.2'
6
- gem 'ruby-plsql', '~> 0.4.3'
6
+ gem 'ruby-plsql', '~> 0.4.4'
7
7
  gem 'nokogiri', '>= 1.4.3'
8
8
 
9
9
  platforms :ruby do
data/History.txt CHANGED
@@ -1,3 +1,14 @@
1
+ == 0.2.1 2010-10-22
2
+
3
+ * Changes
4
+ * Use latest ruby-plsql version 0.4.4
5
+
6
+ == 0.2.0 2010-10-22
7
+
8
+ * Changes
9
+ * Upgraded to use RSpec 2.0
10
+ * Added --html option for plsql-spec run
11
+
1
12
  == 0.1.0 2010-10-01
2
13
 
3
14
  * Initial release
data/README.markdown CHANGED
@@ -65,6 +65,15 @@ You can get additional help about `plsql-spec` command line utility with
65
65
 
66
66
  plsql-spec help
67
67
 
68
+ Generating HTML RSpec output
69
+ ----------------------------
70
+
71
+ If you would like to see a colour HTML report about the test results, just run the tests with --html option:
72
+
73
+ plsql-spec run --html [filename]
74
+
75
+ HTML report will be generated to [filename] file. If you don't specify filename, then it will generated to test-results.html. You can open it in your browser.
76
+
68
77
  Code coverage reporting
69
78
  -----------------------
70
79
 
@@ -84,8 +93,30 @@ Read blog post about [Oracle PL/SQL unit testing with Ruby](http://blog.rayapps.
84
93
  If you are not familiar with Ruby I recommend to start with [Ruby in Twenty Minutes](http://www.ruby-lang.org/en/documentation/quickstart/) tutorial. Then you can take a look on some [RSpec examples](http://rspec.info/documentation/) how to write and structure tests. And then you can take a look at [ruby-plsql own tests](http://github.com/rsim/ruby-plsql/blob/master/spec/plsql/procedure_spec.rb) to see how to pass parameters and verify results for different PL/SQL data types.
85
94
 
86
95
  How to customize ruby-plsql-spec for my project?
87
- --------------------------------------------
96
+ ------------------------------------------------
88
97
 
89
98
  * Review spec/spec_helper.rb file and modify if needed directories where you will store additional required files (helper files, factory files, source files).
90
99
  * Review and or create new helper files in `spec\helpers` directory.
91
100
  * Create new factory methods for test data creation in `factories` directory (see example in `examples/spec/factories`).
101
+
102
+ How to upgrade ruby-plsql-spec to latest version
103
+ ------------------------------------------------
104
+
105
+ You can see current ruby-plsql-spec version with
106
+
107
+ plsql-spec -v
108
+
109
+ If you want to upgrade ruby-plsql-spec to latest version then just do
110
+
111
+ gem install ruby-plsql-spec
112
+
113
+ If you have upgrade from ruby-plsql-spec version 0.1.0 to 0.2.0 then you need to update your spec_helper.rb file to use rspec 2.0. You can do it by running one more time
114
+
115
+ plsql-spec init
116
+
117
+ which will check which current files are different from the latest templates. You need to update just spec_helper.rb file. When you will be prompted to overwrite spec_helper.rb file then at first you can enter `d` to see differences between current file and new template. If you have not changed original spec_helper.rb file then you will see just one difference
118
+
119
+ - Spec::Runner.configure do |config|
120
+ + RSpec.configure do |config|
121
+
122
+ You can then answer `y` and this file will be updated. When you will be prompted to overwrite other files then you can review the changes in the same way and decide if you want them to be overwritten or not.
data/Rakefile CHANGED
@@ -12,26 +12,24 @@ EOS
12
12
  gem.email = "raimonds.simanovskis@gmail.com"
13
13
  gem.homepage = "http://github.com/rsim/ruby-plsql-spec"
14
14
  gem.authors = ["Raimonds Simanovskis"]
15
- gem.add_dependency "ruby-plsql", ">= 0.4.3"
15
+ gem.add_dependency "ruby-plsql", ">= 0.4.4"
16
16
  gem.add_dependency "thor", ">= 0.14.2"
17
- gem.add_dependency "rspec", "~> 1.3.0"
17
+ gem.add_dependency "rspec", ">= 2.0.1"
18
18
  end
19
19
  Jeweler::GemcutterTasks.new
20
20
  rescue LoadError
21
21
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
22
  end
23
23
 
24
- require 'spec/rake/spectask'
25
- Spec::Rake::SpecTask.new(:spec) do |spec|
26
- spec.libs << 'lib' << 'spec'
27
- spec.spec_files = FileList['spec/plsql/**/*_spec.rb']
24
+ require 'rspec/core/rake_task'
25
+ RSpec::Core::RakeTask.new(:spec) do |t|
26
+ t.pattern = 'spec/plsql/**/*_spec.rb'
28
27
  end
29
28
 
30
- Spec::Rake::SpecTask.new(:rcov) do |spec|
31
- spec.libs << 'lib' << 'spec'
32
- spec.pattern = 'spec/plsql/**/*_spec.rb'
33
- spec.rcov = true
34
- spec.rcov_opts = ['--exclude', '/Library,spec/']
29
+ RSpec::Core::RakeTask.new(:rcov) do |t|
30
+ t.rcov = true
31
+ t.rcov_opts = ['--exclude', '/Library,spec/']
32
+ t.pattern = 'spec/plsql/**/*_spec.rb'
35
33
  end
36
34
 
37
35
  task :spec => :check_dependencies
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.1
@@ -47,7 +47,7 @@ at_exit do
47
47
  end
48
48
  end
49
49
 
50
- Spec::Runner.configure do |config|
50
+ RSpec.configure do |config|
51
51
  config.before(:each) do
52
52
  database_connections.each do |name|
53
53
  plsql(name).savepoint "before_each"
data/lib/plsql/spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'spec'
1
+ require 'rspec'
2
2
  require 'ruby-plsql'
3
3
  require 'plsql/coverage'
4
4
  require 'plsql/spec/cli'
@@ -1,6 +1,10 @@
1
1
  require 'thor'
2
2
  require 'thor/actions'
3
3
 
4
+ # use plsql-spec for showing diff of files
5
+ # by defuault Thor uses diff utility which is not available on Windows
6
+ ENV['THOR_DIFF'] = 'plsql-spec diff'
7
+
4
8
  module PLSQL
5
9
  module Spec
6
10
  class CLI < ::Thor
@@ -29,6 +33,7 @@ Create tests in spec/ directory (or in subdirectories of it) in *_spec.rb files.
29
33
 
30
34
  Run created tests with "plsql-spec run".
31
35
  Run tests with "plsql-spec run --coverage" to generate code coverage report in coverage/ directory.
36
+ Run tests with "plsql-spec run --html" to generate RSpec report to test-results.html file.
32
37
  EOS
33
38
  end
34
39
 
@@ -37,6 +42,9 @@ EOS
37
42
  :type => :boolean,
38
43
  :default => false,
39
44
  :banner => "show DBMS_OUTPUT messages"
45
+ method_option :"html",
46
+ :type => :string,
47
+ :banner => "generate HTML RSpec output to specified file (default is test-results.html)"
40
48
  method_option :coverage,
41
49
  :type => :string,
42
50
  :banner => "generate code coverage report in specified directory (defaults to coverage/)"
@@ -52,27 +60,53 @@ EOS
52
60
  exit 1
53
61
  end
54
62
  ENV['PLSQL_DBMS_OUTPUT'] = 'true' if options[:"dbms-output"]
63
+ ENV['PLSQL_HTML'] = options[:html] if options[:html]
55
64
  ENV['PLSQL_COVERAGE'] = options[:coverage] if options[:coverage]
56
65
  ENV['PLSQL_COVERAGE_IGNORE_SCHEMAS'] = options[:"ignore-schemas"].join(',') if options[:"ignore-schemas"]
57
66
  ENV['PLSQL_COVERAGE_LIKE'] = options[:like].join(',') if options[:like]
67
+
68
+ if options[:html]
69
+ # if there is no filename given, the options[:html] == "html"
70
+ spec_output_filename = options[:html] == 'html' ? 'test-results.html' : options[:html]
71
+
72
+ speccommand = "rspec --format html --out #{spec_output_filename}"
73
+ else
74
+ speccommand = "rspec"
75
+ end
76
+
58
77
  if files.empty?
59
78
  say "Running all specs from spec/", :yellow
60
- puts run('spec spec', :verbose => false)
79
+ puts run("#{speccommand} spec", :verbose => false)
61
80
  else
62
81
  say "Running specs from #{files.join(', ')}", :yellow
63
- puts run("spec #{files.join(' ')}", :verbose => false)
82
+ puts run("#{speccommand} #{files.join(' ')}", :verbose => false)
64
83
  end
84
+
85
+ if options[:html]
86
+ say "Test results in #{spec_output_filename}"
87
+ end
88
+
89
+ if options[:coverage]
90
+ say "Coverage report in #{options[:coverage]}/index.html"
91
+ end
92
+
65
93
  unless $?.exitstatus == 0
66
94
  say "Failing tests!", :red
67
95
  exit 1
68
96
  end
69
97
  end
70
98
 
99
+ desc 'diff [FILE1] [FILE2]', 'show difference between files'
100
+ def diff(file1, file2)
101
+ differ = RSpec::Expectations::Differ.new
102
+ say differ.diff_as_string File.read(file2), File.read(file1)
103
+ end
104
+
71
105
  desc '-v', 'show ruby-plsql-spec and ruby-plsql version'
72
106
  def version
73
107
  say "ruby-plsql-spec #{PLSQL::Spec::VERSION}"
74
108
  say "ruby-plsql #{PLSQL::VERSION}"
75
- say "rspec #{::Spec::VERSION::STRING}"
109
+ say "rspec #{::RSpec::Version::STRING}"
76
110
  end
77
111
 
78
112
  end
@@ -47,7 +47,7 @@ at_exit do
47
47
  end
48
48
  end
49
49
 
50
- Spec::Runner.configure do |config|
50
+ RSpec.configure do |config|
51
51
  config.before(:each) do
52
52
  database_connections.each do |name|
53
53
  plsql(name).savepoint "before_each"
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruby-plsql-spec}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Raimonds Simanovskis"]
12
- s.date = %q{2010-10-05}
12
+ s.date = %q{2010-10-22}
13
13
  s.default_executable = %q{plsql-spec}
14
14
  s.description = %q{ruby-plsql-spec is Oracle PL/SQL unit testing framework which is built using Ruby programming language, ruby-plsql library and RSpec testing framework.
15
15
  }
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  ]
21
21
  s.files = [
22
22
  ".gitignore",
23
+ ".rspec",
23
24
  "Gemfile",
24
25
  "History.txt",
25
26
  "INSTALL-Windows.markdown",
@@ -63,7 +64,6 @@ Gem::Specification.new do |s|
63
64
  "ruby-plsql-spec.gemspec",
64
65
  "spec/plsql/coverage_spec.rb",
65
66
  "spec/plsql/spec/cli_spec.rb",
66
- "spec/spec.opts",
67
67
  "spec/spec_helper.rb"
68
68
  ]
69
69
  s.homepage = %q{http://github.com/rsim/ruby-plsql-spec}
@@ -96,18 +96,18 @@ Gem::Specification.new do |s|
96
96
  s.specification_version = 3
97
97
 
98
98
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
99
- s.add_runtime_dependency(%q<ruby-plsql>, [">= 0.4.3"])
99
+ s.add_runtime_dependency(%q<ruby-plsql>, [">= 0.4.4"])
100
100
  s.add_runtime_dependency(%q<thor>, [">= 0.14.2"])
101
- s.add_runtime_dependency(%q<rspec>, ["~> 1.3.0"])
101
+ s.add_runtime_dependency(%q<rspec>, [">= 2.0.1"])
102
102
  else
103
- s.add_dependency(%q<ruby-plsql>, [">= 0.4.3"])
103
+ s.add_dependency(%q<ruby-plsql>, [">= 0.4.4"])
104
104
  s.add_dependency(%q<thor>, [">= 0.14.2"])
105
- s.add_dependency(%q<rspec>, ["~> 1.3.0"])
105
+ s.add_dependency(%q<rspec>, [">= 2.0.1"])
106
106
  end
107
107
  else
108
- s.add_dependency(%q<ruby-plsql>, [">= 0.4.3"])
108
+ s.add_dependency(%q<ruby-plsql>, [">= 0.4.4"])
109
109
  s.add_dependency(%q<thor>, [">= 0.14.2"])
110
- s.add_dependency(%q<rspec>, ["~> 1.3.0"])
110
+ s.add_dependency(%q<rspec>, [">= 2.0.1"])
111
111
  end
112
112
  end
113
113
 
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
3
  describe "Coverage" do
4
4
  def drop_profiler_tables
@@ -158,6 +158,10 @@ END;
158
158
  adjust_test_coverage
159
159
  end
160
160
 
161
+ after(:all) do
162
+ PLSQL::Coverage.cleanup
163
+ end
164
+
161
165
  describe "details report" do
162
166
  before(:all) do
163
167
  @details_doc = Nokogiri::HTML(File.read(File.join(@directory, "#{DATABASE_USER.upcase}-TEST_PROFILER.html")))
@@ -196,13 +200,13 @@ END;
196
200
 
197
201
  end
198
202
 
199
- describe "index repot" do
203
+ describe "index report" do
200
204
  before(:all) do
201
205
  @index_doc = Nokogiri::HTML(File.read(File.join(@directory, "index.html")))
202
206
  end
203
207
 
204
208
  it "should generate HTML table with coverage percentage" do
205
- @index_doc.css("table.report tbody div.percent_graph_legend").map{|div| div.text}.should == expected_coverages
209
+ @index_doc.css("table.report tbody tr:contains('HR.TEST_PROFILER') div.percent_graph_legend").map{|div| div.text}.should == expected_coverages
206
210
  @index_doc.css("table.report tfoot div.percent_graph_legend").map{|div| div.text}.should == expected_coverages
207
211
  end
208
212
 
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe "plsql-spec" do
4
4
 
@@ -241,6 +241,40 @@ EOS
241
241
 
242
242
  end
243
243
 
244
+ describe "with html output" do
245
+ before(:all) do
246
+ create_test 'SYSDATE should not be NULL',
247
+ 'plsql.sysdate.should_not == NULL'
248
+ @default_html_file = File.join(@root_dir, 'test-results.html')
249
+ @custom_file_name = 'custom-results.html'
250
+ @custom_html_file = File.join(@root_dir, @custom_file_name)
251
+ end
252
+
253
+ def delete_html_output_files
254
+ FileUtils.rm_rf @default_html_file
255
+ FileUtils.rm_rf @custom_html_file
256
+ end
257
+
258
+ before(:each) do
259
+ delete_html_output_files
260
+ end
261
+
262
+ after(:all) do
263
+ delete_html_output_files
264
+ end
265
+
266
+ it "should create default report file" do
267
+ run_cli('run', '--html')
268
+ File.read(@default_html_file).should =~ / 0 failures/
269
+ end
270
+
271
+ it "should create specified report file" do
272
+ run_cli('run', '--html', @custom_file_name)
273
+ File.read(@custom_html_file).should =~ / 0 failures/
274
+ end
275
+
276
+ end
277
+
244
278
  end
245
279
 
246
280
  describe "version" do
@@ -257,8 +291,33 @@ EOS
257
291
  end
258
292
 
259
293
  it "should show rspec version" do
260
- @stdout.should =~ /rspec\s+#{::Spec::VERSION::STRING.gsub('.','\.')}/
294
+ @stdout.should =~ /rspec\s+#{::RSpec::Version::STRING.gsub('.','\.')}/
295
+ end
296
+
297
+ end
298
+
299
+ describe "diff" do
300
+ before(:all) do
301
+ @test_strings = %w(test1 test2)
302
+ @test_files = %w(test1.txt test2.txt)
303
+ @test_strings.each_with_index do |string, i|
304
+ File.open(File.join(@root_dir, @test_files[i]), 'w') do |file|
305
+ file.write(string)
306
+ end
307
+ end
308
+ run_cli('diff', *@test_files.map{|file| File.join(@root_dir, file)})
309
+ end
310
+
311
+ after(:all) do
312
+ @test_files.each do |file|
313
+ FileUtils.rm_f(File.join(@root_dir, file))
314
+ end
261
315
  end
262
316
 
317
+ it "should show diff" do
318
+ @stdout.should =~ /^\-#{@test_strings[0]}$/
319
+ @stdout.should =~ /^\+#{@test_strings[1]}$/
320
+ end
263
321
  end
322
+
264
323
  end
data/spec/spec_helper.rb CHANGED
@@ -1,20 +1,10 @@
1
1
  require "rubygems"
2
-
3
- # Set up gems listed in the Gemfile.
4
- gemfile = File.expand_path('../../Gemfile', __FILE__)
5
- begin
6
- ENV['BUNDLE_GEMFILE'] = gemfile
7
- require 'bundler'
8
- Bundler.setup
9
- rescue Bundler::GemNotFound => e
10
- STDERR.puts e.message
11
- STDERR.puts "Try running `bundle install`."
12
- exit!
13
- end if File.exist?(gemfile)
2
+ require "bundler"
3
+ Bundler.setup(:default)
14
4
 
15
5
  $:.unshift(File.expand_path('../../lib', __FILE__))
16
6
 
17
- require 'spec'
7
+ require 'rspec'
18
8
  require 'nokogiri'
19
9
 
20
10
  require 'ruby-plsql-spec'
@@ -33,7 +23,7 @@ CONNECTION_PARAMS = {
33
23
  CONNECTION_PARAMS[:host] = DATABASE_HOST if defined?(DATABASE_HOST)
34
24
  CONNECTION_PARAMS[:port] = DATABASE_PORT if defined?(DATABASE_PORT)
35
25
 
36
- Spec::Runner.configure do |config|
26
+ RSpec.configure do |config|
37
27
  # taken from thor specs
38
28
  def capture(stream)
39
29
  begin
@@ -57,5 +47,9 @@ Spec::Runner.configure do |config|
57
47
  File.join(File.dirname(__FILE__), 'sandbox')
58
48
  end
59
49
 
60
-
61
50
  end
51
+
52
+ # set default time zone in TZ environment variable
53
+ # which will be used to set session time zone
54
+ ENV['TZ'] ||= 'Europe/Riga'
55
+ # ENV['TZ'] ||= 'UTC'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-plsql-spec
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 2
8
9
  - 1
9
- - 0
10
- version: 0.1.0
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Raimonds Simanovskis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-05 00:00:00 +03:00
18
+ date: 2010-10-22 00:00:00 +03:00
19
19
  default_executable: plsql-spec
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 9
29
+ hash: 7
30
30
  segments:
31
31
  - 0
32
32
  - 4
33
- - 3
34
- version: 0.4.3
33
+ - 4
34
+ version: 0.4.4
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -56,14 +56,14 @@ dependencies:
56
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ~>
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- hash: 27
61
+ hash: 13
62
62
  segments:
63
- - 1
64
- - 3
63
+ - 2
65
64
  - 0
66
- version: 1.3.0
65
+ - 1
66
+ version: 2.0.1
67
67
  type: :runtime
68
68
  version_requirements: *id003
69
69
  description: |
@@ -78,6 +78,7 @@ extra_rdoc_files:
78
78
  - README.markdown
79
79
  files:
80
80
  - .gitignore
81
+ - .rspec
81
82
  - Gemfile
82
83
  - History.txt
83
84
  - INSTALL-Windows.markdown
@@ -121,7 +122,6 @@ files:
121
122
  - ruby-plsql-spec.gemspec
122
123
  - spec/plsql/coverage_spec.rb
123
124
  - spec/plsql/spec/cli_spec.rb
124
- - spec/spec.opts
125
125
  - spec/spec_helper.rb
126
126
  has_rdoc: true
127
127
  homepage: http://github.com/rsim/ruby-plsql-spec
data/spec/spec.opts DELETED
@@ -1,6 +0,0 @@
1
- --colour
2
- --format
3
- progress
4
- --loadby
5
- mtime
6
- --reverse