File tree 3 files changed +75
-0
lines changed
3 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 250
250
* Use ` Set ` , not ` Array ` , for arrays with unique elements. The lookup is faster.
251
251
* Use single-quotes for strings unless interpolating.
252
252
253
+ [ Sample] ( https://github.com/thoughtbot/style-guide/blob/master/ruby-sample.rb )
254
+
253
255
Rails
254
256
-----
255
257
@@ -370,6 +372,8 @@ Testing
370
372
* Use one expectation per ` it ` block.
371
373
* Use [ stubs and spies] ( http://goo.gl/EciDJ ) (not mocks) in isolated tests.
372
374
375
+ [ Sample] ( https://github.com/thoughtbot/style-guide/blob/master/rspec-sample.rb )
376
+
373
377
Browsers
374
378
--------
375
379
Original file line number Diff line number Diff line change
1
+ describe SomeClass do
2
+ it "does something for #some_method" do
3
+ end
4
+
5
+ context "#other_method" do
6
+ it "does something in one case" do
7
+ end
8
+
9
+ it "does something else in other cases" do
10
+ end
11
+
12
+ # methods go here
13
+ end
14
+ end
Original file line number Diff line number Diff line change
1
+ class SomeClass
2
+ SOME_CONSTANT = 'upper case name'
3
+
4
+ def initialize ( attributes )
5
+ @some_attribute = attributes [ :some_attribute ]
6
+ @another_attribute = attributes [ :another_attribute ]
7
+ end
8
+
9
+ def method_with_arguments ( argument_one , argument_two )
10
+ this_is_a_really_line_that_should_be_broken_up_over_multiple_lines_and .
11
+ every_line_but_the_first_is_indented
12
+ end
13
+
14
+ def method_with_multiline_block
15
+ items . each do |item |
16
+ do_something_with_item
17
+ end
18
+ end
19
+
20
+ def method_with_single_line_block
21
+ items . map { |item | item . some_attribute }
22
+ end
23
+
24
+ def method_that_returns_an_array
25
+ [ item_one , item_two ]
26
+ end
27
+
28
+ def method_that_returns_a_hash
29
+ { :key => 'value' }
30
+ end
31
+
32
+ def method_that_uses_infix_operators
33
+ left + middle - right
34
+ end
35
+
36
+ def method_without_arguments
37
+ method_start
38
+
39
+ if complex_condition?
40
+ positive_branch
41
+ else
42
+ negative_branch
43
+ end
44
+
45
+ rest_of_body
46
+ end
47
+
48
+ def self . class_method
49
+ method_body
50
+ end
51
+
52
+ private
53
+
54
+ def complex_condition?
55
+ part_one? && part_two?
56
+ end
57
+ end
You can’t perform that action at this time.
0 commit comments