mspec 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +9 -7
  3. data/lib/mspec/commands/mspec.rb +0 -8
  4. data/lib/mspec/guards/platform.rb +4 -0
  5. data/lib/mspec/helpers/environment.rb +12 -22
  6. data/lib/mspec/helpers/io.rb +6 -1
  7. data/lib/mspec/helpers/mock_to_path.rb +1 -1
  8. data/lib/mspec/helpers/ruby_exe.rb +8 -3
  9. data/lib/mspec/runner/actions.rb +0 -1
  10. data/lib/mspec/utils/options.rb +0 -4
  11. data/lib/mspec/utils/script.rb +0 -1
  12. data/lib/mspec/version.rb +1 -1
  13. data/spec/commands/mkspec_spec.rb +31 -31
  14. data/spec/commands/mspec_ci_spec.rb +14 -14
  15. data/spec/commands/mspec_run_spec.rb +4 -4
  16. data/spec/commands/mspec_spec.rb +33 -56
  17. data/spec/commands/mspec_tag_spec.rb +26 -26
  18. data/spec/guards/background_spec.rb +1 -1
  19. data/spec/guards/block_device_spec.rb +1 -1
  20. data/spec/guards/bug_spec.rb +4 -4
  21. data/spec/guards/compliance_spec.rb +2 -2
  22. data/spec/guards/conflict_spec.rb +5 -5
  23. data/spec/guards/endian_spec.rb +8 -8
  24. data/spec/guards/extensions_spec.rb +1 -1
  25. data/spec/guards/feature_spec.rb +1 -1
  26. data/spec/guards/guard_spec.rb +20 -20
  27. data/spec/guards/noncompliance_spec.rb +1 -1
  28. data/spec/guards/platform_spec.rb +14 -14
  29. data/spec/guards/quarantine_spec.rb +1 -1
  30. data/spec/guards/runner_spec.rb +7 -7
  31. data/spec/guards/specified_spec.rb +7 -7
  32. data/spec/guards/superuser_spec.rb +3 -3
  33. data/spec/guards/support_spec.rb +1 -1
  34. data/spec/guards/tty_spec.rb +1 -1
  35. data/spec/guards/user_spec.rb +3 -3
  36. data/spec/guards/version_spec.rb +3 -3
  37. data/spec/helpers/ducktype_spec.rb +3 -3
  38. data/spec/helpers/environment_spec.rb +18 -10
  39. data/spec/helpers/flunk_spec.rb +2 -2
  40. data/spec/helpers/io_spec.rb +2 -2
  41. data/spec/helpers/ruby_exe_spec.rb +5 -9
  42. data/spec/matchers/have_singleton_method_spec.rb +1 -1
  43. data/spec/matchers/output_spec.rb +1 -1
  44. data/spec/mocks/mock_spec.rb +41 -41
  45. data/spec/mocks/proxy_spec.rb +1 -1
  46. data/spec/runner/actions/filter_spec.rb +1 -1
  47. data/spec/runner/actions/tag_spec.rb +17 -17
  48. data/spec/runner/actions/taglist_spec.rb +8 -8
  49. data/spec/runner/actions/tagpurge_spec.rb +11 -11
  50. data/spec/runner/actions/timer_spec.rb +4 -4
  51. data/spec/runner/context_spec.rb +32 -32
  52. data/spec/runner/example_spec.rb +1 -1
  53. data/spec/runner/filters/profile_spec.rb +2 -2
  54. data/spec/runner/filters/tag_spec.rb +6 -6
  55. data/spec/runner/formatters/describe_spec.rb +6 -6
  56. data/spec/runner/formatters/dotted_spec.rb +10 -10
  57. data/spec/runner/formatters/file_spec.rb +2 -2
  58. data/spec/runner/formatters/html_spec.rb +10 -10
  59. data/spec/runner/formatters/junit_spec.rb +11 -11
  60. data/spec/runner/formatters/method_spec.rb +3 -3
  61. data/spec/runner/formatters/specdoc_spec.rb +1 -1
  62. data/spec/runner/formatters/spinner_spec.rb +4 -4
  63. data/spec/runner/formatters/unit_spec.rb +7 -7
  64. data/spec/runner/formatters/yaml_spec.rb +10 -10
  65. data/spec/runner/mspec_spec.rb +25 -25
  66. data/spec/runner/shared_spec.rb +1 -1
  67. data/spec/utils/options_spec.rb +28 -50
  68. data/spec/utils/script_spec.rb +15 -24
  69. metadata +12 -16
  70. data/lib/mspec/runner/actions/gdb.rb +0 -17
  71. data/spec/runner/actions/gdb_spec.rb +0 -61
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db64f3a62d63a1638a20baa6df40cebc68b02ec2
4
- data.tar.gz: 65f01cb75ab6f4decb63e7fdb4989dd171645259
3
+ metadata.gz: 733fa565d5e2085c638435f1fc22513fa124bec8
4
+ data.tar.gz: ed6da518e6058b01ef1a7ea8f99ffd2f051c2994
5
5
  SHA512:
6
- metadata.gz: 066466880beebed65251d5f8f167b3ecc61739b982ababa3c97021ef1421f40391c4ba8d24cff9fba50ba400f4ad7a911fee467ac3f2872f1827cd44654589ac
7
- data.tar.gz: 10d37dbe04a31f6fe9fa0ceeb3c46abc5ca7e2013852dd29cc4d5500148ba382bfb3dcdc130ae0d19c687b27d93e62918ae2f6231ddd18b98e094c073259673f
6
+ metadata.gz: b61ffdbc4bfc08fcbd7bdcb31004186135b9e6e06f8c7c8b062ebf7b170d840e1368898af9d8b6995a701a647aa7e314d85ea80e5825e854365b351e98834589
7
+ data.tar.gz: d3312bdda59bfa8380bf7f85ccc010683f1e43e04e3dda5231ded27fea339af823bfad6bfca5d4b1c918f85e6cd9f8738ef0c7601bfd874ea6f6a4a40b94e81a
@@ -5,14 +5,16 @@ jdk:
5
5
  - openjdk7
6
6
  rvm:
7
7
  - 1.8.7
8
- - 1.9.3
9
- - 2.0.0
10
- - 2.1.0
8
+ - 2.1.5
11
9
  - ruby-head
12
10
  - rbx-2
13
11
  - jruby-head
14
- allow_failures:
15
- - rvm: jruby-head
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: jruby-head
15
+ - rvm: rbx-2
16
+ - rvm: ruby-head
16
17
  notifications:
17
- recipients:
18
- - brixen@gmail.com
18
+ email:
19
+ recipients:
20
+ - brixen@gmail.com
@@ -37,10 +37,6 @@ class MSpecMain < MSpecScript
37
37
 
38
38
  options.targets
39
39
 
40
- options.on("-D", "--gdb", "Run under gdb") do
41
- config[:use_gdb] = true
42
- end
43
-
44
40
  options.on("-A", "--valgrind", "Run under valgrind") do
45
41
  config[:use_valgrind] = true
46
42
  end
@@ -162,12 +158,8 @@ class MSpecMain < MSpecScript
162
158
  else
163
159
  if config[:use_valgrind]
164
160
  more = ["--child-silent-after-fork=yes",
165
- "--db-attach=#{config[:use_gdb] ? 'yes' : 'no'}",
166
161
  config[:target]] + argv
167
162
  exec "valgrind", *more
168
- elsif config[:use_gdb]
169
- more = ["--args", config[:target]] + argv
170
- exec "gdb", *more
171
163
  else
172
164
  cmd, *rest = config[:target].split(/\s+/)
173
165
  argv = rest + argv unless rest.empty?
@@ -5,6 +5,10 @@ class PlatformGuard < SpecGuard
5
5
  PlatformGuard.new(:os => :windows).match?
6
6
  end
7
7
 
8
+ def self.opal?
9
+ PlatformGuard.new(:opal)
10
+ end
11
+
8
12
  def initialize(*args)
9
13
  if args.last.is_a?(Hash)
10
14
  @options, @platforms = args.last, args[0..-2]
@@ -2,19 +2,13 @@ require 'mspec/guards/guard'
2
2
 
3
3
  class Object
4
4
  def env
5
- platform_is_not :opal, :windows do
6
- env = Hash[*`env`.split("\n").map { |e| e.split("=", 2) }.flatten]
7
- end
8
-
9
- platform_is :windows do
10
- env = Hash[*`cmd.exe /C set`.split("\n").map { |e| e.split("=", 2) }.flatten]
11
- end
12
-
13
- platform_is :opal do
14
- env = {}
5
+ if PlatformGuard.windows?
6
+ Hash[*`cmd.exe /C set`.split("\n").map { |e| e.split("=", 2) }.flatten]
7
+ elsif PlatformGuard.opal?
8
+ {}
9
+ else
10
+ Hash[*`env`.split("\n").map { |e| e.split("=", 2) }.flatten]
15
11
  end
16
-
17
- env
18
12
  end
19
13
 
20
14
  def windows_env_echo(var)
@@ -24,17 +18,13 @@ class Object
24
18
  end
25
19
 
26
20
  def username
27
- user = ""
28
-
29
- platform_is :windows do
30
- user = windows_env_echo('USERNAME')
31
- end
32
-
33
- platform_is_not :opal do
34
- user = `whoami`.strip
21
+ if PlatformGuard.windows?
22
+ windows_env_echo('USERNAME')
23
+ elsif PlatformGuard.opal?
24
+ ""
25
+ else
26
+ `whoami`.strip
35
27
  end
36
-
37
- user
38
28
  end
39
29
 
40
30
  def home_directory
@@ -53,7 +53,12 @@ class IOStub
53
53
  flush
54
54
  @output
55
55
  end
56
- alias to_str to_s
56
+
57
+ alias_method :to_str, :to_s
58
+
59
+ def inspect
60
+ to_s.inspect
61
+ end
57
62
  end
58
63
 
59
64
  class Object
@@ -1,6 +1,6 @@
1
1
  class Object
2
2
  def mock_to_path(path)
3
- obj = mock('path')
3
+ obj = double('path')
4
4
  obj.should_receive(:to_path).and_return(path)
5
5
  obj
6
6
  end
@@ -146,11 +146,16 @@ class Object
146
146
 
147
147
  if code and not File.exist?(code)
148
148
  if opts[:escape]
149
- code = "'#{code}'"
149
+ heredoc_separator = "END_OF_RUBYCODE"
150
+ lines = code.lines
151
+ until lines.none? {|line| line.start_with? heredoc_separator }
152
+ heredoc_separator << heredoc_separator
153
+ end
154
+
155
+ body = %Q!-e "$(cat <<'#{heredoc_separator}'\n#{code}\n#{heredoc_separator}\n)"!
150
156
  else
151
- code = code.inspect
157
+ body = "-e #{code.inspect}"
152
158
  end
153
- body = "-e #{code}"
154
159
  end
155
160
 
156
161
  [RUBY_EXE, ENV['RUBY_FLAGS'], opts[:options], body, opts[:args]].compact.join(' ')
@@ -4,4 +4,3 @@ require 'mspec/runner/actions/filter'
4
4
  require 'mspec/runner/actions/tag'
5
5
  require 'mspec/runner/actions/taglist'
6
6
  require 'mspec/runner/actions/tagpurge'
7
- require 'mspec/runner/actions/gdb'
@@ -468,10 +468,6 @@ class MSpecOptions
468
468
  "Invoke the debugger when a spec description matches (see -K, -S)") do
469
469
  config[:debugger] = true
470
470
  end
471
- on("--spec-gdb",
472
- "Invoke Gdb when a spec description matches (see -K, -S)") do
473
- config[:gdb] = true
474
- end
475
471
  end
476
472
 
477
473
  def debug
@@ -125,7 +125,6 @@ class MSpecScript
125
125
  ProfileFilter.new(:exclude, *config[:xprofiles]).register unless config[:xprofiles].empty?
126
126
 
127
127
  DebugAction.new(config[:atags], config[:astrings]).register if config[:debugger]
128
- GdbAction.new(config[:atags], config[:astrings]).register if config[:gdb]
129
128
 
130
129
  custom_register
131
130
  end
@@ -1,5 +1,5 @@
1
1
  require 'mspec/utils/version'
2
2
 
3
3
  module MSpec
4
- VERSION = SpecVersion.new "1.7.0"
4
+ VERSION = SpecVersion.new "1.8.0"
5
5
  end
@@ -5,13 +5,13 @@ require 'mspec/commands/mkspec'
5
5
  describe "The -c, --constant CONSTANT option" do
6
6
  before :each do
7
7
  @options = MSpecOptions.new
8
- MSpecOptions.stub!(:new).and_return(@options)
8
+ MSpecOptions.stub(:new).and_return(@options)
9
9
  @script = MkSpec.new
10
10
  @config = @script.config
11
11
  end
12
12
 
13
13
  it "is enabled by #options" do
14
- @options.stub!(:on)
14
+ @options.stub(:on)
15
15
  @options.should_receive(:on).with("-c", "--constant", "CONSTANT",
16
16
  an_instance_of(String))
17
17
  @script.options
@@ -29,13 +29,13 @@ end
29
29
  describe "The -b, --base DIR option" do
30
30
  before :each do
31
31
  @options = MSpecOptions.new
32
- MSpecOptions.stub!(:new).and_return(@options)
32
+ MSpecOptions.stub(:new).and_return(@options)
33
33
  @script = MkSpec.new
34
34
  @config = @script.config
35
35
  end
36
36
 
37
37
  it "is enabled by #options" do
38
- @options.stub!(:on)
38
+ @options.stub(:on)
39
39
  @options.should_receive(:on).with("-b", "--base", "DIR",
40
40
  an_instance_of(String))
41
41
  @script.options
@@ -53,13 +53,13 @@ end
53
53
  describe "The -r, --require LIBRARY option" do
54
54
  before :each do
55
55
  @options = MSpecOptions.new
56
- MSpecOptions.stub!(:new).and_return(@options)
56
+ MSpecOptions.stub(:new).and_return(@options)
57
57
  @script = MkSpec.new
58
58
  @config = @script.config
59
59
  end
60
60
 
61
61
  it "is enabled by #options" do
62
- @options.stub!(:on)
62
+ @options.stub(:on)
63
63
  @options.should_receive(:on).with("-r", "--require", "LIBRARY",
64
64
  an_instance_of(String))
65
65
  @script.options
@@ -77,13 +77,13 @@ end
77
77
  describe "The -V, --version-guard VERSION option" do
78
78
  before :each do
79
79
  @options = MSpecOptions.new
80
- MSpecOptions.stub!(:new).and_return(@options)
80
+ MSpecOptions.stub(:new).and_return(@options)
81
81
  @script = MkSpec.new
82
82
  @config = @script.config
83
83
  end
84
84
 
85
85
  it "is enabled by #options" do
86
- @options.stub!(:on)
86
+ @options.stub(:on)
87
87
  @options.should_receive(:on).with("-V", "--version-guard", "VERSION",
88
88
  an_instance_of(String))
89
89
  @script.options
@@ -101,7 +101,7 @@ end
101
101
  describe MkSpec, "#options" do
102
102
  before :each do
103
103
  @options = MSpecOptions.new
104
- MSpecOptions.stub!(:new).and_return(@options)
104
+ MSpecOptions.stub(:new).and_return(@options)
105
105
  @script = MkSpec.new
106
106
  end
107
107
 
@@ -117,8 +117,8 @@ describe MkSpec, "#options" do
117
117
 
118
118
  it "prints help and exits if passed an unrecognized option" do
119
119
  @options.should_receive(:raise).with(MSpecOptions::ParseError, an_instance_of(String))
120
- @options.stub!(:puts)
121
- @options.stub!(:exit)
120
+ @options.stub(:puts)
121
+ @options.stub(:exit)
122
122
  @script.options "--iunknown"
123
123
  end
124
124
  end
@@ -162,8 +162,8 @@ describe MkSpec, "#write_requires" do
162
162
  @script = MkSpec.new
163
163
  @script.config[:base] = "spec"
164
164
 
165
- @file = mock("file")
166
- File.stub!(:open).and_yield(@file)
165
+ @file = double("file")
166
+ File.stub(:open).and_yield(@file)
167
167
  end
168
168
 
169
169
  it "writes the spec_helper require line" do
@@ -172,7 +172,7 @@ describe MkSpec, "#write_requires" do
172
172
  end
173
173
 
174
174
  it "writes require lines for each library specified on the command line" do
175
- @file.stub!(:puts)
175
+ @file.stub(:puts)
176
176
  @file.should_receive(:puts).with("require File.expand_path('../../../../spec_helper', __FILE__)")
177
177
  @file.should_receive(:puts).with("require 'complex'")
178
178
  @script.config[:requires] << 'complex'
@@ -183,14 +183,14 @@ end
183
183
  describe MkSpec, "#write_spec" do
184
184
  before :each do
185
185
  @file = IOStub.new
186
- File.stub!(:open).and_yield(@file)
186
+ File.stub(:open).and_yield(@file)
187
187
 
188
188
  @script = MkSpec.new
189
- @script.stub!(:puts)
189
+ @script.stub(:puts)
190
190
 
191
- @response = mock("system command response")
192
- @response.stub!(:=~).and_return(false)
193
- @script.stub!(:`).and_return(@response)
191
+ @response = double("system command response")
192
+ @response.stub(:=~).and_return(false)
193
+ @script.stub(:`).and_return(@response)
194
194
  end
195
195
 
196
196
  it "checks if specs exist for the method if the spec file exists" do
@@ -206,12 +206,12 @@ describe MkSpec, "#write_spec" do
206
206
  end
207
207
 
208
208
  it "returns nil if the spec file exists and contains a spec for the method" do
209
- @response.stub!(:=~).and_return(true)
209
+ @response.stub(:=~).and_return(true)
210
210
  @script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", true).should == nil
211
211
  end
212
212
 
213
213
  it "does not print the spec file name if it exists and contains a spec for the method" do
214
- @response.stub!(:=~).and_return(true)
214
+ @response.stub(:=~).and_return(true)
215
215
  @script.should_not_receive(:puts)
216
216
  @script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", true)
217
217
  end
@@ -262,10 +262,10 @@ end
262
262
  describe MkSpec, "#create_file" do
263
263
  before :each do
264
264
  @script = MkSpec.new
265
- @script.stub!(:write_requires)
266
- @script.stub!(:write_spec)
265
+ @script.stub(:write_requires)
266
+ @script.stub(:write_spec)
267
267
 
268
- File.stub!(:exist?).and_return(false)
268
+ File.stub(:exist?).and_return(false)
269
269
  end
270
270
 
271
271
  it "generates a file name based on the directory, class/module, and method" do
@@ -297,19 +297,19 @@ end
297
297
  describe MkSpec, "#run" do
298
298
  before :each do
299
299
  @options = MSpecOptions.new
300
- MSpecOptions.stub!(:new).and_return(@options)
300
+ MSpecOptions.stub(:new).and_return(@options)
301
301
 
302
302
  @map = NameMap.new
303
- NameMap.stub!(:new).and_return(@map)
303
+ NameMap.stub(:new).and_return(@map)
304
304
 
305
305
  @script = MkSpec.new
306
- @script.stub!(:create_directory).and_return("spec/mkspec")
307
- @script.stub!(:create_file)
306
+ @script.stub(:create_directory).and_return("spec/mkspec")
307
+ @script.stub(:create_file)
308
308
  @script.config[:constants] = [MkSpec]
309
309
  end
310
310
 
311
311
  it "loads files in the requires list" do
312
- @script.stub!(:require)
312
+ @script.stub(:require)
313
313
  @script.should_receive(:require).with("alib")
314
314
  @script.should_receive(:require).with("blib")
315
315
  @script.config[:requires] = ["alib", "blib"]
@@ -336,8 +336,8 @@ end
336
336
 
337
337
  describe MkSpec, ".main" do
338
338
  before :each do
339
- @script = mock("MkSpec").as_null_object
340
- MkSpec.stub!(:new).and_return(@script)
339
+ @script = double("MkSpec").as_null_object
340
+ MkSpec.stub(:new).and_return(@script)
341
341
  end
342
342
 
343
343
  it "sets MSPEC_RUNNER = '1' in the environment" do
@@ -6,11 +6,11 @@ require 'mspec/commands/mspec-ci'
6
6
  describe MSpecCI, "#options" do
7
7
  before :each do
8
8
  @options, @config = new_option
9
- MSpecOptions.stub!(:new).and_return(@options)
9
+ MSpecOptions.stub(:new).and_return(@options)
10
10
 
11
11
  @script = MSpecCI.new
12
- @script.stub!(:config).and_return(@config)
13
- @script.stub!(:files).and_return([])
12
+ @script.stub(:config).and_return(@config)
13
+ @script.stub(:files).and_return([])
14
14
  end
15
15
 
16
16
  it "enables the chdir option" do
@@ -96,19 +96,19 @@ end
96
96
 
97
97
  describe MSpecCI, "#run" do
98
98
  before :each do
99
- MSpec.stub!(:process)
99
+ MSpec.stub(:process)
100
100
 
101
- @filter = mock("TagFilter")
102
- TagFilter.stub!(:new).and_return(@filter)
103
- @filter.stub!(:register)
101
+ @filter = double("TagFilter")
102
+ TagFilter.stub(:new).and_return(@filter)
103
+ @filter.stub(:register)
104
104
 
105
105
  @tags = ["fails", "critical", "unstable", "incomplete", "unsupported"]
106
106
 
107
107
  @config = { :ci_files => ["one", "two"] }
108
108
  @script = MSpecCI.new
109
- @script.stub!(:exit)
110
- @script.stub!(:config).and_return(@config)
111
- @script.stub!(:files).and_return(["one", "two"])
109
+ @script.stub(:exit)
110
+ @script.stub(:config).and_return(@config)
111
+ @script.stub(:files).and_return(["one", "two"])
112
112
  @script.options
113
113
  end
114
114
 
@@ -124,7 +124,7 @@ describe MSpecCI, "#run" do
124
124
  end
125
125
 
126
126
  it "registers a tag filter for 'fails', 'unstable', 'incomplete', 'critical', 'unsupported'" do
127
- filter = mock("fails filter")
127
+ filter = double("fails filter")
128
128
  TagFilter.should_receive(:new).with(:exclude, *@tags).and_return(filter)
129
129
  filter.should_receive(:register)
130
130
  @script.run
@@ -132,7 +132,7 @@ describe MSpecCI, "#run" do
132
132
 
133
133
  it "registers an additional exclude tag specified by :ci_xtags" do
134
134
  @config[:ci_xtags] = "windows"
135
- filter = mock("fails filter")
135
+ filter = double("fails filter")
136
136
  TagFilter.should_receive(:new).with(:exclude, *(@tags + ["windows"])).and_return(filter)
137
137
  filter.should_receive(:register)
138
138
  @script.run
@@ -140,7 +140,7 @@ describe MSpecCI, "#run" do
140
140
 
141
141
  it "registers additional exclude tags specified by a :ci_xtags array" do
142
142
  @config[:ci_xtags] = ["windows", "windoze"]
143
- filter = mock("fails filter")
143
+ filter = double("fails filter")
144
144
  TagFilter.should_receive(:new).with(:exclude,
145
145
  *(@tags + ["windows", "windoze"])).and_return(filter)
146
146
  filter.should_receive(:register)
@@ -153,7 +153,7 @@ describe MSpecCI, "#run" do
153
153
  end
154
154
 
155
155
  it "exits with the exit code registered with MSpec" do
156
- MSpec.stub!(:exit_code).and_return(7)
156
+ MSpec.stub(:exit_code).and_return(7)
157
157
  @script.should_receive(:exit).with(7)
158
158
  @script.run
159
159
  end