Index.
This commit is contained in:
parent
1f4d969077
commit
070e89ffd5
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -21,6 +21,12 @@ layout: default
|
||||||
|
|
||||||
f.object
|
f.object
|
||||||
|
|
||||||
|
### Fields for
|
||||||
|
|
||||||
|
= form_for @post do |f|
|
||||||
|
= fields_for :author, @post.author do |ff|
|
||||||
|
= ff.text_field :name
|
||||||
|
|
||||||
### Fields
|
### Fields
|
||||||
|
|
||||||
f.check_box :is_admin
|
f.check_box :is_admin
|
||||||
|
@ -32,7 +38,7 @@ layout: default
|
||||||
f.label :post, :title, "Title"
|
f.label :post, :title, "Title"
|
||||||
f.label :post, :title, "Title", class: "title"
|
f.label :post, :title, "Title", class: "title"
|
||||||
f.label(:post, :terms) { "Accept terms" }
|
f.label(:post, :terms) { "Accept terms" }
|
||||||
#=> <label for="post_title">Title</label>
|
#=> <label for="post_title">Title</labele>
|
||||||
|
|
||||||
radio_button("post", "category", "rails")
|
radio_button("post", "category", "rails")
|
||||||
radio_button("post", "category", "java")
|
radio_button("post", "category", "java")
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
title: Rspec-rails controllers
|
||||||
|
layout: default
|
||||||
|
---
|
||||||
|
|
||||||
|
```rb
|
||||||
|
expect(response).to be_success
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(response).to render_template("index")
|
82
rspec.md
82
rspec.md
|
@ -59,42 +59,45 @@ layout: default
|
||||||
|
|
||||||
### Expectations
|
### Expectations
|
||||||
|
|
||||||
# Can be .should or .should_not
|
# Can be:
|
||||||
|
# target.should
|
||||||
|
# target.should_not
|
||||||
|
# expect(target).to
|
||||||
|
|
||||||
# Numeric
|
# Numeric
|
||||||
target.should be < 6
|
be < 6
|
||||||
target.should == 5
|
== 5
|
||||||
target.should equal value
|
equal value
|
||||||
target.should be_between(1, 10)
|
be_between(1, 10)
|
||||||
target.should be_close value, tolerance
|
be_close value, tolerance
|
||||||
|
|
||||||
target.should be value
|
be value
|
||||||
target.should satisfy {|arg| ...}
|
satisfy {|arg| ...}
|
||||||
target.should predicate [optional args]
|
predicate [optional args]
|
||||||
target.should match regexp
|
match regexp
|
||||||
|
|
||||||
target.should be_an_instance_of <class>
|
be_an_instance_of <class>
|
||||||
target.should be_a_kind_of <class>
|
be_a_kind_of <class>
|
||||||
|
|
||||||
target.should respond_to <symbol>
|
respond_to <symbol>
|
||||||
|
|
||||||
# Control flow
|
# Control flow
|
||||||
proc.should raise_error
|
raise_error
|
||||||
proc.should raise_error(<exception> [, message])
|
raise_error(<exception> [, message])
|
||||||
|
|
||||||
proc.should throw <symbol>
|
throw <symbol>
|
||||||
|
|
||||||
# Enumerables/arrays
|
# Enumerables/arrays
|
||||||
target.should include <object>
|
include <object>
|
||||||
|
|
||||||
target.should have(<number>).things
|
have(<number>).things
|
||||||
target.should have_at_least(<number>).things
|
have_at_least(<number>).things
|
||||||
target.should have_at_most(<number>).things
|
have_at_most(<number>).things
|
||||||
|
|
||||||
target.should have(<number>).errors_on(:field)
|
have(<number>).errors_on(:field)
|
||||||
|
|
||||||
# Change
|
# Change
|
||||||
proc.should change(instance, method).from(number).to(number)
|
change(instance, method).from(number).to(number)
|
||||||
|
|
||||||
# proc.should <=> expect(&proc).to
|
# proc.should <=> expect(&proc).to
|
||||||
expect { thing.approve! }.to change(thing, :status).
|
expect { thing.approve! }.to change(thing, :status).
|
||||||
|
@ -123,22 +126,23 @@ layout: default
|
||||||
|
|
||||||
### Expectations
|
### Expectations
|
||||||
|
|
||||||
double.should_receive(:msg).with(no_args())
|
expect(double).to receive(:msg)
|
||||||
double.should_receive(:msg).with(any_args())
|
expect(double).to receive(:msg).with(no_args())
|
||||||
double.should_receive(:msg).with(1, kind_of(Numeric), "b") #2nd argument can any kind of Numeric
|
expect(double).to receive(:msg).with(any_args())
|
||||||
double.should_receive(:msg).with(1, boolean(), "b") #2nd argument can true or false
|
expect(double).to receive(:msg).with(1, kind_of(Numeric), "b") #2nd argument can any kind of Numeric
|
||||||
double.should_receive(:msg).with(1, /abc/, "b") #2nd argument can be any String matching the submitted Regexp
|
expect(double).to receive(:msg).with(1, boolean(), "b") #2nd argument can true or false
|
||||||
double.should_receive(:msg).with(1, anything(), "b") #2nd argument can be anything at all
|
expect(double).to receive(:msg).with(1, /abc/, "b") #2nd argument can be any String matching the submitted Regexp
|
||||||
double.should_receive(:msg).with(1, ducktype(:abs, :div), "b") #2nd argument can be object that responds to #abs and #div
|
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
|
||||||
|
|
||||||
double.should_receive(:msg).once
|
expect(double).to receive(:msg).once
|
||||||
double.should_receive(:msg).twice
|
expect(double).to receive(:msg).twice
|
||||||
double.should_receive(:msg).exactly(n).times
|
expect(double).to receive(:msg).exactly(n).times
|
||||||
double.should_receive(:msg).at_least(:once)
|
expect(double).to receive(:msg).at_least(:once)
|
||||||
double.should_receive(:msg).at_least(:twice)
|
expect(double).to receive(:msg).at_least(:twice)
|
||||||
double.should_receive(:msg).at_least(n).times
|
expect(double).to receive(:msg).at_least(n).times
|
||||||
double.should_receive(:msg).at_most(:once)
|
expect(double).to receive(:msg).at_most(:once)
|
||||||
double.should_receive(:msg).at_most(:twice)
|
expect(double).to receive(:msg).at_most(:twice)
|
||||||
double.should_receive(:msg).at_most(n).times
|
expect(double).to receive(:msg).at_most(n).times
|
||||||
double.should_receive(:msg).any_number_of_times
|
expect(double).to receive(:msg).any_number_of_times
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,14 @@ layout: default
|
||||||
|
|
||||||
* [Sinon-chai](https://github.com/domenic/sinon-chai)
|
* [Sinon-chai](https://github.com/domenic/sinon-chai)
|
||||||
|
|
||||||
|
|
||||||
|
### Initialization
|
||||||
|
|
||||||
|
```js
|
||||||
|
var sinon = require('sinon');
|
||||||
|
require('chai').use(require('sinon-chai'));
|
||||||
|
```
|
||||||
|
|
||||||
### Assert
|
### Assert
|
||||||
|
|
||||||
expect(spy).called
|
expect(spy).called
|
||||||
|
|
Loading…
Reference in New Issue