Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rspec: tmux is still being run someplace... #563

Closed
docwhat opened this issue Feb 26, 2014 · 4 comments
Closed

rspec: tmux is still being run someplace... #563

docwhat opened this issue Feb 26, 2014 · 4 comments
Labels

Comments

@docwhat
Copy link
Contributor

docwhat commented Feb 26, 2014

It appears that tmux is being run someplace in ruby 2.0.0...

This is with commit 224e350 on 2.0.0p451 on OS X 10.9.1.

You can see it in the "session not found" and "couldn't set" messages.

This was with random seed 59332.

Guard::Guardfile::Evaluator
  .evaluate_guardfile
    selection of the Guardfile data source
      with the :guardfile_contents option
        stores guardfile_contents as expected
        stores guardfile_path as "Inline Guardfile"
        with a user config file available
          appends it to guardfile_contents
        with other Guardfiles available
          has ultimate precedence
      with the :guardfile option
        stores guardfile_contents as expected
        with an absolute path to custom Guardfile
          stores guardfile_path as expanded path
        with a user config file available
          appends it to guardfile_contents
        with other Guardfiles available
          has precedence over default Guardfiles
        with a relative path to custom Guardfile
          stores guardfile_path as expanded path
      with no option
        home Guardfile
          stores guardfile_contents as expected
          stores guardfile_path as expanded path
          with a user config file available
            appends it to guardfile_contents
        local Guardfile
          stores guardfile_path as expanded path
          stores guardfile_contents as expected
          is the default
          with a user config file available
            appends it to guardfile_contents
          with a home Guardfile available
            has precedence over home Guardfile
    errors cases
      with an invalid Guardfile
        displays an error message and raises original exception
      with empty Guardfile content
        does not display an error message
      with no Guardfile at all
        displays an error message and exits
      with a non-existing Guardfile given
        raises error
      with a problem reading a Guarfile
        displays an error message and exits
      with Guardfile content is nil
        does not raise error and skip it
  .guardfile_include?
    detects a guard specified by a string with single quote
    detects a guard wrapped in parentheses
    detects a guard specified by a symbol
    detects a guard specified by a string with double quotes
  .reevaluate_guardfile
    evaluates the Guardfile
    after reevaluation
      with notifications disabled
        does not enable the notifications again
      without Guards afterwards
        shows a failure notification
      with Guards afterwards
        shows a success notification
        starts all Guards
        shows a success message
      with notifications enabled
        enables the notifications again
    before reevaluation
      resets all Guard plugins
      stops all Guards
      resets all scopes
      resets all groups
session not found: tty
couldn't set 'status-left-bg'
session not found: tty
couldn't set 'status-right-bg'
session not found: tty
couldn't set 'status-left-fg'
session not found: tty
couldn't set 'status-right-fg'
session not found: tty
couldn't set 'message-bg'
session not found: tty
couldn't set 'message-fg'
session not found: tty
couldn't set 'display-time'
unknown option: option1
unknown option: option2
      clears the notifiers
  .initialize
    with the :guardfile option
      uses the given Guardfile content
    with the :guardfile_contents option
      uses the given Guardfile content
@docwhat
Copy link
Contributor Author

docwhat commented Feb 26, 2014

Ah, it looks like with randomized test orders, the stubs sometimes fail. With seed 24183 I got this:

Failures:

  1) Guard::Notifier::Tmux#turn_off when on restores the tmux options
     Failure/Error: expect(described_class).to receive(:`).with('tmux set -t tty -q option2 setting2')
       (<Guard::Notifier::Tmux (class)>).`("tmux set -t tty -q option2 setting2")
           expected: 1 time with arguments: ("tmux set -t tty -q option2 setting2")
           received: 0 times with arguments: ("tmux set -t tty -q option2 setting2")
     # ./spec/lib/guard/notifiers/tmux_spec.rb:335:in `block (4 levels) in <top (required)>'

I think this is why travis failed on pull request #559 the first time.

@docwhat
Copy link
Contributor Author

docwhat commented Feb 26, 2014

I'm taking a look at converting all the stubbing syntax, etc. to rspec-mocks 3.0 syntax:

e.g.

allow(Guard).to receive(:some_method)

allow_any_instance_of(Hash).to receive(:some_method)

@docwhat
Copy link
Contributor Author

docwhat commented Feb 26, 2014

Hmm...it looks like there is some system() leaks in the rspec tests...

You can see it by applying this patch below. I can't commit it because you have to press Control-C when it hangs. Basically rspec blows up due to trying to record what's going on. grin

diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 72f3390..a0b17e0 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -37,6 +37,11 @@
     allow(Guard::Notifier::TerminalTitle).to receive(:puts)
     allow(Pry.output).to receive(:puts)

+    allow_any_instance_of(Object).to receive(:system) { fail 'Unstubbed Object.system()' }
+    allow_any_instance_of(Object).to receive(:`)      { fail 'Unstubbed Object.`()' }
+    allow(Kernel).to receive(:system)                 { fail 'Unstubbed Kernel.system()' }
+    allow(Kernel).to receive(:`)                      { fail 'Unstubbed Kernel.`()' }
+
     ::Guard.reset_groups
     ::Guard.reset_plugins
   end

I suspect that there needs to be a unified approach to handling the various system() calls and that seteruper_spec.rb should use a different spec_helper.rb so that it can test its system() stuff separately.

I haven't quite figured out how all the parts fit together, but I'd be willing to write these changes with help.

@netzpirat
Copy link
Contributor

I "fixed" it by stubbing the Tmux notifier in the spec helper. @rymai pull request will solve it more properly, but for now we can ensure Travis doesn't fail anymore because of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants