Add fouc helpers

This commit is contained in:
Rico Sta. Cruz 2015-03-26 16:41:23 +08:00
parent 906eab0a59
commit b4da084e72
4 changed files with 48 additions and 39 deletions

View File

@ -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" />

View File

@ -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>

View File

@ -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

View File

@ -51,19 +51,21 @@ 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
```
```rb
# Numeric
be < 6
== 5
@ -105,6 +107,7 @@ layout: default
to(Status::APPROVED)
expect { thing.destroy }.to change(Thing, :count).by(-1)
```
### Mocking - basic