Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Make specs and features global configuration proof #2602

Closed
wants to merge 2 commits into from

Conversation

pirj
Copy link
Member

@pirj pirj commented Feb 12, 2019

If a ~/.config/rspec/options file contains the following:

--color
--profile 2
--format progress
--require pry

some specs and features fail, since they are run with options that
contradict the default ones, and expectations are not met.

Example failures:

 (RSpec::Expectations::ExpectationNotMetError)
features/verifying_doubles/partial_doubles.feature:34:in `Then the output should contain "1 example, 1 failure"'
...
LoadError:
  cannot load such file -- pry


6) RSpec::Core::Formatters::ProgressFormatter produces the expected full output
...
   +Top 2 slowest example groups:
   +  pending command with block format
   +    n.nnnn seconds average (n.nnnn seconds / 2 examples) ./spec/rspec/core/resources/formatter_specs.rb:14
   +  failing spec
   +    n.nnnn seconds average (n.nnnn seconds / 2 examples) ./spec/rspec/core/resources/formatter_specs.rb:35
   +

This fixes rspec/rspec-dev#217. Similar issues affect features of rspec-mocks and rspec-expectations, will send out pull requests shortly.

NOTE: Unfortunately, this doesn't fix the issue for configuration stored in ~/.rspec. My advice is to move it over to ~/.config/rspec/options.

NOTE: Unfortunately, this doesn't fix the issue for --require pry for features.

@JonRowe
Copy link
Member

JonRowe commented Feb 13, 2019

Hm I was thinking more along the lines of modifying spec/support/sandboxing.rb to set the right configuration...

@pirj pirj force-pushed the make-tests-global-configuration-proof branch from 41a6129 to 3050e32 Compare February 17, 2019 11:01
@pirj
Copy link
Member Author

pirj commented Feb 17, 2019

@JonRowe Addressed your concerns, now it's less hacky. Please take another look.

@pirj pirj force-pushed the make-tests-global-configuration-proof branch 2 times, most recently from c1f3081 to e3a4e67 Compare February 17, 2019 11:36
pirj added 2 commits February 17, 2019 18:49
If a `~/.config/rspec/options` file contains the following:

    --color
    --profile 2
    --format progress
    --require pry

specs fail, since `--profile 2` option is picked up and used by the code
under test.

`$XDG_CONFIG_HOME/rspec/options` has to be isolated for some specs.
If a `~/.config/rspec/options` file contains the following:

    --color
    --profile 2
    --format progress

a number of features fail, since options are picked up and used by the
code under test.

Resetting `XDG_CONFIG_HOME` for those features isolates the global
configuration.
@pirj pirj force-pushed the make-tests-global-configuration-proof branch from ea7d2df to 99f9c28 Compare February 17, 2019 11:49
@pirj
Copy link
Member Author

pirj commented Feb 18, 2019

AppVeyor failure is unrelated.

@JonRowe
Copy link
Member

JonRowe commented Feb 18, 2019

This still isn't what I meant, we should set the config required to make specs pass, not ignore the config thats there...

@pirj
Copy link
Member Author

pirj commented Feb 23, 2019

@JonRowe I can't find a good way around some of the failing features. E.g. in my ~/.rspec (or $XDG_CONFIG_HOME/rspec/options) there's a line --format progress (or --format documentation, or any other format, no matter). If I add a step:

Given(/^a configuration file with defaults$/) do
  step %q{a file named ".rspec" with:}, "
    --no-profile
  "
end

and use it features/command_line/init.feature:25, which is:

     Then the output from `rspec` should not be in documentation format
      But the output from `rspec spec/addition_spec.rb` should be in documentation format
      But the output from `rspec spec/addition_spec.rb --format progress` should not be in documentation format

there is nothing that a I can put in that "configuration with defaults" to override the reset the global setting back to default (format for running all is in progress, format for running one is documentation), either of those fails:

features/command_line/init.feature:46:in `Then the output from `rspec` should not be in documentation format' 
...
features/command_line/init.feature:47:in `But the output from `rspec spec/addition_spec.rb` should be in documentation format' 

Do you have some hints?

@pirj
Copy link
Member Author

pirj commented Feb 23, 2019

I've already removed --require pry from my global conf. I'm more inclined to close this (and corresponding mocks and expectations PRs) and remove global configuration if I'm the only potential contributor suffering from weird failures due to global conf options.

@pirj pirj closed this Feb 23, 2019
@pirj pirj deleted the make-tests-global-configuration-proof branch February 23, 2019 15:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors occur with settings in ~/.rspec
2 participants