guard-cunit 0.0.2 → 0.0.3

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.
@@ -1,11 +1,13 @@
1
+ before_install:
2
+ - gem update bundle
3
+ - gem --version
4
+ - bundle --version
1
5
  language: ruby
2
6
  rvm:
3
- - "1.8.7"
4
- - "1.9.2"
5
- - "1.9.3"
6
- - jruby-18mode # JRuby in 1.8 mode
7
+ - "2.0.0-p247"
7
8
  - jruby-19mode # JRuby in 1.9 mode
8
- - rbx-18mode
9
+ - jruby-20mode # JRuby in 2.0 mode
9
10
  - rbx-19mode
11
+ - rbx-20mode
10
12
  # uncomment this line if your project needs to run something other than `rake`:
11
- script: bundle exec rspec spec
13
+ script: bundle exec rspec
@@ -1,4 +1,28 @@
1
- # Chagelog
1
+ # Chagelog
2
+
3
+ ## version 0.0.2
4
+ ### more bugfixes
5
+ commit fc72fdc5b23ea146d37554151eb7681bb0f615ee
6
+ Date: Sun Dec 2 20:25:26 2012 +0200
7
+
8
+ add fixes for running rspec in cleaner environment and increased version
9
+ where platform indpendant gem should be used
10
+
11
+ commit a24dc9f1458a7e200b825c62c9ecd96836fa378e
12
+ Date: Sun Dec 2 17:08:17 2012 +0200
13
+
14
+ reworked popen usage for legacy runy versions and win/mac
15
+ incompatabilities
16
+
17
+ commit f4c578a2974b19e594e6180ca2ad5a27e4edc5ba
18
+ Date: Thu Nov 29 17:07:27 2012 +0200
19
+
20
+ fix problem with pipes on windows
21
+
22
+ commit 94d611475656105b72680dca8aebac6ca7ab3344
23
+ Date: Wed Nov 28 10:46:16 2012 +0200
24
+
25
+ rework adding library to search path for win and mac
2
26
 
3
27
  ### Bug fix
4
28
  commit fd83634f375f76fb7ef5af72516f6afe6f07946c
data/Gemfile CHANGED
@@ -6,4 +6,7 @@ if RUBY_VERSION.match("1.8")
6
6
  gem 'rake', :require=>true
7
7
  end
8
8
  gem 'guard', :require=>true
9
+ gem 'guard-compat', :require=>true
9
10
  gem 'rspec-core', :require=> true
11
+ gem 'pry', :require=> true
12
+ gem 'pry_debug', :require=> true
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
+
1
2
  # Guard CUnit [![Build Status](https://secure.travis-ci.org/teacup-on-rockingchair/guard-cunit.png?branch=master)](http://travis-ci.org/teacup-on-rockingchair/guard-cunit)
2
3
 
3
4
  CUnit Guard allows you to run/watch Unit test for C modules, or anything other that works with Makefile
4
5
 
5
- Soon will add parser for CUnit tests, and probably other UT libs
6
+ Has basic parser for CUnit tests. Current TODO is to add also for CppUtest and Unity
6
7
 
7
8
  ## Install
8
9
 
@@ -10,10 +11,10 @@ Need to have guard and also some of the notifiers that guard uses
10
11
 
11
12
  otherwise, get the gemfile and install it:
12
13
  ```
13
- $ gem install ./guard-cunit-*.gem
14
+ $ gem install guard-cunit
14
15
  ```
15
16
 
16
- will put that in rubygems soon
17
+ Already can be found on http://rubygems.org/
17
18
 
18
19
  # Guardfile
19
20
 
@@ -36,9 +37,9 @@ guard 'cunit' do
36
37
  watch(%r{((.+)\.c$)|((.+)\.h$)|((M|m)akefile$)} )
37
38
  end
38
39
 
39
- set_builder "make 2>&1"
40
+ set_builder "make"
40
41
  set_cleaner "make clean"
41
- cunit_runner "#{File.basename(Dir.getwd)}_unit"
42
+ cunit_runner "./#{File.basename(Dir.getwd)}_unit"
42
43
  libdir "#{Dir.getwd}"
43
44
 
44
45
  ```
@@ -60,11 +61,12 @@ Run rspec in top directory of the project or guard-rspec
60
61
  Todo
61
62
  -----------
62
63
  - fix all bugs :)
63
- - add parser for CUNIT tests
64
+ - add parser for more Unit tests frameworks
64
65
  - add hook for coverage
66
+ - something about automatic mock generation ???
65
67
  - ... whatever wind blows ...
66
68
 
67
69
  Author
68
70
  ----------
69
- [A tea cup on a rocking chair](https://github.com/strandjata)
71
+ [A tea cup on a rocking chair](https://github.com/teacup-on-rockingchair)
70
72
 
data/Rakefile CHANGED
@@ -8,13 +8,14 @@ task :default => [ :spec, :doc, :gem]
8
8
 
9
9
  desc "Run RSpec"
10
10
  RSpec::Core::RakeTask.new do |t|
11
- t.rcov = ENV['RCOV']
12
- t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/}
11
+ # t.rcov = ENV['RCOV']
12
+ # t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/}
13
13
  t.verbose = true
14
14
  end
15
15
 
16
16
 
17
17
  task :doc do
18
+ system 'rm -fr doc'
18
19
  system 'rdoc -a -U'
19
20
  end
20
21
 
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
 
18
18
  # specify any dependencies here; for example:
19
19
  s.add_dependency 'guard', '>= 1.1'
20
+ s.add_dependency 'guard-compat', '~> 1.1'
20
21
  s.add_development_dependency 'bundler'
21
22
  s.add_development_dependency 'rspec'
22
23
 
@@ -1,69 +1,70 @@
1
1
  require 'guard'
2
- require 'guard/guard'
3
-
2
+ require 'guard/compat/plugin'
3
+ require_relative 'cunit/runner'
4
4
 
5
5
  module Guard
6
- # main child class of Guard to nherit guard's behaviour
7
- class Cunit < Guard
8
- autoload :Runner, 'guard/cunit/runner'
9
- # new method that also creates the runner class
10
- def initialize(watchers = [], options = {})
6
+ # main child class of Guard to nherit guard's behaviour
7
+ class Cunit < Plugin
8
+ # new method that also creates the runner class
9
+ def initialize(options = {})
11
10
  super
12
11
  @options = {
13
- :all_on_start => true,
12
+ all_on_start: true
14
13
  }.update(options)
15
- @runner = Runner.new()
14
+ @runner = Runner.new
16
15
  end
16
+
17
17
  # Called when just `enter` is pressed
18
- # This method should be principally used for long action like running all specs/tests/...
18
+ # This method should be principally used for long action
19
+ # like running all specs/tests/...
19
20
  # @raise [:task_has_failed] when run_all has failed
20
21
  def run_all
21
22
  passed = @runner.run
22
23
  throw :task_has_failed unless passed
23
24
  end
25
+
24
26
  def run_on_change(paths)
25
27
  UI.info("Process changes in #{paths}")
26
- passed = run_all
28
+ run_all
27
29
  end
28
30
  end
29
31
 
30
- #
31
- # add more behaviour to Guard's DSL to be able to configure executors
32
- # of all the CUnit's Guard tasks
33
- #
32
+ #
33
+ # add more behaviour to Guard's DSL to be able to configure executors
34
+ # of all the CUnit's Guard tasks
35
+ #
34
36
  class Dsl
35
- #
36
- # put default values to task executors
37
- #
37
+ #
38
+ # put default values to task executors
39
+ #
38
40
  def initialize
39
41
  super
40
- set_cleaner("make clean")
42
+ set_cleaner('make clean')
41
43
  cunit_runner("./#{File.basename(Dir.getwd)}_unit")
42
- set_builder("make 2>&1")
44
+ set_builder('make 2>&1')
43
45
  libdir("#{Dir.getwd}")
44
46
  @runner = Cunit::Runner.new
45
47
  end
46
48
 
47
49
  # dsl call to set cunit test executable
48
- def cunit_runner (name)
49
- Cunit::Runner.set_runner(name)
50
+ def cunit_runner(name)
51
+ Cunit::Runner.cfg_runner(name)
50
52
  end
51
-
53
+
52
54
  # dsl call to set cunit build command/script, by default make
53
- def set_builder (name)
54
- Cunit::Runner.set_builder(name)
55
+ def set_builder(name)
56
+ Cunit::Runner.cfg_builder(name)
55
57
  end
56
-
57
- #dsl call to set cunit clean command/script, by default 'make clean'
58
- def set_cleaner (name)
59
- Cunit::Runner.set_cleaner(name)
58
+
59
+ # dsl call to set cunit clean command/script, by default 'make clean'
60
+ def set_cleaner(name)
61
+ Cunit::Runner.cfg_cleaner(name)
60
62
  end
61
-
62
- # dsl call to set dir, where library under test is generated, by default current dir
63
+
64
+ # dsl call to set dir, where library under test is generated,
65
+ # by default current dir
63
66
  def libdir(name)
64
- Cunit::Runner.set_libdir(File.expand_path(name))
67
+ Cunit::Runner.cfg_libdir(File.expand_path(name))
65
68
  end
66
-
67
69
  end
68
-
69
70
  end
@@ -1,79 +1,78 @@
1
+ # couple of methods I need for String objects
1
2
  class TestOutput < String
2
3
  # limit the output to given nr rows
3
4
  def limit_to_rows(number_of_rows)
4
- output = TestOutput.new("")
5
- raws_count = 1;
6
- self.lines.each do |current_line|
5
+ output = TestOutput.new('')
6
+ raws_count = 1
7
+ lines.each do |current_line|
7
8
  output += current_line
8
- break if(raws_count == number_of_rows)
9
- raws_count+=1
9
+ break if raws_count == number_of_rows
10
+ raws_count += 1
10
11
  end
11
- output=output+"..." if ( number_of_rows < self.lines.count )
12
+ output += '...' if number_of_rows < lines.count
12
13
  output
13
14
  end
14
-
15
+
15
16
  # bang version
16
17
  def limit_to_rows!(number_of_rows)
17
- self.replace(limit_to_rows(number_of_rows))
18
+ replace(limit_to_rows(number_of_rows))
18
19
  end
19
-
20
20
  end
21
21
 
22
-
23
22
  module Guard
24
- class Cunit
25
- class CunitParser
26
- @output
27
- @summary_output
28
- @failures
23
+ class Cunit < Plugin
24
+ # Parse CUNIT test harness output
25
+ class CunitParser
26
+ # constructor
27
+ def initialize(task_output = nil)
28
+ parse_output(task_output) unless task_output.nil?
29
+ end
29
30
 
30
- #constructor
31
- def initialize (task_output = nil)
32
- parse_output( task_output ) unless task_output == nil
33
- end
34
-
35
- #get cunit output
36
- def parse_output( task_output )
37
- task_output = "" unless task_output != nil
38
- @output = TestOutput.new(task_output.dup)
39
- get_summary
40
- get_failures
41
- end
42
-
43
- # find summary of the cunit test reprot
44
- def get_summary
45
- begin
46
- @summary_output = TestOutput.new(@output[/Run Summary:[\w\W]*/])
47
- rescue
48
- @summary_output = TestOutput.new("")
49
- end
50
- end
31
+ # get cunit output
32
+ def parse_output(task_output)
33
+ task_output = '' if task_output.nil?
34
+ @output = TestOutput.new(task_output.dup)
35
+ read_summary
36
+ read_failures
37
+ end
51
38
 
52
- #find failures from Cunit test report
53
- def get_failures
54
- begin
55
- @failures = TestOutput.new(@output[/[\r\n]*[ \t\f]*1. [\w\W]*:[\d]* [\w\W]*/].sub(@summary_output,"").strip)
56
- rescue
57
- @failures = TestOutput.new("Failed")
58
- end
59
- @failures.limit_to_rows!(3)
60
- end
39
+ # find summary of the cunit test reprot
40
+ def read_summary
41
+ summary_txt = ''
42
+ begin
43
+ summary_txt = @output[/Run Summary:[\w\W]*/] || ''
44
+ rescue
45
+ summary_txt = ''
46
+ end
47
+ @summary_output = TestOutput.new(summary_txt)
48
+ end
61
49
 
62
- #display summary of the suites/tests/asserts
63
- def cunit_output
64
- @summary_output
65
- end
50
+ # find failures from Cunit test report
51
+ def read_failures
52
+ begin
53
+ failures_rex = /[\r\n]*[ \t\f]*1. [\w\W]*:[\d]* [\w\W]*/
54
+ outp = @output[failures_rex].sub(@summary_output, '').strip
55
+ @failures = TestOutput.new(outp)
56
+ rescue
57
+ @failures = TestOutput.new('Failed')
58
+ end
59
+ @failures.limit_to_rows!(3)
60
+ end
66
61
 
67
- #copy of the cunit output
68
- def full_output
69
- @output
70
- end
62
+ # display summary of the suites/tests/asserts
63
+ def cunit_output
64
+ @summary_output
65
+ end
71
66
 
72
- #display failures output
73
- def failures_output
74
- @failures
75
- end
67
+ # copy of the cunit output
68
+ def full_output
69
+ @output
70
+ end
76
71
 
77
- end
78
- end
72
+ # display failures output
73
+ def failures_output
74
+ @failures
75
+ end
76
+ end
77
+ end
79
78
  end
@@ -1,128 +1,142 @@
1
1
  require 'guard/cunit/cunit_parser'
2
2
 
3
-
4
3
  module Guard
5
- class Cunit
6
- #
7
- # the class implements running and handling of results of the tasks that made up the cunit guard
8
- #
9
- class Runner
10
- @@cunit_runner=''
11
- @@project_builder=''
12
- @@project_cleaner=''
13
- @@project_libdir=''
14
-
15
-
16
- def initialize
17
- @parser = CunitParser.new()
18
- @current_output = String.new("")
19
- end
20
- # set the executable file name to run CUNIT tests
21
- def self.set_runner(name)
22
- @@cunit_runner=name
23
- end
24
-
25
- # set command to run to prepare build
26
- def self.set_builder(name)
27
- @@project_builder=name
28
- end
29
-
4
+ class Cunit < Plugin
5
+ # the class implements running and handling results
6
+ # of the tasks that made up the cunit guard
7
+ class Runner
8
+ @@cunit_runner = ''
9
+ @@project_builder = ''
10
+ @@project_cleaner = ''
11
+ @@project_libdir = ''
12
+
13
+ def initialize
14
+ @parser = CunitParser.new
15
+ @current_output = String.new('')
16
+ end
17
+
18
+ # set the executable file name to run CUNIT tests
19
+ def self.cfg_runner(name)
20
+ @@cunit_runner = name
21
+ end
22
+
23
+ # set command to run to prepare build
24
+ def self.cfg_builder(name)
25
+ @@project_builder = name
26
+ end
27
+
30
28
  # set cleaner script/exe/command
31
- def self.set_cleaner(name)
32
- @@project_cleaner=name
33
- end
34
-
35
-
29
+ def self.cfg_cleaner(name)
30
+ @@project_cleaner = name
31
+ end
32
+
36
33
  # set directory where library under test is generated
37
- def self.set_libdir(name)
38
- @@project_libdir=name
39
- end
40
-
41
- #
42
- # make wrapper for piping so we can use different approaches on win and *nix
43
- #
44
- def piper(exe)
45
- if( RUBY_PLATFORM.match(/mingw/)||RUBY_PLATFORM.match(/mswin/)||RUBY_VERSION.match("1.8"))
46
- IO.popen(exe) {|io|
47
- yield io
48
- }
49
- else
50
- IO.popen(exe.split << {:err=>[:child, :out]}) {|io|
51
- yield io
52
- }
53
- end
54
-
55
- end
56
- #
57
- # run one phase of the guard via a system command/executable
58
- #
59
- def run_task(task_executable)
60
- success = true
61
- piper(task_executable) {|myio|
62
- @current_output = myio.read
63
- }
64
- success = false unless $?.exitstatus == 0
65
- UI.info @current_output
66
- success
67
- end
68
-
69
- # run clean before each run all start with clean
70
- def run_clean
71
- raise "Clean failed" unless run_task(@@project_cleaner) == true
72
- end
73
- def export_libdir(libdir)
74
- case RUBY_PLATFORM
75
- when /mingw/,/mswin/
76
- ENV["PATH"]="#{ENV["PATH"]};#{libdir}"
77
- when /darwin/
78
- ENV["DYLD_LIBRARY_PATH"]="#{ENV["DYLD_LIBRARY_PATH"]}:#{libdir}"
79
- else
80
- ENV["LD_LIBRARY_PATH"]="#{ENV["LD_LIBRARY_PATH"]}:#{libdir}"
81
- end
82
- end
83
- # run unit tests via cunit executable
84
- def run_tests
85
- # setup environment so it should include lib dir for ld path
86
- export_libdir(@@project_libdir)
87
-
88
- if( !File.exists? (@@cunit_runner) )
89
- Notifier.notify("Pending", :title => "Test Not Defined", :image => :pending, :priority => 2)
90
- success = false
91
- else
92
- success = run_task(@@cunit_runner)
93
- @parser.parse_output(@current_output)
94
- if success == true
95
- Notifier.notify("Success", :title => "Test Passed", :image => :passed, :priority => 2)
96
- else
97
- Notifier.notify(@parser.failures_output, :title => "Test Failed", :image => :failed, :priority => 2 )
98
- end
99
- end
100
- raise "Test failed" unless success == true
101
- end
102
-
103
-
104
- # run make command to build the project
105
- def run_make
106
- success = run_task(@@project_builder)
107
- Notifier.notify("Failed", :title => "Build Failed", :image => :failed, :priority => 2) unless success == true
108
- raise "Build failed" unless success == true
109
- end
110
- # run them all
111
- def run
112
- UI.info "Test runner: #{@@cunit_runner}"
113
- UI.info "Builder: #{@@project_builder}"
114
- UI.info "Cleaner: #{@@project_cleaner}"
115
- UI.info "Libdir: #{@@project_libdir}"
116
- begin
117
- run_clean
118
- run_make
119
- run_tests
120
- rescue
121
- return false
122
- end
123
- true
124
- end
125
-
126
- end
127
- end
34
+ def self.cfg_libdir(name)
35
+ @@project_libdir = name
36
+ end
37
+
38
+ # make wrapper for piping so we can use different
39
+ # approaches on win and *nix
40
+ def piper(exe)
41
+ if RUBY_PLATFORM.match(/mingw/) || \
42
+ RUBY_PLATFORM.match(/mswin/) || RUBY_VERSION.match('1.8')
43
+ IO.popen(exe) do |io|
44
+ yield io
45
+ end
46
+ else
47
+ IO.popen(exe.split << { err: [:child, :out] }) do |io|
48
+ yield io
49
+ end
50
+ end
51
+ end
52
+
53
+ # run one phase of the guard via a system command/executable
54
+ def run_task(task_executable)
55
+ success = true
56
+ piper(task_executable) do |myio|
57
+ @current_output = myio.read
58
+ end
59
+ success = false unless $CHILD_STATUS.exitstatus == 0
60
+ UI.info @current_output
61
+ success
62
+ end
63
+
64
+ # run clean before each run all start with clean
65
+ def run_clean
66
+ fail 'Clean failed' unless run_task(@@project_cleaner) == true
67
+ end
68
+
69
+ def export_libdir(libdir)
70
+ case RUBY_PLATFORM
71
+ when /mingw/, /mswin/
72
+ ENV['PATH'] = "#{ENV['PATH']};#{libdir}"
73
+ when /darwin/
74
+ ENV['DYLD_LIBRARY_PATH'] = "#{ENV['DYLD_LIBRARY_PATH']}:#{libdir}"
75
+ else
76
+ ENV['LD_LIBRARY_PATH'] = "#{ENV['LD_LIBRARY_PATH']}:#{libdir}"
77
+ end
78
+ end
79
+
80
+ def parse_test_output(result)
81
+ @parser.parse_output(@current_output)
82
+ if result == true
83
+ Guard::Compat::UI.notify('Success', title: 'Test Passed',
84
+ image: :success, priority: 2)
85
+ else
86
+ Guard::Compat::UI.notify(@parser.failures_output, title: 'Test Failed',
87
+ image: :failed, priority: 2)
88
+ end
89
+ end
90
+
91
+ def run_cunit
92
+ if !File.exist?(@@cunit_runner)
93
+ Guard::Compat::UI.notify('Pending', title: 'Test Not Defined',
94
+ image: :pending, priority: 2)
95
+ return false
96
+ else
97
+ success = run_task(@@cunit_runner)
98
+ parse_test_output(success)
99
+ return success
100
+ end
101
+ end
102
+
103
+ # run unit tests via cunit executable
104
+ def run_tests
105
+ # setup environment so it should include lib dir for ld path
106
+ export_libdir(@@project_libdir)
107
+ success = run_cunit
108
+ fail 'Test failed' unless success == true
109
+ end
110
+
111
+ # run make command to build the project
112
+ def run_make
113
+ success = run_task(@@project_builder)
114
+ unless success == true
115
+ Guard::Compat::UI.notify('Failed', title: 'Build Failed',
116
+ image: :failed, priority: 2)
117
+ end
118
+ fail 'Build failed' unless success == true
119
+ end
120
+
121
+ def print_test_info
122
+ UI.info "Test runner: #{@@cunit_runner}"
123
+ UI.info "Builder: #{@@project_builder}"
124
+ UI.info "Cleaner: #{@@project_cleaner}"
125
+ UI.info "Libdir: #{@@project_libdir}"
126
+ end
127
+
128
+ # run them all
129
+ def run
130
+ print_test_info
131
+ begin
132
+ run_clean
133
+ run_make
134
+ run_tests
135
+ rescue
136
+ return false
137
+ end
138
+ true
139
+ end
140
+ end
141
+ end
128
142
  end
@@ -5,7 +5,7 @@ guard 'cunit' do
5
5
  watch(%r{((.+)\.c$)|((.+)\.h$)|((M|m)akefile$)} )
6
6
  end
7
7
 
8
- set_builder "make 2>&1"
8
+ set_builder "make"
9
9
  set_cleaner "make clean"
10
10
  cunit_runner "#{File.basename(Dir.getwd)}_unit"
11
11
  libdir "#{Dir.getwd}"
@@ -1,7 +1,6 @@
1
- #version
2
1
  module Guard
2
+ # version of the gem
3
3
  module CunitGuard
4
- # version of the gem
5
- VERSION="0.0.2"
4
+ VERSION = '0.0.3'
6
5
  end
7
6
  end
@@ -60,24 +60,24 @@ Elapsed time = 0.000 seconds")
60
60
 
61
61
  it "should generate a UI summary and full output from given text input" do
62
62
  parser = Guard::Cunit::CunitParser.new(@fake_output)
63
- parser.full_output.should == @fake_output
64
- parser.cunit_output.should == (@fake_summary)
65
- parser.failures_output.should == (@fake_fail_summary)
63
+ expect(parser.full_output).to eq @fake_output
64
+ expect(parser.cunit_output).to eq (@fake_summary)
65
+ expect(parser.failures_output).to eq (@fake_fail_summary)
66
66
  end
67
67
 
68
68
  it "failure summary should be maximum a 3 row output" do
69
69
  parser = Guard::Cunit::CunitParser.new(@long_fake_output)
70
- parser.failures_output.should == (@shortened_fail_summary)
70
+ expect(parser.failures_output).to eq (@shortened_fail_summary)
71
71
  end
72
72
 
73
73
  it "should be able to init with no output and later trigger process" do
74
74
  parser = Guard::Cunit::CunitParser.new()
75
75
  parser.parse_output(@long_fake_output)
76
- parser.failures_output.should == (@shortened_fail_summary)
76
+ expect(parser.failures_output).to eq (@shortened_fail_summary)
77
77
  end
78
78
  it "should be able to handle test exe with no output and put just failed as failure message" do
79
79
  parser = Guard::Cunit::CunitParser.new()
80
80
  parser.parse_output(nil)
81
- parser.failures_output.should == ("Failed")
81
+ expect(parser.failures_output).to eq ("Failed")
82
82
  end
83
83
  end
@@ -25,7 +25,9 @@ describe Guard::Cunit do
25
25
  Guard::setup({:no_interactions => true})
26
26
  @@first = false
27
27
  else
28
- Guard::reload({})
28
+ options = ::Guard.state.session.evaluator_options
29
+ evaluator = ::Guard::Guardfile::Evaluator.new(options)
30
+ evaluator.evaluate
29
31
  end
30
32
  end
31
33
 
@@ -33,8 +35,8 @@ describe Guard::Cunit do
33
35
  Dir.chdir(@work_dir)
34
36
  tmp_work_dir=@tmp_env.create_tmp_prj_dir
35
37
  Dir.chdir((tmp_work_dir))
36
- Guard::UI.stub(:info)
37
- IO.stub(:popen)
38
+ allow(Guard::UI).to receive(:info)
39
+ allow(IO).to receive(:popen)
38
40
  end
39
41
 
40
42
  after(:each) do
@@ -43,7 +45,7 @@ describe Guard::Cunit do
43
45
  end
44
46
 
45
47
  it "should inherit Guard class" do
46
- subject.class.ancestors.should include(Guard::Guard)
48
+ expect(Guard::Cunit.ancestors).to include(Guard::Plugin)
47
49
  end
48
50
 
49
51
  context "Run guard" do
@@ -64,9 +66,8 @@ describe Guard::Cunit do
64
66
  it "should run build on changes " do
65
67
 
66
68
  cguard = Guard::Cunit.new
67
- cguard.stub(:run_all).and_return(true)
68
- Guard::UI.should_receive(:info).with("Process changes in #{File.basename(Dir.getwd)}")
69
-
69
+ expect(cguard).to receive(:run_all).and_return(true)
70
+ expect(Guard::UI).to receive(:info).with("Process changes in #{File.basename(Dir.getwd)}")
70
71
  cguard.run_on_change("#{File.basename(Dir.getwd)}")
71
72
 
72
73
  end
@@ -78,13 +79,12 @@ describe Guard::Cunit do
78
79
  popen_successfull_fake("make clean")
79
80
  popen_successfull_fake("make 2>&1")
80
81
  fake_test_exe("./jiji",:pass)
81
-
82
82
  cguard = Guard::Cunit::Runner.new
83
83
  setup_guard
84
84
  cguard.run
85
85
  newenv =get_ld_path
86
- newenv.should include("#{oldenv}")
87
- newenv.should include("#{Dir.getwd}")
86
+ expect(newenv).to include("#{oldenv}")
87
+ expect(newenv).to include("#{Dir.getwd}")
88
88
  get_ld_path=oldenv
89
89
  end
90
90
 
@@ -101,8 +101,8 @@ describe Guard::Cunit do
101
101
  setup_guard
102
102
  cguard.run
103
103
  newenv =get_ld_path
104
- newenv.should include("#{oldenv}")
105
- newenv.should include("#{File.join(Dir.getwd,"lib")}")
104
+ expect(newenv).to include("#{oldenv}")
105
+ expect(newenv).to include("#{File.join(Dir.getwd,"lib")}")
106
106
  get_ld_path=oldenv
107
107
  end
108
108
 
@@ -141,7 +141,7 @@ describe Guard::Cunit do
141
141
  popen_successfull_fake("./make_all.sh")
142
142
  popen_successfull_fake("./clean_all.sh")
143
143
  cguard = Guard::Cunit::Runner.new
144
- setup_guard
144
+ setup_guard
145
145
  cguard.run
146
146
 
147
147
  end
@@ -156,7 +156,7 @@ describe Guard::Cunit do
156
156
  popen_failing_fake("make 2>&1")
157
157
  cguard = Guard::Cunit::Runner.new
158
158
  setup_guard
159
- cguard.run.should == false
159
+ expect(cguard.run).to eq false
160
160
  end
161
161
 
162
162
  it "should block further tasks on build failed" do
@@ -165,11 +165,11 @@ describe Guard::Cunit do
165
165
  popen_failing_fake("make 2>&1")
166
166
  f = File.new("./jiji", "w+", 0666)
167
167
  f.close
168
- IO.stub(:popen).with("jiji".split << {:err=>[:child, :out]})
169
- IO.should_not_receive(:popen).with("jiji".split << {:err=>[:child, :out]})
168
+ allow(IO).to receive(:popen).with("jiji".split << {:err=>[:child, :out]})
169
+ expect(IO).not_to receive(:popen).with("jiji".split << {:err=>[:child, :out]})
170
170
  cguard = Guard::Cunit::Runner.new
171
171
  setup_guard
172
- cguard.run.should == false
172
+ expect(cguard.run).to eq false
173
173
  end
174
174
 
175
175
 
@@ -180,7 +180,7 @@ describe Guard::Cunit do
180
180
  fake_test_exe("./jiji",:fail)
181
181
  cguard = Guard::Cunit::Runner.new
182
182
  setup_guard
183
- cguard.run.should == false
183
+ expect(cguard.run).to eq false
184
184
  end
185
185
 
186
186
  end
@@ -189,9 +189,9 @@ describe Guard::Cunit do
189
189
  context "Displaying notifications" do
190
190
 
191
191
  it "should display failure if build fails" do
192
- Guard::Notifier.stub(:notify)
192
+ allow(Guard::Notifier).to receive(:notify)
193
193
  guardfile_has_unit_test_exe()
194
- Guard::Notifier.should_receive(:notify).with("Failed", :title => "Build Failed", :image => :failed, :priority => 2)
194
+ allow(Guard::Notifier).to receive(:notify).with("Failed", :title => "Build Failed", :image => :failed, :priority => 2)
195
195
  popen_successfull_fake("make clean")
196
196
  popen_failing_fake("make 2>&1")
197
197
  cguard = Guard::Cunit::Runner.new
@@ -200,10 +200,10 @@ describe Guard::Cunit do
200
200
  end
201
201
 
202
202
  it "should display failure if test fails" do
203
- IO.stub(:popen)
204
- Guard::Notifier.stub(:notify)
203
+ allow(IO).to receive(:popen)
204
+ allow(Guard::Notifier).to receive(:notify)
205
205
  guardfile_has_unit_test_exe(:test_exe=>"jiji")
206
- Guard::Notifier.should_receive(:notify).with( anything(), :title => "Test Failed", :image => :failed, :priority => 2 )
206
+ allow(Guard::Notifier).to receive(:notify).with( anything(), :title => "Test Failed", :image => :failed, :priority => 2 )
207
207
  popen_successfull_fake("make clean")
208
208
  popen_successfull_fake("make 2>&1")
209
209
  fake_test_exe("./jiji",:fail)
@@ -213,9 +213,9 @@ describe Guard::Cunit do
213
213
  end
214
214
 
215
215
  it "should display pending if test is absent" do
216
- Guard::Notifier.stub(:notify)
216
+ allow(Guard::Notifier).to receive(:notify)
217
217
  guardfile_has_unit_test_exe()
218
- Guard::Notifier.should_receive(:notify).with("Pending", :title => "Test Not Defined", :image => :pending, :priority => 2)
218
+ allow(Guard::Notifier).to receive(:notify).with("Pending", :title => "Test Not Defined", :image => :pending, :priority => 2)
219
219
  popen_successfull_fake("make clean")
220
220
  popen_successfull_fake("make 2>&1")
221
221
  cguard = Guard::Cunit::Runner.new
@@ -224,14 +224,14 @@ describe Guard::Cunit do
224
224
  end
225
225
 
226
226
  it "should display success if build and test succeeded" do
227
- Guard::Notifier.stub(:notify)
227
+ allow(Guard::Notifier).to receive(:notify)
228
228
  guardfile_has_unit_test_exe()
229
- Guard::Notifier.should_receive(:notify).with("Success", :title => "Test Passed", :image => :passed, :priority => 2)
229
+ allow(Guard::Notifier).to receive(:notify).with("Success", :title => "Test Passed", :image => :success, :priority => 2)
230
230
  popen_successfull_fake("make clean")
231
231
  popen_successfull_fake("make 2>&1")
232
232
  fake_test_exe(nil,:pass)
233
233
  cguard = Guard::Cunit::Runner.new
234
- Guard.add_guard('cunit')
234
+ Guard.state.session.plugins.add('cunit', Hash.new)
235
235
  cguard.run
236
236
  end
237
237
  end
@@ -2,10 +2,12 @@ require 'rubygems'
2
2
  require 'fileutils'
3
3
  require 'pathname'
4
4
  require 'guard'
5
+ require 'guard/commander'
5
6
  require 'guard/cunit'
6
7
  require 'guard/cunit/runner'
7
8
  require 'guard/cunit/cunit_parser'
8
9
  require 'rspec'
10
+ require 'pry_debug'
9
11
 
10
12
  # a class to set/cleanup environment for fake project
11
13
  class TempPrjEnv
@@ -59,11 +61,11 @@ def popen_fake(fakename,exp_result)
59
61
  pipe_args = fakename.split << {:err=>[:child, :out]}
60
62
  end
61
63
 
62
- IO.stub(:popen).with(pipe_args)
64
+ allow(IO).to receive(:popen).with(pipe_args)
63
65
  if exp_result == false
64
- IO.should_receive(:popen).with(pipe_args) { fake_script(1) }
66
+ expect(IO).to receive(:popen).with(pipe_args) { fake_script(1) }
65
67
  else
66
- IO.should_receive(:popen).with(pipe_args) { fake_script(0) }
68
+ expect(IO).to receive(:popen).with(pipe_args) { fake_script(0) }
67
69
  end
68
70
  end
69
71
 
metadata CHANGED
@@ -1,75 +1,88 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: guard-cunit
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Tea Cup On Rocking Chair
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-12-02 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- type: :runtime
22
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2015-12-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: guard
16
+ requirement: !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 13
28
- segments:
29
- - 1
30
- - 1
31
- version: "1.1"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '1.1'
22
+ type: :runtime
32
23
  prerelease: false
33
- name: guard
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- type: :development
37
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
38
25
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '1.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: guard-compat
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.1'
38
+ type: :runtime
46
39
  prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.1'
46
+ - !ruby/object:Gem::Dependency
47
47
  name: bundler
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- type: :development
51
- requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
52
49
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
60
55
  prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
61
63
  name: rspec
62
- version_requirements: *id003
63
- description: Guard Cunit should automatically build your C project and run CUnit based tests
64
- email:
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Guard Cunit should automatically build your C project and run CUnit based
79
+ tests
80
+ email:
65
81
  - strandjata@gmail.com
66
82
  executables: []
67
-
68
83
  extensions: []
69
-
70
84
  extra_rdoc_files: []
71
-
72
- files:
85
+ files:
73
86
  - .travis.yml
74
87
  - CHANGELOG.md
75
88
  - Gemfile
@@ -87,36 +100,29 @@ files:
87
100
  - spec/spec_helper.rb
88
101
  homepage: http://teacup-on-rockingchair.github.com/guard-cunit/
89
102
  licenses: []
90
-
91
103
  post_install_message:
92
104
  rdoc_options: []
93
-
94
- require_paths:
105
+ require_paths:
95
106
  - lib
96
- required_ruby_version: !ruby/object:Gem::Requirement
107
+ required_ruby_version: !ruby/object:Gem::Requirement
97
108
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
103
- - 0
104
- version: "0"
105
- required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
114
  none: false
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- hash: 3
111
- segments:
112
- - 0
113
- version: "0"
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
114
119
  requirements: []
115
-
116
120
  rubyforge_project: guard-cunit
117
- rubygems_version: 1.8.24
121
+ rubygems_version: 1.8.23
118
122
  signing_key:
119
123
  specification_version: 3
120
124
  summary: Guard gem for CUnit-driven projects
121
- test_files: []
122
-
125
+ test_files:
126
+ - spec/guard_cunit_parser_spec.rb
127
+ - spec/guard_cunit_spec.rb
128
+ - spec/spec_helper.rb