Add fouc helpers
This commit is contained in:
parent
906eab0a59
commit
b4da084e72
|
@ -1,5 +1,5 @@
|
|||
<!doctype html>
|
||||
<html lang='en' class='{{ page.html_class }}'>
|
||||
<html lang='en' class='no-js {{ page.html_class }}'>
|
||||
<head>
|
||||
{% include meta.html %}
|
||||
<link href="http://ricostacruz.com/til/assets/style.css?t={{ site.time | date: "%Y%m%d%H%M%S" }}" rel="stylesheet" />
|
||||
|
|
|
@ -89,3 +89,6 @@
|
|||
<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'>
|
||||
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
|
||||
<link href='{{ base }}/assets/favicon.png' rel='shortcut icon'>
|
||||
|
||||
{%comment%}<!-- fouc -->{%endcomment%}
|
||||
<script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
|
||||
|
|
|
@ -139,8 +139,8 @@ Validation
|
|||
|
||||
validates :name, length: { minimum: 2 }
|
||||
validates :bio, length: { maximum: 500 }
|
||||
validates :password, length: { in => 6..20 }
|
||||
validates :number, length: { is => 6 }
|
||||
validates :password, length: { in: => 6..20 }
|
||||
validates :number, length: { is: => 6 }
|
||||
|
||||
validates :gender, inclusion: %w(male female)
|
||||
validates :gender, inclusion: { in: %w(male female) }
|
||||
|
@ -148,6 +148,9 @@ Validation
|
|||
|
||||
validates :points, numericality: true
|
||||
validates :played, numericality: { only_integer: true }
|
||||
# ... greater_than, greater_than_or_equal_to,
|
||||
# ... less_than, less_than_or_equal_to
|
||||
# ... odd, even, equal_to
|
||||
|
||||
# Validate the associated records to ensure they're valid as well
|
||||
has_many :books
|
||||
|
|
71
rspec.md
71
rspec.md
|
@ -51,60 +51,63 @@ layout: default
|
|||
it "should do this" do
|
||||
pending "some other thing"
|
||||
|
||||
subject.name = 'x'
|
||||
subject.name.should == 'x'
|
||||
expect(subject.name).to eq 'x'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
### Expectations
|
||||
|
||||
# Can be:
|
||||
# target.should
|
||||
# target.should_not
|
||||
# expect(target).to
|
||||
```rb
|
||||
target.should eq 1
|
||||
target.should_not eq 1
|
||||
expect(target).to eq 1
|
||||
expect(target).not_to eq 1
|
||||
```
|
||||
|
||||
# Numeric
|
||||
be < 6
|
||||
== 5
|
||||
equal value
|
||||
be_between(1, 10)
|
||||
be_close value, tolerance
|
||||
```rb
|
||||
# Numeric
|
||||
be < 6
|
||||
== 5
|
||||
equal value
|
||||
be_between(1, 10)
|
||||
be_close value, tolerance
|
||||
|
||||
be value
|
||||
satisfy {|arg| ...}
|
||||
predicate [optional args]
|
||||
match regexp
|
||||
be value
|
||||
satisfy {|arg| ...}
|
||||
predicate [optional args]
|
||||
match regexp
|
||||
|
||||
be_an_instance_of <class>
|
||||
be_a_kind_of <class>
|
||||
be_an_instance_of <class>
|
||||
be_a_kind_of <class>
|
||||
|
||||
respond_to <symbol>
|
||||
respond_to <symbol>
|
||||
|
||||
# Control flow
|
||||
raise_error
|
||||
raise_error(<exception> [, message])
|
||||
# Control flow
|
||||
raise_error
|
||||
raise_error(<exception> [, message])
|
||||
|
||||
throw <symbol>
|
||||
throw <symbol>
|
||||
|
||||
# Enumerables/arrays
|
||||
include <object>
|
||||
# Enumerables/arrays
|
||||
include <object>
|
||||
|
||||
have(<number>).things
|
||||
have_at_least(<number>).things
|
||||
have_at_most(<number>).things
|
||||
have(<number>).things
|
||||
have_at_least(<number>).things
|
||||
have_at_most(<number>).things
|
||||
|
||||
have(<number>).errors_on(:field)
|
||||
have(<number>).errors_on(:field)
|
||||
|
||||
# Change
|
||||
change(instance, method).from(number).to(number)
|
||||
# Change
|
||||
change(instance, method).from(number).to(number)
|
||||
|
||||
# proc.should <=> expect(&proc).to
|
||||
expect { thing.approve! }.to change(thing, :status).
|
||||
# proc.should <=> expect(&proc).to
|
||||
expect { thing.approve! }.to change(thing, :status).
|
||||
from(Status::AWAITING_APPROVAL).
|
||||
to(Status::APPROVED)
|
||||
|
||||
expect { thing.destroy }.to change(Thing, :count).by(-1)
|
||||
expect { thing.destroy }.to change(Thing, :count).by(-1)
|
||||
```
|
||||
|
||||
### Mocking - basic
|
||||
|
||||
|
|
Loading…
Reference in New Issue