From e9859a904e59d26c3483eeb96de8ab76a55adb0b Mon Sep 17 00:00:00 2001 From: Ariejan de Vroom Date: Wed, 16 Apr 2014 10:04:33 +0200 Subject: [PATCH] Add new posts and GPG page --- content/gpg.haml | 58 ++++++++-------- .../2014-04-04-dealing-with-technical-debt.md | 1 - ...15-testing-home-with-cucumber-and-aruba.md | 69 +++++++++++++++++++ 3 files changed, 99 insertions(+), 29 deletions(-) create mode 100644 content/posts/2014-04-15-testing-home-with-cucumber-and-aruba.md diff --git a/content/gpg.haml b/content/gpg.haml index c4da1c2..f80af61 100644 --- a/content/gpg.haml +++ b/content/gpg.haml @@ -9,37 +9,39 @@ title: GPG Public Key ## Proof of identity As far as you can trust this website, this is a proof of my identity. - -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 - - Yes, I use GPG. This message is here to prove my identity to you. - + + My name is Ariejan de Vroom and I use GPG. + + My public key information is: + ID: 0xF713697B + Fingerprint: 8450 D928 4373 164E 25CC 7E0D AD73 9154 F713 697B -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) Comment: GPGTools - https://gpgtools.org - - iQQcBAEBCgAGBQJTPUABAAoJEK1zkVT3E2l7CyEf/iFXQ+hl8As1oNpHoNKLnIie - wpyWBbhOj0YAuxoYA1fmFn3IASq3+st+VZEX82M3FedBLXozxFdFRE6OzLIKlx5i - ulbTtjq9gpiPcTO6n9P8hAdn672LAc0Hgo2CDZLg+SGkeseMzrFE5Pki9j7PHUP8 - 3SEk7j/iPQumfoJtPKRqzsnamViFonHorJGY9pso7hHPIaQlw7hQARkU5/OkADKM - BjlfqTxcgId9da9Y+yro3MnVWtAR8j1GWZDF90t/xipOQ9Bdj86jPiF16HEtM539 - VPOsayxry24gEmVMsk4cERgysxUIp2js2v/ETL0udxk+7mP2EILVtUipYGR3jSYJ - 2ByhPag9LgbqSttXzyrFs3aGl/mp65xZhOuWE/RJexcSa+opB2lQX1YEY3FmgTua - cL13rALwd4oa4WSh6nSXl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+ Sk6IK32/9Qn2PXiyeTMdE8NOfj52WKVD3rFaMPsjU/XeqA/nWKoJCbISQ3yp0c8J + D62HQpKhxRRcRuesVRhbFdyK+1ssLQ5ZUcx7kKPzLn2amBQzG80XNZbjb24CbY2X + CXRh3R0DoSuAnDbYefT9p1ZXiLYMamMkX2UQYavrW3rWh2oA4oJwoTbqJrWtSvjg + wXNyc35IivZxfZHegHUmtfEuVX/cFTRLpoIUOWEpZpVLC6pjVfRznVapExr8X5o= + =1VS2 -----END PGP SIGNATURE----- diff --git a/content/posts/2014-04-04-dealing-with-technical-debt.md b/content/posts/2014-04-04-dealing-with-technical-debt.md index 0cf9142..5172c25 100644 --- a/content/posts/2014-04-04-dealing-with-technical-debt.md +++ b/content/posts/2014-04-04-dealing-with-technical-debt.md @@ -2,7 +2,6 @@ title: "Dealing With Technical Debt" created_at: 2014-04-04 12:38:41 +0200 kind: article -published: false tags: - programming - craftsmanship diff --git a/content/posts/2014-04-15-testing-home-with-cucumber-and-aruba.md b/content/posts/2014-04-15-testing-home-with-cucumber-and-aruba.md new file mode 100644 index 0000000..e2f8041 --- /dev/null +++ b/content/posts/2014-04-15-testing-home-with-cucumber-and-aruba.md @@ -0,0 +1,69 @@ +--- +title: "Testing $HOME with Cucumber and Aruba" +created_at: 2014-04-15 21:42:43 +0200 +kind: article +published: true +tags: + - programming + - cucumber + - aruba +summary: | + Cucumber and Aruba make it awesome to write acceptance tests for your + command line programs. But how do you test your program interacting with + files from a user's $HOME directory? +--- +[Cucumber][1] and [Aruba][2] are awesome tools to write acceptance tests for your command line application. The allow you to do things like this: + +``` +:::gherkin +Scenario: Exit with 0 when no examples are run + Given a file named "a_no_examples_spec.rb" with: + """ruby + """ + When I run `rspec a_no_examples_spec.rb` + Then the exit status should be 0 + And the output should contain "0 examples" +``` +_This example was taken rspec-core._ + +Aruba basically does three things for you: + + * Create and inspect files and directories + * Run commands + * Inspect output and exit status + +## The problem + +Now, if you are writing a CLI that interacts with a configuration file in the user's home directory, you'd write a cucumber like this: + +``` +:::gherkin +Scenario: use .my-app configuration + Given a file named "~/.my-app" with: + """ + awesome_enabled: true + """ + When I run `my-app` + Then the output should contain "AWESOME" +``` + +But how does your app and Aruba differentiate between this generated test file and your actual configration file in your home directory? It doens't. + +## The answer + +The solution is quite easy and elegant, in your `Before` set the `$HOME` environment variable to a custom location inside the `tmp/aruba` directory. + +In `features/support/env.rb`: + +``` +:::ruby +Before do + set_env 'HOME', File.expand_path(File.join(current_dir, 'home')) + FileUtils.mkdir_p ENV['HOME'] +end +``` + +This will set `$HOME` to `tmp/aruba/home` in the context of your cucumbers (and execute binary). `current_dir` automatically points to the right location for the aruba temporary directory. + +[1]: https://github.com/cucumber/cucumber +[2]: https://github.com/cucumber/aruba