3 spec/bundler is rspec examples for bundler library (`lib/bundler.rb`, `lib/bundler/*`).
5 ## Running spec/bundler
7 To run rspec for bundler:
13 or run rspec with parallel execution:
16 make test-bundler-parallel
19 If you specify `BUNDLER_SPECS=foo/bar_spec.rb` then only `spec/bundler/foo/bar_spec.rb` will be run.
23 ruby/spec (https://github.com/ruby/spec/) is
24 a test suite for the Ruby language.
26 Once a month, @eregon merges the in-tree copy under spec/ruby
27 with the upstream repository, preserving the commits and history.
28 The same happens for other implementations such as JRuby and TruffleRuby.
30 Feel welcome to modify the in-tree spec/ruby.
31 This is the purpose of the in-tree copy,
32 to facilitate contributions to ruby/spec for MRI developers.
34 New features, additional tests for existing features and
35 regressions tests are all welcome in ruby/spec.
36 There is very little behavior that is implementation-specific,
37 as in the end user programs tend to rely on every behavior MRI exhibits.
38 In other words: If adding a spec might reveal a bug in
39 another implementation, then it is worth adding it.
40 Currently, the only module which is MRI-specific is `RubyVM`.
42 ## Changing behavior and versions guards
44 Version guards (`ruby_version_is`) must be added for new features or features
45 which change behavior or are removed. This is necessary for other Ruby implementations
46 to still be able to run the specs and contribute new specs.
51 describe "Some spec" do
53 # Old behavior for Ruby < 2.7
61 describe "Some spec" do
62 ruby_version_is ""..."2.7" do
64 # Old behavior for Ruby < 2.7
68 ruby_version_is "2.7" do
70 # New behavior for Ruby >= 2.7
76 See `spec/ruby/CONTRIBUTING.md` for more documentation about guards.
78 To verify specs are compatible with older Ruby versions:
82 $RUBY_MANAGER use 2.4.9
94 Extra arguments can be added via `SPECOPTS`.
95 For instance, to show the help:
98 make test-spec SPECOPTS=-h
101 You can also run the specs in parallel, which is currently experimental.
102 It takes around 10s instead of 60s on a quad-core laptop.
105 make test-spec SPECOPTS=-j
108 To run a specific test, add its path to the command:
111 make test-spec SPECOPTS=spec/ruby/language/for_spec.rb
114 If ruby trunk is your current `ruby` in `$PATH`, you can also run `mspec` directly:
117 # change ruby to trunk
119 spec/mspec/bin/mspec spec/ruby/language/for_spec.rb
122 ## ruby/spec and test/
124 The main difference between a "spec" under `spec/ruby/` and
125 a test under `test/` is that specs are documenting what they test.
126 This is extremely valuable when reading these tests, as it
127 helps to quickly understand what specific behavior is tested,
128 and how a method should behave. Basic English is fine for spec descriptions.
129 Specs also tend to have few expectations (assertions) per spec,
130 as they specify one aspect of the behavior and not everything at once.
131 Beyond that, the syntax is slightly different but it does the same thing:
132 `assert_equal 3, 1+2` is just `(1+2).should == 3`.
137 describe "The for expression" do
138 it "iterates over an Enumerable passing each element to the block" do
148 For more details, see `spec/ruby/CONTRIBUTING.md`.
150 # spec/syntax_suggest
152 ## Running spec/syntax_suggest
154 To run rspec for syntax_suggest:
157 make test-syntax-suggest
160 If you specify `SYNTAX_SUGGEST_SPECS=foo/bar_spec.rb` then only `spec/syntax_suggest/foo/bar_spec.rb` will be run.