slacker 1.0.14 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/README.markdown +22 -22
- data/Rakefile +11 -11
- data/bin/slacker +32 -32
- data/bin/slacker_new +34 -34
- data/lib/slacker.rb +180 -175
- data/lib/slacker/application.rb +224 -214
- data/lib/slacker/command_line_formatter.rb +61 -61
- data/lib/slacker/configuration.rb +59 -59
- data/lib/slacker/formatter.rb +14 -14
- data/lib/slacker/query_result_matcher.rb +178 -178
- data/lib/slacker/rspec_ext.rb +57 -57
- data/lib/slacker/rspec_monkey.rb +7 -7
- data/lib/slacker/sql.rb +39 -39
- data/lib/slacker/sql_preprocessor.rb +23 -23
- data/lib/slacker/string_helper.rb +16 -16
- data/lib/slacker/version.rb +3 -3
- data/lib/slacker_new/project/data/sample_1/my_table_expected_power_results.csv +11 -11
- data/lib/slacker_new/project/data/sample_1/my_table_initial_data.csv +11 -11
- data/lib/slacker_new/project/data/sample_1/numbers_expected_output.csv +3 -3
- data/lib/slacker_new/project/database.yml +9 -9
- data/lib/slacker_new/project/lib/helpers/my_helper.rb +1 -1
- data/lib/slacker_new/project/spec/sample_1.rb +66 -66
- data/lib/slacker_new/project/sql/sample_1/my_table_on_power.sql.erb +1 -1
- data/lib/slacker_new/project/sql/sample_1/play_with_numbers.sql.erb +16 -16
- data/lib/slacker_new/project/sql/sample_1/sysobjects_with_params.sql.erb +1 -1
- data/slacker.gemspec +27 -27
- data/spec/application_spec.rb +13 -13
- data/spec/query_result_matcher_spec.rb +268 -268
- data/spec/rspec_ext_spec.rb +87 -87
- data/spec/slacker_spec.rb +59 -59
- data/spec/spec_helper.rb +19 -9
- data/spec/test_files/matcher/test_1.csv +3 -3
- data/spec/test_files/test_slacker_project/data/test_1.csv +3 -3
- data/spec/test_files/test_slacker_project/sql/nest/nested_1.sql.erb +1 -1
- data/spec/test_files/test_slacker_project/sql/no_params.sql.erb +2 -2
- data/spec/test_files/test_slacker_project/sql/params.sql.erb +1 -1
- metadata +24 -24
data/spec/rspec_ext_spec.rb
CHANGED
@@ -1,88 +1,88 @@
|
|
1
|
-
require 'slacker'
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'ostruct'
|
4
|
-
|
5
|
-
class RSpecSlackerHost
|
6
|
-
include Slacker::RSpecExt
|
7
|
-
end
|
8
|
-
|
9
|
-
describe Slacker::RSpecExt do
|
10
|
-
before(:each) do
|
11
|
-
Slacker::configure do |config|
|
12
|
-
config.base_dir = SpecHelper.expand_test_files_path('test_slacker_project')
|
13
|
-
end
|
14
|
-
|
15
|
-
example = OpenStruct.new
|
16
|
-
example.metadata = {:sql => '', :example_group => {:file_path => SpecHelper.expand_test_files_path('test_slacker_project/spec/example_xyz.rb')}}
|
17
|
-
|
18
|
-
@instance = RSpecSlackerHost.new
|
19
|
-
@instance.stub(:example).and_return(example)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'responds to query' do
|
23
|
-
@instance.should respond_to(:query)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'responds to match' do
|
27
|
-
@instance.should respond_to(:match)
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'responds to csv' do
|
31
|
-
@instance.should respond_to(:csv)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'responds to load_csv' do
|
35
|
-
@instance.should respond_to(:load_csv)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'responds to load_csv' do
|
39
|
-
@instance.should respond_to(:touch_csv)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'responds to sql' do
|
43
|
-
@instance.should respond_to(:sql)
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'responds to ghost methods' do
|
47
|
-
before(:each) do
|
48
|
-
Slacker.application.stub(:query_script) {|sql| sql}
|
49
|
-
end
|
50
|
-
|
51
|
-
specify 'described as SQL files found in the sql/helpers folder' do
|
52
|
-
@instance.sql.respond_to?(:helpers).should
|
53
|
-
@instance.sql.helpers.respond_to?(:helper_1).should
|
54
|
-
@instance.sql.helpers.helper_1.should == 'helpers/helper_1.sql called'
|
55
|
-
end
|
56
|
-
|
57
|
-
specify 'described as SQL.ERB files found in the sql/helpers folder' do
|
58
|
-
@instance.sql.helpers.respond_to?(:helper_2).should
|
59
|
-
@instance.sql.helpers.helper_2.should == 'helpers/helper_2.sql.erb called'
|
60
|
-
end
|
61
|
-
|
62
|
-
specify 'with SQL files taking priority over SQL.ERB files' do
|
63
|
-
@instance.sql.helpers.respond_to?(:helper_3).should
|
64
|
-
@instance.sql.helpers.helper_3.should == 'helpers/helper_3.sql called'
|
65
|
-
end
|
66
|
-
|
67
|
-
specify 'but ignores non-existing methods' do
|
68
|
-
@instance.sql.helpers.respond_to?(:some_bogus_method).should
|
69
|
-
end
|
70
|
-
|
71
|
-
specify 'but ignores files which are not with SQL or SQL.ERB extension' do
|
72
|
-
@instance.sql.helpers.respond_to?(:text_file_1).should
|
73
|
-
end
|
74
|
-
|
75
|
-
specify 'from folders other than helpers' do
|
76
|
-
@instance.sql.respond_to?(:example_1).should
|
77
|
-
@instance.sql.example_1.respond_to?(:helper_1).should
|
78
|
-
@instance.sql.example_1.helper_1.should == 'example_1/helper_1.sql called'
|
79
|
-
end
|
80
|
-
|
81
|
-
specify "works with deeply nested example files reflecting their location in the lookup of SQL files in the SQL folder" do
|
82
|
-
@instance.sql.respond_to?(:nest).should
|
83
|
-
@instance.sql.nest.respond_to?(:example_1).should
|
84
|
-
@instance.sql.nest.example_1.respond_to?(:helper_1).should
|
85
|
-
@instance.sql.nest.example_1.helper_1.should == 'nest/example_1/helper_1.sql.erb called'
|
86
|
-
end
|
87
|
-
end
|
1
|
+
require 'slacker'
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
class RSpecSlackerHost
|
6
|
+
include Slacker::RSpecExt
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Slacker::RSpecExt do
|
10
|
+
before(:each) do
|
11
|
+
Slacker::configure do |config|
|
12
|
+
config.base_dir = SpecHelper.expand_test_files_path('test_slacker_project')
|
13
|
+
end
|
14
|
+
|
15
|
+
example = OpenStruct.new
|
16
|
+
example.metadata = {:sql => '', :example_group => {:file_path => SpecHelper.expand_test_files_path('test_slacker_project/spec/example_xyz.rb')}}
|
17
|
+
|
18
|
+
@instance = RSpecSlackerHost.new
|
19
|
+
@instance.stub(:example).and_return(example)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'responds to query' do
|
23
|
+
@instance.should respond_to(:query)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'responds to match' do
|
27
|
+
@instance.should respond_to(:match)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'responds to csv' do
|
31
|
+
@instance.should respond_to(:csv)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'responds to load_csv' do
|
35
|
+
@instance.should respond_to(:load_csv)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'responds to load_csv' do
|
39
|
+
@instance.should respond_to(:touch_csv)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'responds to sql' do
|
43
|
+
@instance.should respond_to(:sql)
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'responds to ghost methods' do
|
47
|
+
before(:each) do
|
48
|
+
Slacker.application.stub(:query_script) {|sql| sql}
|
49
|
+
end
|
50
|
+
|
51
|
+
specify 'described as SQL files found in the sql/helpers folder' do
|
52
|
+
@instance.sql.respond_to?(:helpers).should be true
|
53
|
+
@instance.sql.helpers.respond_to?(:helper_1).should be true
|
54
|
+
@instance.sql.helpers.helper_1.should == 'helpers/helper_1.sql called'
|
55
|
+
end
|
56
|
+
|
57
|
+
specify 'described as SQL.ERB files found in the sql/helpers folder' do
|
58
|
+
@instance.sql.helpers.respond_to?(:helper_2).should be true
|
59
|
+
@instance.sql.helpers.helper_2.should == 'helpers/helper_2.sql.erb called'
|
60
|
+
end
|
61
|
+
|
62
|
+
specify 'with SQL files taking priority over SQL.ERB files' do
|
63
|
+
@instance.sql.helpers.respond_to?(:helper_3).should be true
|
64
|
+
@instance.sql.helpers.helper_3.should == 'helpers/helper_3.sql called'
|
65
|
+
end
|
66
|
+
|
67
|
+
specify 'but ignores non-existing methods' do
|
68
|
+
@instance.sql.helpers.respond_to?(:some_bogus_method).should be false
|
69
|
+
end
|
70
|
+
|
71
|
+
specify 'but ignores files which are not with SQL or SQL.ERB extension' do
|
72
|
+
@instance.sql.helpers.respond_to?(:text_file_1).should be false
|
73
|
+
end
|
74
|
+
|
75
|
+
specify 'from folders other than helpers' do
|
76
|
+
@instance.sql.respond_to?(:example_1).should be true
|
77
|
+
@instance.sql.example_1.respond_to?(:helper_1).should be true
|
78
|
+
@instance.sql.example_1.helper_1.should == 'example_1/helper_1.sql called'
|
79
|
+
end
|
80
|
+
|
81
|
+
specify "works with deeply nested example files reflecting their location in the lookup of SQL files in the SQL folder" do
|
82
|
+
@instance.sql.respond_to?(:nest).should be true
|
83
|
+
@instance.sql.nest.respond_to?(:example_1).should be true
|
84
|
+
@instance.sql.nest.example_1.respond_to?(:helper_1).should be true
|
85
|
+
@instance.sql.nest.example_1.helper_1.should == 'nest/example_1/helper_1.sql.erb called'
|
86
|
+
end
|
87
|
+
end
|
88
88
|
end
|
data/spec/slacker_spec.rb
CHANGED
@@ -1,60 +1,60 @@
|
|
1
|
-
require 'slacker'
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Slacker do
|
5
|
-
it 'exposes a singleton application object' do
|
6
|
-
app = Slacker::application
|
7
|
-
app.should equal(Slacker::application)
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'and it''s base folder can be configured through a call to configure' do
|
11
|
-
Slacker.configure do |config|
|
12
|
-
config.base_dir = 'xyz'
|
13
|
-
end
|
14
|
-
|
15
|
-
Slacker.configuration.base_dir.should == 'xyz'
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'converts a hash array to csv' do
|
19
|
-
csv = Slacker.hash_array_to_csv [{'a' => 1, 'b' => 2}, {'a' => 3, 'b' => 4}]
|
20
|
-
csv.to_csv.should == "a,b\n1,2\n3,4\n"
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'provides SQL resolution' do
|
24
|
-
before(:each) do
|
25
|
-
Slacker.configure do |config|
|
26
|
-
config.base_dir = SpecHelper.expand_test_files_path('test_slacker_project')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
specify 'which resolves to a SQL string when a non-file is sent to it' do
|
31
|
-
Slacker.sql_from_query_string("select 'abc' as xyz").should == "select 'abc' as xyz"
|
32
|
-
end
|
33
|
-
|
34
|
-
specify 'which resolves to the correct contents of a SQL file' do
|
35
|
-
Slacker.sql_from_query_string("test_1.sql").should == "select 1;"
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'of an ERB file' do
|
39
|
-
specify 'with no params' do
|
40
|
-
Slacker.sql_from_query_string("no_params.sql.erb").should == "select 1;\nselect 2;\n"
|
41
|
-
end
|
42
|
-
|
43
|
-
specify 'with params' do
|
44
|
-
Slacker.sql_from_query_string("params.sql.erb", {:param1 => 11, :param2 => 12}).should == "select 11;\nselect 12;"
|
45
|
-
end
|
46
|
-
|
47
|
-
specify 'which calls another ERB file with no params' do
|
48
|
-
Slacker.sql_from_query_string("nested.sql.erb").should == "select 1;\nselect 2;\n"
|
49
|
-
end
|
50
|
-
|
51
|
-
specify 'which calls another ERB file with params' do
|
52
|
-
Slacker.sql_from_query_string("nested_with_params.sql.erb", {:param1 => 21, :param2 => 22}).should == "select 21;\nselect 22;"
|
53
|
-
end
|
54
|
-
|
55
|
-
specify 'which calls complex multi-nested file' do
|
56
|
-
Slacker.sql_from_query_string("multi_nested.sql.erb", {:seed => 1}).should == "seed 1;\nselect 3;\nselect 4;"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
1
|
+
require 'slacker'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Slacker do
|
5
|
+
it 'exposes a singleton application object' do
|
6
|
+
app = Slacker::application
|
7
|
+
app.should equal(Slacker::application)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'and it''s base folder can be configured through a call to configure' do
|
11
|
+
Slacker.configure do |config|
|
12
|
+
config.base_dir = 'xyz'
|
13
|
+
end
|
14
|
+
|
15
|
+
Slacker.configuration.base_dir.should == 'xyz'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'converts a hash array to csv' do
|
19
|
+
csv = Slacker.hash_array_to_csv [{'a' => 1, 'b' => 2}, {'a' => 3, 'b' => 4}]
|
20
|
+
csv.to_csv.should == "a,b\n1,2\n3,4\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'provides SQL resolution' do
|
24
|
+
before(:each) do
|
25
|
+
Slacker.configure do |config|
|
26
|
+
config.base_dir = SpecHelper.expand_test_files_path('test_slacker_project')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
specify 'which resolves to a SQL string when a non-file is sent to it' do
|
31
|
+
Slacker.sql_from_query_string("select 'abc' as xyz").should == "select 'abc' as xyz"
|
32
|
+
end
|
33
|
+
|
34
|
+
specify 'which resolves to the correct contents of a SQL file' do
|
35
|
+
Slacker.sql_from_query_string("test_1.sql").should == "select 1;"
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'of an ERB file' do
|
39
|
+
specify 'with no params' do
|
40
|
+
Slacker.sql_from_query_string("no_params.sql.erb").should == "select 1;\nselect 2;\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
specify 'with params' do
|
44
|
+
Slacker.sql_from_query_string("params.sql.erb", {:param1 => 11, :param2 => 12}).should == "select 11;\nselect 12;"
|
45
|
+
end
|
46
|
+
|
47
|
+
specify 'which calls another ERB file with no params' do
|
48
|
+
Slacker.sql_from_query_string("nested.sql.erb").should == "select 1;\nselect 2;\n"
|
49
|
+
end
|
50
|
+
|
51
|
+
specify 'which calls another ERB file with params' do
|
52
|
+
Slacker.sql_from_query_string("nested_with_params.sql.erb", {:param1 => 21, :param2 => 22}).should == "select 21;\nselect 22;"
|
53
|
+
end
|
54
|
+
|
55
|
+
specify 'which calls complex multi-nested file' do
|
56
|
+
Slacker.sql_from_query_string("multi_nested.sql.erb", {:seed => 1}).should == "seed 1;\nselect 3;\nselect 4;"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
60
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
-
module SpecHelper
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
1
|
+
module SpecHelper
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.expect_with :rspec do |c|
|
5
|
+
c.syntax = :should
|
6
|
+
end
|
7
|
+
config.mock_with :rspec do |c|
|
8
|
+
c.syntax = :should
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.expand_test_files_path(path)
|
13
|
+
File.expand_path("#{File.dirname(__FILE__)}/test_files/#{path}")
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.load_csv(file)
|
17
|
+
CSV.read(expand_test_files_path(file), {:headers => true, :encoding => 'Windows-1252'})
|
18
|
+
end
|
19
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
"Field 1","Field_2","b"
|
2
|
-
12,,""
|
3
|
-
"test string",01/30/2011,8.9
|
1
|
+
"Field 1","Field_2","b"
|
2
|
+
12,,""
|
3
|
+
"test string",01/30/2011,8.9
|
@@ -1,3 +1,3 @@
|
|
1
|
-
"Field 1","Field_2","b"
|
2
|
-
12,10,11
|
3
|
-
"test string",01/01/2011,8.9
|
1
|
+
"Field 1","Field_2","b"
|
2
|
+
12,10,11
|
3
|
+
"test string",01/01/2011,8.9
|
@@ -1,2 +1,2 @@
|
|
1
|
-
seed <%= options[:seed] %>;
|
1
|
+
seed <%= options[:seed] %>;
|
2
2
|
<%= render 'nested_2.sql.erb', {:seed => options[:seed] + 1}%>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%2.times do |i|%>
|
2
|
-
select <%=i+1%>;
|
1
|
+
<%2.times do |i|%>
|
2
|
+
select <%=i+1%>;
|
3
3
|
<%end%>
|
@@ -1,2 +1,2 @@
|
|
1
|
-
select <%= options[:param1] %>;
|
1
|
+
select <%= options[:param1] %>;
|
2
2
|
select <%= options[:param2] %>;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vassil Kovatchev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -144,34 +144,34 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project: slacker
|
147
|
-
rubygems_version: 2.6.
|
147
|
+
rubygems_version: 2.6.7
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Behavior Driven Development for SQL Server
|
151
151
|
test_files:
|
152
|
-
- spec/
|
153
|
-
- spec/
|
154
|
-
- spec/
|
155
|
-
- spec/
|
152
|
+
- spec/application_spec.rb
|
153
|
+
- spec/query_result_matcher_spec.rb
|
154
|
+
- spec/rspec_ext_spec.rb
|
155
|
+
- spec/slacker_spec.rb
|
156
|
+
- spec/spec_helper.rb
|
157
|
+
- spec/test_files/matcher/completely_blank.csv
|
158
|
+
- spec/test_files/matcher/no_rows.csv
|
159
|
+
- spec/test_files/matcher/test_1.csv
|
160
|
+
- spec/test_files/test_slacker_project/data/test_1.csv
|
156
161
|
- spec/test_files/test_slacker_project/sql/example_1/helper_1.sql
|
157
|
-
- spec/test_files/test_slacker_project/sql/
|
158
|
-
- spec/test_files/test_slacker_project/sql/
|
162
|
+
- spec/test_files/test_slacker_project/sql/example_1/helper_2.sql
|
163
|
+
- spec/test_files/test_slacker_project/sql/example_1/helper_2.sql.erb
|
164
|
+
- spec/test_files/test_slacker_project/sql/helpers/helper_1.sql
|
159
165
|
- spec/test_files/test_slacker_project/sql/helpers/helper_2.sql.erb
|
160
|
-
- spec/test_files/test_slacker_project/sql/helpers/helper_3.sql.erb
|
161
166
|
- spec/test_files/test_slacker_project/sql/helpers/helper_3.sql
|
162
|
-
- spec/test_files/test_slacker_project/sql/helpers/
|
163
|
-
- spec/test_files/test_slacker_project/sql/
|
164
|
-
- spec/test_files/test_slacker_project/sql/
|
165
|
-
- spec/test_files/test_slacker_project/sql/nested.sql.erb
|
166
|
-
- spec/test_files/test_slacker_project/sql/nest/nested_2.sql.erb
|
167
|
+
- spec/test_files/test_slacker_project/sql/helpers/helper_3.sql.erb
|
168
|
+
- spec/test_files/test_slacker_project/sql/helpers/text_file_1.txt
|
169
|
+
- spec/test_files/test_slacker_project/sql/multi_nested.sql.erb
|
167
170
|
- spec/test_files/test_slacker_project/sql/nest/example_1/helper_1.sql.erb
|
168
171
|
- spec/test_files/test_slacker_project/sql/nest/nested_1.sql.erb
|
169
|
-
- spec/test_files/test_slacker_project/
|
170
|
-
- spec/test_files/
|
171
|
-
- spec/test_files/
|
172
|
-
- spec/test_files/
|
173
|
-
- spec/
|
174
|
-
- spec/
|
175
|
-
- spec/rspec_ext_spec.rb
|
176
|
-
- spec/application_spec.rb
|
177
|
-
- spec/query_result_matcher_spec.rb
|
172
|
+
- spec/test_files/test_slacker_project/sql/nest/nested_2.sql.erb
|
173
|
+
- spec/test_files/test_slacker_project/sql/nested.sql.erb
|
174
|
+
- spec/test_files/test_slacker_project/sql/nested_with_params.sql.erb
|
175
|
+
- spec/test_files/test_slacker_project/sql/no_params.sql.erb
|
176
|
+
- spec/test_files/test_slacker_project/sql/params.sql.erb
|
177
|
+
- spec/test_files/test_slacker_project/sql/test_1.sql
|