my_scripts 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -58,3 +58,7 @@
58
58
 
59
59
  * Ansi script added
60
60
 
61
+
62
+ == 0.1.14 / 2010-10-28
63
+
64
+ * Project updated for RSpec2
data/Rakefile CHANGED
@@ -11,13 +11,8 @@ require NAME
11
11
  CLASS_NAME = MyScripts
12
12
  VERSION = CLASS_NAME::VERSION
13
13
 
14
- begin
15
- require 'rake'
16
- rescue LoadError
17
- require 'rubygems'
18
- gem 'rake', '~> 0.8.3.1'
19
- require 'rake'
20
- end
14
+ gem 'rake', '~> 0.8.7'
15
+ require 'rake'
21
16
 
22
17
  # Load rakefile tasks
23
18
  Dir['tasks/*.rake'].sort.each { |file| load file }
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.13
1
+ 0.1.14
@@ -2,60 +2,58 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- module MyScriptsTest
6
- module A
7
- class B
8
- class C
9
- end
5
+ module A
6
+ class B
7
+ class C
10
8
  end
11
9
  end
10
+ end
12
11
 
13
- describe String do
14
- context '#snake_case' do
15
- it 'transforms CamelCase strings' do
16
- 'GetCharWidth32'.snake_case.should == 'get_char_width_32'
17
- end
18
-
19
- it 'leaves snake_case strings intact' do
20
- 'keybd_event'.snake_case.should == 'keybd_event'
21
- end
12
+ describe String do
13
+ context '#snake_case' do
14
+ it 'transforms CamelCase strings' do
15
+ 'GetCharWidth32'.snake_case.should == 'get_char_width_32'
22
16
  end
23
17
 
24
- context '#camel_case' do
25
- it 'transforms underscore strings to CamelCase' do
26
- 'get_char_width_32'.camel_case.should == 'GetCharWidth32'
27
- end
18
+ it 'leaves snake_case strings intact' do
19
+ 'keybd_event'.snake_case.should == 'keybd_event'
20
+ end
21
+ end
28
22
 
29
- it 'leaves CamelCase strings intact' do
30
- 'GetCharWidth32'.camel_case.should == 'GetCharWidth32'
31
- end
23
+ context '#camel_case' do
24
+ it 'transforms underscore strings to CamelCase' do
25
+ 'get_char_width_32'.camel_case.should == 'GetCharWidth32'
32
26
  end
33
27
 
34
- context '#to_class' do
35
- it 'converts string into appropriate Class constant' do
36
- "Fixnum".to_class.should == Fixnum
37
- "MyScriptsTest::A::B::C".to_class.should == MyScriptsTest::A::B::C
38
- end
28
+ it 'leaves CamelCase strings intact' do
29
+ 'GetCharWidth32'.camel_case.should == 'GetCharWidth32'
30
+ end
31
+ end
39
32
 
40
- it 'returns nil if string is not convertible into class' do
41
- "Math".to_class.should == nil
42
- "Math::PI".to_class.should == nil
43
- "Something".to_class.should == nil
44
- end
33
+ context '#to_class' do
34
+ it 'converts string into appropriate Class constant' do
35
+ "Fixnum".to_class.should == Fixnum
36
+ "A::B::C".to_class.should == A::B::C
37
+ end
45
38
 
46
- it 'deals with leading colons' do
47
- "::MyScriptsTest::A::B::C".to_class.should == MyScriptsTest::A::B::C
48
- end
39
+ it 'returns nil if string is not convertible into class' do
40
+ "Math".to_class.should == nil
41
+ "Math::PI".to_class.should == nil
42
+ "Something".to_class.should == nil
49
43
  end
50
44
 
51
- context '#translit!' do
52
- it 'converts string from Cyrillic to Latin translit' do
53
- "Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства".translit!.
54
- should == "SHirokaya elektrifikatsiya yuzhnykh gubernij dast moshchnyj tolchok pod\"emu sel'skogo khozyajstva"
55
- "ШИРОКАЯ ЭЛЕКТРИФИКАЦИЯ ЮЖНЫХ ГУБЕРНИЙ ДАСТ МОЩНЫЙ ТОЛЧОК ПОДЪЁМУ СЕЛЬСКОГО ХОЗЯЙСТВА".translit!.
56
- should == "SHIROKAYA ELEKTRIFIKATSIYA YUZHNYKH GUBERNIJ DAST MOSHCHNYJ TOLCHOK POD\"EMU SEL'SKOGO KHOZYAJSTVA"
57
- end
45
+ it 'deals with leading colons' do
46
+ "::A::B::C".to_class.should == A::B::C
58
47
  end
48
+ end
59
49
 
50
+ context '#translit!' do
51
+ it 'converts string from Cyrillic to Latin translit' do
52
+ "Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства".translit!.
53
+ should == "SHirokaya elektrifikatsiya yuzhnykh gubernij dast moshchnyj tolchok pod\"emu sel'skogo khozyajstva"
54
+ "ШИРОКАЯ ЭЛЕКТРИФИКАЦИЯ ЮЖНЫХ ГУБЕРНИЙ ДАСТ МОЩНЫЙ ТОЛЧОК ПОДЪЁМУ СЕЛЬСКОГО ХОЗЯЙСТВА".translit!.
55
+ should == "SHIROKAYA ELEKTRIFIKATSIYA YUZHNYKH GUBERNIJ DAST MOSHCHNYJ TOLCHOK POD\"EMU SEL'SKOGO KHOZYAJSTVA"
56
+ end
60
57
  end
61
- end
58
+
59
+ end
@@ -1,56 +1,53 @@
1
1
  require 'spec_helper'
2
- require 'my_scripts/scripts/shared'
3
2
 
4
- module MyScriptsTest
5
- VERSION_COMMANDS = %W[1 10 100 1.2.3 1.2.3.beta2 0.0.1.patch .patch .b2a]
3
+ VERSION_COMMANDS = %W[1 10 100 1.2.3 1.2.3.beta2 0.0.1.patch .patch .b2a]
6
4
 
7
- describe MyScripts::Gitto do
8
- before(:each) do
9
- create_cli(:system=> 'ok')
10
- @name = 'gitto'
11
- end
5
+ describe MyScripts::Gitto do
6
+ before(:each) do
7
+ create_cli(:system=> 'ok')
8
+ @name = 'gitto'
9
+ end
12
10
 
13
- it_should_behave_like "script with args"
11
+ it_should_behave_like "script with args"
14
12
 
15
- context 'No version command' do
16
- it 'Commits with message, pushes to remote' do
17
- message = 'This is bomb!'
18
- stdout_should_receive "Adding all the changes",
19
- "Committing everything with message: #{message}",
20
- "Pushing to (default) remote for branch: * master"
21
- system_should_receive "git add --all",
22
- %Q{git commit -a -m "#{message}" --author arvicco},
23
- "git push"
24
- cli "#{@name} #{message}"
25
- end
13
+ context 'No version command' do
14
+ it 'Commits with message, pushes to remote' do
15
+ message = 'This is bomb!'
16
+ stdout_should_receive "Adding all the changes",
17
+ "Committing everything with message: #{message}",
18
+ "Pushing to (default) remote for branch: * master"
19
+ system_should_receive "git add --all",
20
+ %Q{git commit -a -m "#{message}" --author arvicco},
21
+ "git push"
22
+ cli "#{@name} #{message}"
23
+ end
26
24
 
27
- context 'With version command' do
28
- it 'Commits with message if message given, pushes to remote' do
29
- VERSION_COMMANDS.each do |command|
30
- message = 'This is bomb!'
25
+ context 'With version command' do
26
+ it 'Commits with message if message given, pushes to remote' do
27
+ VERSION_COMMANDS.each do |command|
28
+ message = 'This is bomb!'
31
29
 
32
- stdout_should_receive "Adding all the changes",
33
- "Committing everything with message: #{message}",
34
- "Pushing to (default) remote for branch: * master"
35
- system_should_receive %Q{rake "version[#{command},#{message}]"},
36
- "git add --all",
37
- %Q{git commit -a -m "#{message}" --author arvicco},
38
- "git push"
39
- cli "#{@name} #{command} #{message}"
40
- end
30
+ stdout_should_receive "Adding all the changes",
31
+ "Committing everything with message: #{message}",
32
+ "Pushing to (default) remote for branch: * master"
33
+ system_should_receive %Q{rake "version[#{command},#{message}]"},
34
+ "git add --all",
35
+ %Q{git commit -a -m "#{message}" --author arvicco},
36
+ "git push"
37
+ cli "#{@name} #{command} #{message}"
41
38
  end
39
+ end
42
40
 
43
- it 'Commits and pushes with default timestamped message if no message' do
44
- VERSION_COMMANDS.each do |command|
45
- stdout_should_receive "Adding all the changes",
46
- "Committing everything with message: Commit #{Time.now.to_s[0..-6]}",
47
- "Pushing to (default) remote for branch: * master"
48
- system_should_receive "rake version[#{command}]",
49
- "git add --all",
50
- %Q{git commit -a -m "Commit #{Time.now.to_s[0..-6]}" --author arvicco},
51
- "git push"
52
- cli "#{@name} #{command}"
53
- end
41
+ it 'Commits and pushes with default timestamped message if no message' do
42
+ VERSION_COMMANDS.each do |command|
43
+ stdout_should_receive "Adding all the changes",
44
+ "Committing everything with message: Commit #{Time.now.to_s[0..-6]}",
45
+ "Pushing to (default) remote for branch: * master"
46
+ system_should_receive "rake version[#{command}]",
47
+ "git add --all",
48
+ %Q{git commit -a -m "Commit #{Time.now.to_s[0..-6]}" --author arvicco},
49
+ "git push"
50
+ cli "#{@name} #{command}"
54
51
  end
55
52
  end
56
53
  end
@@ -1,2 +1,2 @@
1
- # Delegation (for autospec)
1
+ # Delegation (for autotest)
2
2
  require 'my_scripts/scripts/msdn_spec'
@@ -1,32 +1,30 @@
1
1
  require 'spec_helper'
2
- require 'my_scripts/scripts/shared'
3
2
 
4
- module MyScriptsTest
5
-
6
- describe MyScripts::Msdn do
7
- before(:each) do
8
- @name = 'msdn'
9
- end
3
+ describe MyScripts::Msdn do
4
+ before(:each) do
5
+ @name = 'msdn'
6
+ end
10
7
 
11
- context 'With explicit infile, no outfile' do
8
+ context 'With explicit infile, no outfile' do
12
9
 
13
- it 'reads from infile, writes to stdout' do
14
- test_files(@name).each do |infile, outfile|
15
- create_cli
16
- stdout_should_receive outfile.readlines.map(&:chomp).join("\n") + "\n"
17
- cli "#{@name} #{infile}", infile
18
- end
10
+ it 'reads from infile, writes to stdout' do
11
+ test_files(@name).each do |infile, outfile|
12
+ create_cli
13
+ stdout_should_receive outfile.readlines.map(&:chomp).join("\n") + "\n"
14
+ cli "#{@name} #{infile}", infile
19
15
  end
20
16
  end
17
+ end
21
18
 
22
- it 'reads from temp file' do
23
- text = test_files(@name)[1].first.read
24
- temp_file = File.expand_path('/tmp/msdn_temp_file')
25
- File.open(temp_file, 'w') do |f| f.write(text) end
26
-
27
- lambda{@changed_text = `msdn /tmp/msdn_temp_file`}.should_not raise_error
28
- # puts "\n\nResult: #{@changed_text}"
19
+ it 'reads from temp file' do
20
+ text = test_files(@name)[1].first.read
21
+ temp_file = File.expand_path('/tmp/msdn_temp_file')
22
+ File.open(temp_file, 'w') do |f|
23
+ f.write(text)
29
24
  end
30
25
 
26
+ lambda { @changed_text = `msdn /tmp/msdn_temp_file` }.should_not raise_error
27
+ # puts "\n\nResult: #{@changed_text}"
31
28
  end
29
+
32
30
  end
File without changes
data/spec/spec_helper.rb CHANGED
@@ -1,75 +1,71 @@
1
1
  require 'my_scripts'
2
- require 'spec'
3
- require 'spec/autorun'
2
+ require 'rspec'
3
+ require 'shared'
4
4
 
5
- Spec::Runner.configure do |config|
6
- end
7
-
8
- module MyScriptsTest
5
+ #Spec::Runner.configure do |config|
6
+ #end
9
7
 
10
- def create_cli(opts={})
11
- @stdout = opts[:stdout] || mock('stdout').as_null_object
12
- @stdin = opts[:stdin] || mock('stdin')
13
- if opts[:input]
14
- @stdin.stub(:gets).and_return(*opts[:input])
15
- else
16
- @stdin.stub(:gets).and_return('')
17
- end
18
- @kernel = Kernel
19
- if opts[:system]
20
- @kernel = mock('Kernel')
21
- @kernel.stub(:system).and_return(*opts[:system])
22
- end
23
- @cli = MyScripts::CLI.new(@stdin, @stdout, @kernel)
8
+ def create_cli(opts={})
9
+ @stdout = opts[:stdout] || mock('stdout').as_null_object
10
+ @stdin = opts[:stdin] || mock('stdin')
11
+ if opts[:input]
12
+ @stdin.stub(:gets).and_return(*opts[:input])
13
+ else
14
+ @stdin.stub(:gets).and_return('')
24
15
  end
25
-
26
- def cli(command_line, argf=ARGF)
27
- raise "Command line should be non-empty String" unless command_line.respond_to?(:split) && command_line != ''
28
- argv = command_line.split(' ')
29
- @cli.run argv.shift.to_sym, argv, argf
16
+ @kernel = Kernel
17
+ if opts[:system]
18
+ @kernel = mock('Kernel')
19
+ @kernel.stub(:system).and_return(*opts[:system])
30
20
  end
21
+ @cli = MyScripts::CLI.new(@stdin, @stdout, @kernel)
22
+ end
31
23
 
32
- # Sets expectation for Kernel to receive system call with specific messages/patterns
33
- def system_should_receive(*messages)
34
- entity_should_receive(@kernel, :system, *messages)
35
- end
24
+ def cli(command_line, argf=ARGF)
25
+ raise "Command line should be non-empty String" unless command_line.respond_to?(:split) && command_line != ''
26
+ argv = command_line.split(' ')
27
+ @cli.run argv.shift.to_sym, argv, argf
28
+ end
36
29
 
37
- # Sets expectation for stdout to receive puts with specific messages/patterns
38
- def stdout_should_receive(*messages)
39
- entity_should_receive(@stdout, :puts, *messages)
40
- end
30
+ # Sets expectation for Kernel to receive system call with specific messages/patterns
31
+ def system_should_receive(*messages)
32
+ entity_should_receive(@kernel, :system, *messages)
33
+ end
34
+
35
+ # Sets expectation for stdout to receive puts with specific messages/patterns
36
+ def stdout_should_receive(*messages)
37
+ entity_should_receive(@stdout, :puts, *messages)
38
+ end
41
39
 
42
- # Sets expectation for entity to receive either:
43
- # :message(s) - strictly ordered sequence of exact messages
44
- # :pattern(s) - specific patterns (unordered)
45
- #
46
- def entity_should_receive(entity, method, *messages)
47
- # If symbol is coming after method, it must be message type
48
- type = messages.first.is_a?(Symbol) ? messages.shift : :message
49
- messages.each do |message|
50
- if type.to_s =~ /message/
51
- entity.should_receive(method).with(message).once.ordered
52
- elsif type.to_s =~ /(pattern|regex)/
53
- re = Regexp === message ? message : Regexp.new(Regexp.escape(message))
54
- entity.should_receive(method).with(re).at_least(:once)
55
- end
40
+ # Sets expectation for entity to receive either:
41
+ # :message(s) - strictly ordered sequence of exact messages
42
+ # :pattern(s) - specific patterns (unordered)
43
+ #
44
+ def entity_should_receive(entity, method, *messages)
45
+ # If symbol is coming after method, it must be message type
46
+ type = messages.first.is_a?(Symbol) ? messages.shift : :message
47
+ messages.each do |message|
48
+ if type.to_s =~ /message/
49
+ entity.should_receive(method).with(message).once.ordered
50
+ elsif type.to_s =~ /(pattern|regex)/
51
+ re = Regexp === message ? message : Regexp.new(Regexp.escape(message))
52
+ entity.should_receive(method).with(re).at_least(:once)
56
53
  end
57
54
  end
55
+ end
58
56
 
59
- # Lists files of specific type
60
- def test_files(dir)
57
+ # Lists files of specific type
58
+ def test_files(dir)
61
59
 
62
- files_dir = Pathname(__FILE__).dirname + 'files' + dir
63
- infiles_glob = (files_dir + '*_in.txt').to_s
64
- outfiles_glob = (files_dir + '*_out.txt').to_s
65
- infiles = Pathname.glob(infiles_glob)
66
- outfiles = Pathname.glob(outfiles_glob)
60
+ files_dir = Pathname(__FILE__).dirname + 'files' + dir
61
+ infiles_glob = (files_dir + '*_in.txt').to_s
62
+ outfiles_glob = (files_dir + '*_out.txt').to_s
63
+ infiles = Pathname.glob(infiles_glob)
64
+ outfiles = Pathname.glob(outfiles_glob)
67
65
 
68
- if infiles.size == outfiles.size
69
- infiles.zip(outfiles)
70
- else
71
- nil
72
- end
66
+ if infiles.size == outfiles.size
67
+ infiles.zip(outfiles)
68
+ else
69
+ nil
73
70
  end
74
-
75
- end
71
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_scripts
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 13
10
- version: 0.1.13
9
+ - 14
10
+ version: 0.1.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - arvicco
@@ -48,6 +48,22 @@ dependencies:
48
48
  version: "0"
49
49
  type: :development
50
50
  version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: bundler
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 13
60
+ segments:
61
+ - 1
62
+ - 2
63
+ - 9
64
+ version: 1.2.9
65
+ type: :runtime
66
+ version_requirements: *id003
51
67
  description: Simple scripting framework
52
68
  email: arvitallian@gmail.com
53
69
  executables:
@@ -99,9 +115,8 @@ files:
99
115
  - spec/my_scripts/scripts/gitto_spec.rb
100
116
  - spec/my_scripts/scripts/msdn/msdn_helper_spec.rb
101
117
  - spec/my_scripts/scripts/msdn_spec.rb
102
- - spec/my_scripts/scripts/shared.rb
103
118
  - spec/my_scripts_spec.rb
104
- - spec/spec.opts
119
+ - spec/shared.rb
105
120
  - spec/spec_helper.rb
106
121
  - features/my_scripts.feature
107
122
  - features/step_definitions/my_scripts_steps.rb
@@ -152,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
167
  version: "0"
153
168
  requirements: []
154
169
 
155
- rubyforge_project: ""
170
+ rubyforge_project:
156
171
  rubygems_version: 1.3.7
157
172
  signing_key:
158
173
  specification_version: 3
@@ -170,7 +185,6 @@ test_files:
170
185
  - spec/my_scripts/scripts/gitto_spec.rb
171
186
  - spec/my_scripts/scripts/msdn/msdn_helper_spec.rb
172
187
  - spec/my_scripts/scripts/msdn_spec.rb
173
- - spec/my_scripts/scripts/shared.rb
174
188
  - spec/my_scripts_spec.rb
175
- - spec/spec.opts
189
+ - spec/shared.rb
176
190
  - spec/spec_helper.rb
data/spec/spec.opts DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format nested