From a57d0ea90d32ab29508f1395ca0db72a8d164814 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Fri, 17 Jul 2015 04:19:25 +0800 Subject: [PATCH] Update --- awscli.md | 61 ++++++++++++++++++++++++++++++++++++ capybara.md | 11 +++++++ eslint.md | 17 +++++++++++ expectjs.md | 28 ++++++++++++----- metalsmith.md | 21 +++++++++++++ mocha-html.md | 21 ++++++++----- rspec.md | 45 ++++++--------------------- saucelabs.md | 38 +++++++++++++++++++++++ slim.md | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 277 insertions(+), 50 deletions(-) create mode 100644 awscli.md create mode 100644 eslint.md create mode 100644 metalsmith.md create mode 100644 saucelabs.md create mode 100644 slim.md diff --git a/awscli.md b/awscli.md new file mode 100644 index 000000000..46e9ae114 --- /dev/null +++ b/awscli.md @@ -0,0 +1,61 @@ +--- +title: AWS CLI +--- + +### EC2 + +``` +aws ec2 describe-instances +aws ec2 start-instances --instance-ids i-12345678c +``` + +### S3 + +``` +aws s3 ls s3://mybucket +aws s3 cp myfolder s3://mybucket/folder --recursive +aws s3 sync myfolder s3://mybucket/folder --exclude *.tmp +``` + +### ECS + +``` +aws ecs create-cluster + --cluster-name=NAME + --generate-cli-skeleton + +aws ecs create-service +``` + +### Homebrew + +``` +brew install awscli +aws configure +``` + +## Elastic Beanstalk + +### Configuration + +* .elasticbeanstalk/config.yml - application config +* .elasticbeanstalk/dev-env.env.yml - environment config + +``` +eb config +``` + +See: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options.html + +## ebextensions + +* see +* see + +---- + +See: + +* [AWS CLI](https://aws.amazon.com/cli/) +* [Documentation](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) +* [All commands](http://docs.aws.amazon.com/cli/latest/reference/#available-services) diff --git a/capybara.md b/capybara.md index f42da30df..5a9c5ff2b 100644 --- a/capybara.md +++ b/capybara.md @@ -148,5 +148,16 @@ expect(page).to have_unchecked_field expect(page).to have_xpath ``` +## Page object + +```rb +page.status_code == 200 +page.response_headers +``` + + - + +## See also + - - diff --git a/eslint.md b/eslint.md new file mode 100644 index 000000000..cafc880b6 --- /dev/null +++ b/eslint.md @@ -0,0 +1,17 @@ +--- +title: eslint +--- + +```js +// "comma-dangle": "always" ("always-multiline", "never") +var foo = { + bar: "baz", + qux: "quux", +}; +var arr = [1,2,]; +``` + +``` +// "yoda": "always" ("never") +if ("red" === color) +``` diff --git a/expectjs.md b/expectjs.md index 7fa2c41f0..2e2ee6467 100644 --- a/expectjs.md +++ b/expectjs.md @@ -7,23 +7,37 @@ expect(x).toBe(y) .toBe(val) .toEqual(val) .toThrow(err) - .toExist + .toExist /* aka: toBeTruthy */ + .toNotExist /* aka: toBeFalsy */ .toBeA(constructor) .toBeA('string') .toMatch(/expr/) .toBeLessThan(n) .toBeGreaterThan(n) - .toInclude(val) + .toInclude(val) /* aka: toContain */ .toExclude(val) + +/* also: toNotBe, toNotEqual, etc */ ``` +### Spies + ```js spy = expect.spyOn(video, 'play') -expect(spy.calls.length).toEqual(1); -expect(spy.calls[0].context).toBe(video); -expect(spy.calls[0].arguments).toEqual([ 'some', 'args' ]); -expect(spy).toHaveBeenCalled(); -expect(spy).toHaveBeenCalledWith('some', 'args'); + +spy = expect.spyOn(...) + .andCallThrough() /* pass through */ + .andCall(fn) + .andThrow(exception) + .andReturn(value) + +expect(spy.calls.length).toEqual(1) +expect(spy.calls[0].context).toBe(video) +expect(spy.calls[0].arguments).toEqual([ 'some', 'args' ]) +expect(spy.getLastCall().arguments).toEqual(...) + +expect(spy).toHaveBeenCalled() +expect(spy).toHaveBeenCalledWith('some', 'args') ``` https://www.npmjs.com/package/expect diff --git a/metalsmith.md b/metalsmith.md new file mode 100644 index 000000000..aa1fb8f8d --- /dev/null +++ b/metalsmith.md @@ -0,0 +1,21 @@ +--- +title: Metalsmith +--- + +### [metalsmith-templates](https://www.npmjs.com/package/metalsmith-templates) + +```js +"plugins": { + "metalsmith-templates": { + "engine": "swig", + "directory": "_layouts" + } +} +``` + +Use `{{ contents }}` to bring it out + +Engines: + + * swig (like liquid) + diff --git a/mocha-html.md b/mocha-html.md index 3b7a4f96a..f1c56fbf7 100644 --- a/mocha-html.md +++ b/mocha-html.md @@ -8,17 +8,22 @@ This is a mocha template that loads js/css from cdn. + Mocha - - - + + -
- - - +
+ + + + + + + + + diff --git a/rspec.md b/rspec.md index c79fed22b..030e5edba 100644 --- a/rspec.md +++ b/rspec.md @@ -97,45 +97,20 @@ expect { thing.approve! }.to change(thing, :status). expect { thing.destroy }.to change(Thing, :count).by(-1) ``` -### Mocking - basic +### Double - book.stub(:title) { "The RSpec Book" } - book.stub(:title => "The RSpec Book") - book.stub(:title).and_return("The RSpec Book") +```rb +book = double('book') +book = instance_double('Book', pages: 250) +``` - # First arg is a name, it's optional - book = double("book", :title => "The RSpec Book") +### Method stubs -### Mocking - consecutive return values +```rb +allow(die).to receive(:roll) { 3 } +``` - die.stub(:roll).and_return(1,2,3) - die.roll # => 1 - die.roll # => 2 - die.roll # => 3 - die.roll # => 3 - die.roll # => 3 - -### Expectations - - expect(double).to receive(:msg) - expect(double).to receive(:msg).with(no_args()) - expect(double).to receive(:msg).with(any_args()) - expect(double).to receive(:msg).with(1, kind_of(Numeric), "b") #2nd argument can any kind of Numeric - expect(double).to receive(:msg).with(1, boolean(), "b") #2nd argument can true or false - expect(double).to receive(:msg).with(1, /abc/, "b") #2nd argument can be any String matching the submitted Regexp - expect(double).to receive(:msg).with(1, anything(), "b") #2nd argument can be anything at all - expect(double).to receive(:msg).with(1, ducktype(:abs, :div), "b") #2nd argument can be object that responds to #abs and #div - - expect(double).to receive(:msg).once - expect(double).to receive(:msg).twice - expect(double).to receive(:msg).exactly(n).times - expect(double).to receive(:msg).at_least(:once) - expect(double).to receive(:msg).at_least(:twice) - expect(double).to receive(:msg).at_least(n).times - expect(double).to receive(:msg).at_most(:once) - expect(double).to receive(:msg).at_most(:twice) - expect(double).to receive(:msg).at_most(n).times - expect(double).to receive(:msg).any_number_of_times +https://relishapp.com/rspec/rspec-mocks/docs ## Subjects diff --git a/saucelabs.md b/saucelabs.md new file mode 100644 index 000000000..3a093ad1f --- /dev/null +++ b/saucelabs.md @@ -0,0 +1,38 @@ +Sign up for opensauce + +- http://saucelabs.com/opensauce + +Install zuul + +``` +npm i -g zuul +``` + +Configure zuul + +```yml +# ~/.zuulrc +sauce_username: me +sauce_key: abc12348-e3e2-... +``` + +Add .zuul.yml to your project + +```yml +# .zuul.yml +ui: mocha-bdd +browsers: + - name: chrome + version: latest + - name: ie + version: 6..latest + - name: firefox + version: latest +``` + +Try to run tests + +``` +zuul test/test.js +zuul --local test/test.js +``` diff --git a/slim.md b/slim.md new file mode 100644 index 000000000..fd5e1e4b2 --- /dev/null +++ b/slim.md @@ -0,0 +1,85 @@ +--- +title: Slim +--- + +```slim +doctype html +html + head + title Slim Examples + meta[charset='utf-8'] + meta(name="keywords" content="template language") + meta name="author" content=author + meta property='og:image' content=asset_url('foo.png') + meta property='og:image' content=(path_to_user user) + meta( + property='description' + content='this is the song that never ends') +``` + +### Ruby attributes + +```slim +a class=[:menu,:highlight] +.card *{'data-url' => place_path(place)} +``` + +### Inline ruby + +```slim +ruby: + def foobar + "hello" + end + +div= foobar +``` + +### Embedded js + +```slim +javascript: + alert('Slim supports embedded javascript!') +``` + +### Comments + +```slim +/ Comment +/! HTML comment +``` + +### Ruby + +```slim +== yield += t('.hello') +- 3.times do |i| + div +``` + +### Verbatim text + +```slim +div + | This is text + it is nice +``` + +### Inline HTML + +```slim +
+ - if articles.empty? + | Nothing here +
+``` + +### Inline tags + +```slim +ul + li: a(href='/') Home +``` + +