🧛♂️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rspec/core/rake_task' | |
| namespace :stubs do | |
| namespace :schedule do | |
| pid_file_path = "lib/stubs/schedule.pid" | |
| desc "Start the schedule stub" | |
| task :start do | |
| `rackup -D lib/stubs/schedule.ru -P #{pid_file_path} -p 2000` | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #in env.rb: | |
| require 'active_support/time' | |
| Time.zone = 'Europe/London' | |
| #use in tests instead of `Time.now`: | |
| Time.current #=> will output the time in London, regardless of the localhost's timezone |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| To list all tags scattered across your feature files... | |
| 1) add the following "list_tags.rb" file to your features/support directory | |
| 2) cucumber -d -f Cucumber::Formatter::ListTags |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| visit LoginPage do |page| | |
| page.login_with('foo', 'badpass') | |
| page.text.should include "Login error" | |
| page.text.should include "Secure your account" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NOTE: I've created a gem based on this: https://github.com/natritmeyer/yarjuf | |
| --------- | |
| rspec my_spec.rb -r ./junit.rb -f JUnit -o results.xml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #you probably only need one of these, but here's the lot of them... | |
| #prepare the commands that will bring the various browsers to the front | |
| bring_chrome_to_front = %Q{ osascript -e "tell application \\\"Google Chrome\\\" to activate" } | |
| bring_firefox_to_front = %Q{ osascript -e "tell application \\\"Firefox\\\" to activate" } | |
| #execute the applescript commands to bring the browsers to the front | |
| `#{bring_chrome_to_front}` | |
| `#{bring_firefox_to_front}` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require './tinytest' | |
| class MyTests < TinyTest | |
| def setup | |
| @name = "Bob" | |
| end | |
| def teardown | |
| @name = "" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module AjaxWaiter | |
| def wait_for_ajax | |
| wait_until { page.evaluate_script("jQuery.active") == 0 } | |
| end | |
| end | |
| World(AjaxWaiter) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Before do |scenario| | |
| p scenario.source_tag_names #=> ["@complete", "@slow"] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sl() { | |
| /usr/bin/mdfind -onlyin \. $@ | |
| } | |
| #usage: | |
| # sl Search for this phrase |