This gist shows how to test events on Backbone views using Mocha, Chai, Sinon, and Require.js. The directory structure of the project being referenced, based on that of the Canto front end, can be found in my earlier gist about a related testing topic.
This file contains 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
source 'https://rubygems.org' | |
gem 'bundler', '~> 1.5.2' | |
gem 'rake', '~> 10.3.2' | |
gem 'certificate_authority', '~> 0.1.6' |
This file contains 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
This gist is an offshoot of the one by Michael Cox at https://gist.github.com/michaelcox/3800736. | |
I had been looking for a testing solution for a long time, and his code didn't quite work for me, | |
so I thought I'd share what finally did. | |
In all the files I'm showing here, there are additional lines of code that are omitted for brevity. | |
If you'd like to see the whole thing in action, you can find it at | |
`https://github.com/danascheider/canto`. | |
Relevant parts of my directory structure looked like this. The ./js/lib/chai and | |
./js/lib/mocha directories are the same directories that show up in your node_modules |
This file contains 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 this gist I'll show how I solved the problem of testing the visibility of elements using Capybara/Cucumber integration tests. The tests are being run against a locally-hosted site and do not have access to its internals, so I'm leaving the internals out here. Do note that the app itself is written in JavaScript, with only the integration tests being Ruby. The relevant file structure looks like this: | |
├── features/ | |
| ├── step_definitions/ | |
| | ├── canto_steps.rb | |
| ├── support/ | |
| | ├── env.rb | |
| | ├── wait_for_ajax.rb | |
| ├── dashboard_home.feature |
I had to search everywhere to find a decent sorted array of all 50 states that I could copy and paste into my code. The result was that I had to spend a stupid amount of time copying the damned things myself. Hopefully this can spare others the trouble. Most of the languages I can think of will work with an array in this format with minimal modifications that should be possible using a decent find-and-replace. I hope this saves some other unfortunate developer the headache.
This file contains 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
--format documentation | |
--color | |
--require spec_helper |
This file contains 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
source "https://rubygems.org" | |
ruby "2.4.0" | |
gem "cucumber", "3.1.0" | |
gem "watir" | |
gem "webdrivers" | |
gem "byebug" |
This file contains 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
class File < ApplicationRecord | |
has_one_attached :file | |
end |
This file contains 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
class File < ApplicationRecord | |
has_one_attached :file | |
scope :without_attached_file, -> { left_joins(:file_attachment).where('active_storage_attachments.id IS NULL') } | |
end |
This file contains 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
On branch master | |
No commits yet | |
Untracked files: | |
(use "git add <file>..." to include in what will be committed) | |
hello_world.rb | |
nothing added to commit but untracked files present (use "git add" to track) |
OlderNewer