Skip to content

Instantly share code, notes, and snippets.

Chris Roos chrisroos

Block or report user

Report or block chrisroos

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chrisroos
chrisroos / test-output.txt
Created Apr 29, 2015
The tests that fail in smart-answers when I run with seed 56021
View test-output.txt
Chriss-MacBook-Air-2:~/Code/alphagov/smart-answers$ rake test TESTOPTS="--seed=56021"
* DEFERRED: sequence of two questions a question raises an error should permit custom error messages per question.
Run options: --seed=56021
# Running:
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
@chrisroos
chrisroos / README.md
Last active Aug 29, 2015
Smart Answer test failures caused by lack of Internet connection
View README.md

I disabled my Internet connection and ran the tests in the Smart Answers project to see how many relied on being able to make connections to the outside world.

@chrisroos
chrisroos / README.md
Last active Aug 29, 2015
Comparing Smart Answer test output with and without memoized state
View README.md

The current test set-up requires the use of contexts to move through the Smart Answer. We can avoid this by removing the memoization of @state in FlowTestHelper. I temporarily removed it and ran the tests to see how much longer they took and whether we'd have any failures.

def current_state
  # @state ||= begin
    @flow.process(@responses)
  # end
end
@chrisroos
chrisroos / Gemfile
Created May 1, 2015
Nokogiri nth-child problems with LibXML 2.9
View Gemfile
source 'https://rubygems.org'
gem 'nokogiri', '1.5.11'
gem 'test-unit'
@chrisroos
chrisroos / README.md
Last active Aug 29, 2015
Exploring how to act on files that have changed in a directory
View README.md

I've been using [FileWatcher][] to perform actions on new/changed files. I ran into problems where FileWatcher invokes the block before the file has finished copying and my code then fails.

My script runs using launchd so I considered investigating the WatchPaths launchd.plist directive. The man page for that directive says not to use it because of the some of the problems I've been having with FileWatcher.

Use of this key is highly discouraged, as filesystem event monitoring is highly race-prone, and it is entirely possible for modifications to be missed. When modifications are caught, there is no guarantee that the file will be in a consistent state when the job is launched.

The scripts in this gist are investigations into alternative approaches to only acting on files that have been created/changed.

In 'storing-a-hash-of-files.rb' I also compared the performance of Ruby's Digest::MD5 to the system md5 but there didn't seem to be any difference. The system md5 required me to use Shellwords t

@chrisroos
chrisroos / README.md
Created May 5, 2015
Illustration of the problem of precalculation blocks not being evaluated in the first question
View README.md

Demonstration of the problem of precalculate blocks not being evaluated in the first question of a Smart Answer.

Assuming the flow lives in "lib/smart_answer_flows/" and the test lives in "test/integration/smart_answer_flows/", you can run the test with bundle exec ruby test/integration/smart_answer_flows/example_flow_test.rb.

Note the absence of "Q1 - precalculate" in output.txt.

@chrisroos
chrisroos / README.md
Last active Aug 29, 2015
Comparison of Smart Answer visualisation, using next_node_if and next_node with permitted_next_nodes
View README.md

Comparison of the visualisation of two Smart Answers: one using next_node_if and one using a combination of next_node and permitted_next_nodes.

The Smart Answer using next_node_if can be visualised correctly while the one using next_node and permitted_next_nodes cannot. See the attached screenshots for both visualisations.

@chrisroos
chrisroos / Gemfile
Last active Aug 29, 2015
Investigating the problem with shoulda tests being "hidden" by duplicate contexts
View Gemfile
source 'https://rubygems.org'
gem 'minitest'
gem 'shoulda'
@chrisroos
chrisroos / README.md
Last active Aug 29, 2015
Trying to avoid problems caused by duplicate context names in Smart Answers
View README.md

We've seen problems in Smart Answers where duplicate context names result in some tests not running.

This script tries to rename all contexts to give them unique names in order to highlight "hidden" tests.

@chrisroos
chrisroos / Gemfile
Created May 14, 2015
Exploring Minitest's parallelize_me! option
View Gemfile
source 'https://rubygems.org'
gem 'minitest'
You can’t perform that action at this time.