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> <!doctype html>
<html lang='en' class='{{ page.html_class }}'> <html lang='en' class='no-js {{ page.html_class }}'>
<head> <head>
{% include meta.html %} {% include meta.html %}
<link href="http://ricostacruz.com/til/assets/style.css?t={{ site.time | date: "%Y%m%d%H%M%S" }}" rel="stylesheet" /> <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='IE=edge,chrome=1' http-equiv='X-UA-Compatible'>
<meta content='width=device-width, initial-scale=1.0' name='viewport'> <meta content='width=device-width, initial-scale=1.0' name='viewport'>
<link href='{{ base }}/assets/favicon.png' rel='shortcut icon'> <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 :name, length: { minimum: 2 }
validates :bio, length: { maximum: 500 } validates :bio, length: { maximum: 500 }
validates :password, length: { in => 6..20 } validates :password, length: { in: => 6..20 }
validates :number, length: { is => 6 } validates :number, length: { is: => 6 }
validates :gender, inclusion: %w(male female) validates :gender, inclusion: %w(male female)
validates :gender, inclusion: { in: %w(male female) } validates :gender, inclusion: { in: %w(male female) }
@ -148,6 +148,9 @@ Validation
validates :points, numericality: true validates :points, numericality: true
validates :played, numericality: { only_integer: 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 # Validate the associated records to ensure they're valid as well
has_many :books has_many :books

View File

@ -51,19 +51,21 @@ layout: default
it "should do this" do it "should do this" do
pending "some other thing" pending "some other thing"
subject.name = 'x' expect(subject.name).to eq 'x'
subject.name.should == 'x'
end end
end end
end end
### Expectations ### Expectations
# Can be: ```rb
# target.should target.should eq 1
# target.should_not target.should_not eq 1
# expect(target).to expect(target).to eq 1
expect(target).not_to eq 1
```
```rb
# Numeric # Numeric
be < 6 be < 6
== 5 == 5
@ -105,6 +107,7 @@ layout: default
to(Status::APPROVED) to(Status::APPROVED)
expect { thing.destroy }.to change(Thing, :count).by(-1) expect { thing.destroy }.to change(Thing, :count).by(-1)
```
### Mocking - basic ### Mocking - basic