3

Hi I'm currently playing around with cucumber/aruba testing and really like it so far. But I stumbled on a problem with interactivity.

My App watches folders for changes and simply prints something like 'file changed' at the moment.

If I type jsbreeze watchFolder foo the app starts watching my folder and prints this to the console:

"Watching: foo"

I can easily test this with cucumber/aruba like that:

Scenario: jsbreeze should be able to watch a folder
    Given a directory named "foo"
    When I run `jsbreeze watchFolder foo` interactively
    And I wait for output to contain "Watching: foo"

But I actually want to test if it detects changes so I expected I could do something like this

Scenario: jsbreeze should be able to watch multiple folders
    Given a directory named "foo"
    When I run `jsbreeze watchFolder foo,.` interactively
    And I wait for output to contain "Watching: foo,."
    Then I run `touch foo/test.js`
    And I wait for output to contain "Change detected"

But this doesn't seem to work. I think it is because my app runs interactively in that moment so I can't really run a command like touch. Does anybody ever had such a problem and may know a way around it?

Full code is on github: github-link

Every help is much appreciated

Edit: I made a little progress

I created a new step that spawns a childprocess which executes then the touch command. I can clearly see that the touched file is created inside the foo folder but my scenario still fails to see the output.

My step looks like this:

When /^I run "([^"]*)" in a new process$/ do |command|
    @process = ChildProcess.send(:build,*command.split(' '))
    @process.start
    sleep 10
end

And my scenario:

Scenario: jsbreeze should be able to watch multiple folders
    Given a directory named "foo"
    When I run `jsbreeze watchFolder foo,.` interactively
    And I run "touch tmp/aruba/foo/test.js" in a new process
    And I wait for output to contain "Change detected"
Playerwtf
  • 301
  • 1
  • 4
  • 12

0 Answers0