Permalink
Browse files

--default_directory is not supported on Ruby 1.8.6

  • Loading branch information...
1 parent 2c9aef1 commit 9f7b49564bbdea0b014a27fea986ba9bbb70c810 @dchelimsky dchelimsky committed Jun 10, 2011
Showing with 27 additions and 22 deletions.
  1. +6 −1 cucumber.yml
  2. +21 −20 features/configuration/default_path.feature
  3. +0 −1 features/support/env.rb
View
@@ -1,2 +1,7 @@
-default: --require features --strict --format progress --tags ~@wip<%= RUBY_PLATFORM == 'java' ? ' --tags ~@no-jruby' : '' %> features
+<%
+exclusions = []
+exclusions << ' --tags ~@no-jruby' if RUBY_PLATFORM == 'java'
+exclusions << ' --tags ~@no-ruby-186' if RUBY_VERSION == '1.8.6'
+%>
+default: --require features --strict --format progress --tags ~@wip<%= exclusions.join %> features
wip: --require features --tags @wip:3 --wip features
@@ -1,40 +1,41 @@
+@no-ruby-186
Feature: default_path
- Use `config.default_path` to set the spec directory that contains
- all of the examples. With this option, executing `rspec` is equivalent to
- `rspec [default_path]`. The default option is set to "spec".
+ As of rspec-2.7 (not yet released), you can just type `rspec` to run all
+ specs that live in the `spec` directory.
- Scenario: the default default_path is spec
+ This is supported by a `--default_path` option, which is set to `spec` by
+ default. If you prefer to keep your specs in a different directory, or assign
+ an individual file to the `--default_path`, you can do so on the command line
+ or in a configuration file (`.rspec`, `~/.rspec`, or a custom file).
+
+ NOTE: this option is not supported on `RSpec.configuration`, as it needs to
+ be set before spec files get loaded.
+
+ WARNING: this feature is not supported on Ruby-1.8.6
+
+ Scenario: run `rspec` with default default_path (`spec` directory)
Given a file named "spec/example_spec.rb" with:
"""
describe "an example" do
it "passes" do
end
end
"""
- When I run `rspec -f doc`
- Then the output should contain "passes"
-
- Scenario: changing the default_path
-
- Because this is a configuration that happens *before* spec files are
- loaded, we have to use a `.rspec` configuration file here. Normally, you
- would just do the following:
-
- RSpec.configure do |config|
- config.default_path = :the_directory
- end
+ When I run `rspec`
+ Then the output should contain "1 example, 0 failures"
+ Scenario: run `rspec` with customized default_path
Given a file named ".rspec" with:
"""
- --default_path specs
+ --default_path behavior
"""
- Given a file named "specs/example_spec.rb" with:
+ Given a file named "behavior/example_spec.rb" with:
"""
describe "an example" do
it "passes" do
end
end
"""
- When I run `rspec -f doc`
- Then the output should contain "passes"
+ When I run `rspec`
+ Then the output should contain "1 example, 0 failures"
@@ -3,4 +3,3 @@
Before do
@aruba_timeout_seconds = 3
end
-

6 comments on commit 9f7b495

@dchelimsky
Member

@justinko - I didn't look into why, but this fails for Ruby-1.8.6. I'm not that concerned as it only affects a small population of users and it's a convenience as opposed to a core API, but if you want to try to get it to work on 1.8.6, feel free.

@justinko
Contributor

Man I totally bombed on implementing this feature. Looking into the 1.8.6 issue....

@dchelimsky
Member
@justinko
Contributor

It is failing on 1.8.6 & 1.8.7. I got the cuke to pass with this commit (default_path branch):

cc6c2c0

I did a ton of "inspection" and I'm at a loss.

@dchelimsky
Member

Got it working with 1da8e31.

The issue was non-deterministic order of hash keys. default_path= needs to be invoked before files_or_directories_to_run=, but this was not happening consistently across all rubies (though it appeared be consistently correct or incorrect within each ruby).

@justinko
Contributor

Yep, Ruby 1.9 preserves hash insertion order, while 1.8 does not :(

This is why ActiveSupport implements OrderedHash.

Please sign in to comment.