Skip to content

Instantly share code, notes, and snippets.

@dlongmuir
Last active October 4, 2015 07:48
Show Gist options
  • Save dlongmuir/2604155 to your computer and use it in GitHub Desktop.
Save dlongmuir/2604155 to your computer and use it in GitHub Desktop.
Networking steps for cucumber
Around('@no_connection_to_qaserver') do |scenario, block|
%x[sudo ipfw add 10 deny tcp from qaserver to me]
%x[sudo ipfw add 11 deny tcp from me to qaserver]
block.call
%x[sudo ipfw delete 11 > /dev/null 2>&1]
%x[sudo ipfw delete 10 > /dev/null 2>&1]
end
Around('@no_network') do |scenario, block|
%x[sudo ifconfig en1 down]
block.call
%x[sudo ifconfig en1 up]
sleep 5
end
# Can also do slow, delayed, dropping packets. See the ipfw docs
# sudo ipfw add pipe 1 ip from any to servername
# sudo ipfw pipe 1 config delay 200ms bw 100Kbit/s plr 0.2
@no_connection_to_qaserver
Scenario: System Unavailable
When I login
Then I should see the system is unavailable message
@slow
@no_network
Scenario: Network error
When I login
Then I should see a network error message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment