Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Delete helpers, add featers, delete views spec, add gems.

  • Loading branch information...
commit e732c9e92bc69759b97720f9f8bbda843b48499a 1 parent 5c197b1
Lisovsky Vlad authored June 17, 2012
1  .gitignore
@@ -11,3 +11,4 @@
11 11
 /log/*.log
12 12
 /tmp
13 13
 keys.rb
  14
+.rspec
2  .rspec
... ...
@@ -1 +1 @@
1  
---colour
  1
+--colour --format documentation
29  Gemfile
@@ -9,31 +9,36 @@ group :assets do
9 9
   gem 'uglifier', '>= 1.0.3'
10 10
   gem 'twitter-bootstrap-rails'
11 11
 end
  12
+gem 'jquery-rails'
  13
+
  14
+gem 'omniauth-twitter'
12 15
 
13 16
 gem 'mongoid'
14 17
 gem 'bson_ext'
15 18
 
16  
-gem 'jquery-rails'
17 19
 
18 20
 gem 'haml'
19  
-gem 'haml-rails', :group => :development
20 21
 gem 'simple_form'
21 22
 
22  
-
23  
-gem 'thin'
24  
-gem 'quiet_assets', :group => :development
25  
-
26  
-gem 'rspec-rails', :group => [:test, :development]
27  
-
28 23
 group :development do
  24
+  gem 'rails3-generators', :git => 'https://github.com/neocoin/rails3-generators.git'
  25
+  gem 'quiet_assets'
  26
+  gem 'thin'
  27
+  gem 'haml-rails'
  28
+  
  29
+  gem 'pry-rails'
  30
+end
  31
+
  32
+group :development, :test do
  33
+  gem 'rspec-rails'
29 34
   gem 'factory_girl_rails'
30  
-  gem "rails3-generators", :git => "https://github.com/neocoin/rails3-generators.git"
  35
+  gem 'mongoid-rspec'
31 36
 end
32 37
 
33 38
 group :test do
34  
-  gem 'database_cleaner'
35 39
   gem 'cucumber-rails', :require => false
36 40
   gem 'capybara'
  41
+  gem 'faker'
  42
+  gem 'launchy'
  43
+  gem 'guard-rspec'
37 44
 end
38  
-
39  
-gem 'omniauth-twitter'
38  Gemfile.lock
@@ -50,6 +50,7 @@ GEM
50 50
       xpath (~> 0.1.4)
51 51
     childprocess (0.3.2)
52 52
       ffi (~> 1.0.6)
  53
+    coderay (1.0.6)
53 54
     coffee-rails (3.2.2)
54 55
       coffee-script (>= 2.2.0)
55 56
       railties (~> 3.2.0)
@@ -68,7 +69,6 @@ GEM
68 69
       cucumber (>= 1.1.8)
69 70
       nokogiri (>= 1.5.0)
70 71
     daemons (1.1.8)
71  
-    database_cleaner (0.8.0)
72 72
     diff-lcs (1.1.3)
73 73
     erubis (2.7.0)
74 74
     eventmachine (0.12.10)
@@ -79,9 +79,16 @@ GEM
79 79
     factory_girl_rails (3.4.0)
80 80
       factory_girl (~> 3.4.0)
81 81
       railties (>= 3.0.0)
  82
+    faker (1.0.1)
  83
+      i18n (~> 0.4)
82 84
     ffi (1.0.11)
83 85
     gherkin (2.11.0)
84 86
       json (>= 1.4.6)
  87
+    guard (1.1.1)
  88
+      listen (>= 0.4.2)
  89
+      thor (>= 0.14.6)
  90
+    guard-rspec (1.0.1)
  91
+      guard (>= 1.1)
85 92
     haml (3.1.6)
86 93
     haml-rails (0.3.4)
87 94
       actionpack (~> 3.0)
@@ -96,6 +103,8 @@ GEM
96 103
       railties (>= 3.2.0, < 5.0)
97 104
       thor (~> 0.14)
98 105
     json (1.7.3)
  106
+    launchy (2.1.0)
  107
+      addressable (~> 2.2.6)
99 108
     less (2.2.1)
100 109
       commonjs (~> 0.2.6)
101 110
     less-rails (2.2.3)
@@ -104,10 +113,15 @@ GEM
104 113
     libv8 (3.3.10.4)
105 114
     libwebsocket (0.1.3)
106 115
       addressable
  116
+    listen (0.4.5)
  117
+      rb-fchange (~> 0.0.5)
  118
+      rb-fsevent (~> 0.9.1)
  119
+      rb-inotify (~> 0.8.8)
107 120
     mail (2.4.4)
108 121
       i18n (>= 0.4.0)
109 122
       mime-types (~> 1.16)
110 123
       treetop (~> 1.4.8)
  124
+    method_source (0.7.1)
111 125
     mime-types (1.18)
112 126
     mongo (1.6.2)
113 127
       bson (~> 1.6.2)
@@ -115,6 +129,10 @@ GEM
115 129
       activemodel (~> 3.1)
116 130
       mongo (<= 1.6.2)
117 131
       tzinfo (~> 0.3.22)
  132
+    mongoid-rspec (1.4.5)
  133
+      mongoid (>= 2.4.6)
  134
+      rake
  135
+      rspec (>= 2.9)
118 136
     multi_json (1.3.6)
119 137
     nokogiri (1.5.4)
120 138
     oauth (0.4.6)
@@ -128,6 +146,12 @@ GEM
128 146
       multi_json (~> 1.3)
129 147
       omniauth-oauth (~> 1.0)
130 148
     polyglot (0.3.3)
  149
+    pry (0.9.9.6)
  150
+      coderay (~> 1.0.5)
  151
+      method_source (~> 0.7.1)
  152
+      slop (>= 2.4.4, < 3)
  153
+    pry-rails (0.1.6)
  154
+      pry
131 155
     quiet_assets (1.0.1)
132 156
       railties (~> 3.1)
133 157
     rack (1.4.1)
@@ -153,6 +177,11 @@ GEM
153 177
       rdoc (~> 3.4)
154 178
       thor (>= 0.14.6, < 2.0)
155 179
     rake (0.9.2.2)
  180
+    rb-fchange (0.0.5)
  181
+      ffi
  182
+    rb-fsevent (0.9.1)
  183
+    rb-inotify (0.8.8)
  184
+      ffi (>= 0.5.0)
156 185
     rdoc (3.12)
157 186
       json (~> 1.4)
158 187
     rspec (2.10.0)
@@ -183,6 +212,7 @@ GEM
183 212
     simple_form (2.0.2)
184 213
       actionpack (~> 3.0)
185 214
       activemodel (~> 3.0)
  215
+    slop (2.4.4)
186 216
     sprockets (2.1.3)
187 217
       hike (~> 1.2)
188 218
       rack (~> 1.0)
@@ -218,13 +248,17 @@ DEPENDENCIES
218 248
   capybara
219 249
   coffee-rails (~> 3.2.1)
220 250
   cucumber-rails
221  
-  database_cleaner
222 251
   factory_girl_rails
  252
+  faker
  253
+  guard-rspec
223 254
   haml
224 255
   haml-rails
225 256
   jquery-rails
  257
+  launchy
226 258
   mongoid
  259
+  mongoid-rspec
227 260
   omniauth-twitter
  261
+  pry-rails
228 262
   quiet_assets
229 263
   rails (= 3.2.6)
230 264
   rails3-generators!
2  app/helpers/application_helper.rb
... ...
@@ -1,2 +0,0 @@
1  
-module ApplicationHelper
2  
-end
2  app/helpers/posts_helper.rb
... ...
@@ -1,2 +0,0 @@
1  
-module PostsHelper
2  
-end
4  app/models/post.rb
... ...
@@ -1,5 +1,5 @@
1 1
 class Post
2 2
   include Mongoid::Document
3  
-  field :title, :type => String
4  
-  field :content, :type => String
  3
+  field :title, type: String
  4
+  field :content, type: String
5 5
 end
13  config/application.rb
@@ -70,9 +70,18 @@ class Application < Rails::Application
70 70
     config.sass.preferred_syntax = :sass
71 71
 
72 72
     config.generators do |g|
  73
+      g.helper false
  74
+
  75
+      g.test_framework :rspec,
  76
+        fixtures: true,
  77
+        view_specs: false,
  78
+        helper_specs: false,
  79
+        routing_specs: false,
  80
+        controller_specs: true,
  81
+        request_specs: true
  82
+      g.fixture_replacement :factory_girl, dir: "spec/factories"
  83
+
73 84
       g.template_engine :haml
74  
-      g.test_framework :rspec, :fixture => true, :views => false
75  
-      g.fixture_replacement :factory_girl, :dir => 'spec/factories'
76 85
       g.form_builder :simple_form
77 86
       g.orm :mongoid
78 87
     end
23  features/support/env.rb
... ...
@@ -0,0 +1,23 @@
  1
+# env.rb
  2
+
  3
+ENV["RAILS_ENV"] ||= "test"
  4
+require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
  5
+
  6
+require 'cucumber/formatter/unicode'
  7
+require 'cucumber/rails/rspec'
  8
+require 'cucumber/rails/world'
  9
+require 'cucumber/web/tableish'
  10
+
  11
+require 'capybara/rails'
  12
+require 'capybara/cucumber'
  13
+require 'capybara/session'
  14
+require 'cucumber/rails/capybara_javascript_emulation'
  15
+
  16
+Capybara.default_selector = :css
  17
+
  18
+ActionController::Base.allow_rescue = false
  19
+
  20
+require 'factory_girl'
  21
+require 'factory_girl/step_definitions'
  22
+Dir[File.expand_path(File.join(File.dirname(__FILE__),'..','..', 'spec','factories','*.rb'))].each {|f| require f}
  23
+  
5  features/support/hooks.rb
... ...
@@ -0,0 +1,5 @@
  1
+# features/support/hooks.rb
  2
+
  3
+Before do |scenario|
  4
+    Mongoid.master.collections.select {|c| c.name !~ /system/ }.each(&:drop)
  5
+end
6  spec/controllers/posts_controller_spec.rb
@@ -36,9 +36,9 @@ def valid_session
36 36
 
37 37
   describe "GET index" do
38 38
     it "assigns all posts as @posts" do
39  
-      post = Post.create! valid_attributes
40  
-      get :index, {}, valid_session
41  
-      assigns(:posts).should eq([post])
  39
+      post = FactoryGirl.create(:post)
  40
+      get :index
  41
+      assigns(:posts).to_a.should eq([post])
42 42
     end
43 43
   end
44 44
 
6  spec/factories/posts.rb
... ...
@@ -1,8 +1,10 @@
1 1
 # Read about factories at https://github.com/thoughtbot/factory_girl
2 2
 
  3
+require 'faker'
  4
+
3 5
 FactoryGirl.define do
4 6
   factory :post do
5  
-    title "MyString"
6  
-    content "MyString"
  7
+    title 'Title'
  8
+    content { Faker::Lorem::paragraph 10 }
7 9
   end
8 10
 end
15  spec/helpers/posts_helper_spec.rb
... ...
@@ -1,15 +0,0 @@
1  
-require 'spec_helper'
2  
-
3  
-# Specs in this file have access to a helper object that includes
4  
-# the PostsHelper. For example:
5  
-#
6  
-# describe PostsHelper do
7  
-#   describe "string concat" do
8  
-#     it "concats two strings with spaces" do
9  
-#       helper.concat_strings("this","that").should == "this that"
10  
-#     end
11  
-#   end
12  
-# end
13  
-describe PostsHelper do
14  
-  pending "add some examples to (or delete) #{__FILE__}"
15  
-end
26  spec/spec_helper.rb
... ...
@@ -1,25 +1,19 @@
1 1
 # This file is copied to spec/ when you run 'rails generate rspec:install'
2  
-ENV["RAILS_ENV"] ||= 'test'
3  
-require File.expand_path("../../config/environment", __FILE__)
  2
+ENV['RAILS_ENV'] ||= 'test'
  3
+require File.expand_path('../../config/environment', __FILE__)
4 4
 require 'rspec/rails'
5 5
 require 'rspec/autorun'
  6
+require 'capybara/rspec'
  7
+require 'factory_girl'
6 8
 
7 9
 # Requires supporting ruby files with custom matchers and macros, etc,
8 10
 # in spec/support/ and its subdirectories.
9  
-Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
  11
+Dir[Rails.root.join('spec/support/**/*.rb')].each {|f| require f}
10 12
 
11 13
 RSpec.configure do |config|
12  
-  # ## Mock Framework
13  
-  #
14  
-  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
15  
-  #
16  
-  # config.mock_with :mocha
17  
-  # config.mock_with :flexmock
18  
-  # config.mock_with :rr
19  
-
20  
-
21  
-  # If true, the base class of anonymous controllers will be inferred
22  
-  # automatically. This will be the default behavior in future versions of
23  
-  # rspec-rails.
24  
-  config.infer_base_class_for_anonymous_controllers = false
  14
+  config.mock_with :rspec
  15
+  config.include Mongoid::Matchers
  16
+  config.before :each do
  17
+    Mongoid.master.collections.select {|c| c.name !~ /system/ }.each(&:drop)
  18
+  end
25 19
 end
20  spec/views/posts/edit.html.haml_spec.rb
... ...
@@ -1,20 +0,0 @@
1  
-require 'spec_helper'
2  
-
3  
-describe "posts/edit" do
4  
-  before(:each) do
5  
-    @post = assign(:post, stub_model(Post,
6  
-      :title => "MyString",
7  
-      :content => "MyString"
8  
-    ))
9  
-  end
10  
-
11  
-  it "renders the edit post form" do
12  
-    render
13  
-
14  
-    # Run the generator again with the --webrat flag if you want to use webrat matchers
15  
-    assert_select "form", :action => posts_path(@post), :method => "post" do
16  
-      assert_select "input#post_title", :name => "post[title]"
17  
-      assert_select "input#post_content", :name => "post[content]"
18  
-    end
19  
-  end
20  
-end
23  spec/views/posts/index.html.haml_spec.rb
... ...
@@ -1,23 +0,0 @@
1  
-require 'spec_helper'
2  
-
3  
-describe "posts/index" do
4  
-  before(:each) do
5  
-    assign(:posts, [
6  
-      stub_model(Post,
7  
-        :title => "Title",
8  
-        :content => "Content"
9  
-      ),
10  
-      stub_model(Post,
11  
-        :title => "Title",
12  
-        :content => "Content"
13  
-      )
14  
-    ])
15  
-  end
16  
-
17  
-  it "renders a list of posts" do
18  
-    render
19  
-    # Run the generator again with the --webrat flag if you want to use webrat matchers
20  
-    assert_select "tr>td", :text => "Title".to_s, :count => 2
21  
-    assert_select "tr>td", :text => "Content".to_s, :count => 2
22  
-  end
23  
-end
20  spec/views/posts/new.html.haml_spec.rb
... ...
@@ -1,20 +0,0 @@
1  
-require 'spec_helper'
2  
-
3  
-describe "posts/new" do
4  
-  before(:each) do
5  
-    assign(:post, stub_model(Post,
6  
-      :title => "MyString",
7  
-      :content => "MyString"
8  
-    ).as_new_record)
9  
-  end
10  
-
11  
-  it "renders new post form" do
12  
-    render
13  
-
14  
-    # Run the generator again with the --webrat flag if you want to use webrat matchers
15  
-    assert_select "form", :action => posts_path, :method => "post" do
16  
-      assert_select "input#post_title", :name => "post[title]"
17  
-      assert_select "input#post_content", :name => "post[content]"
18  
-    end
19  
-  end
20  
-end
17  spec/views/posts/show.html.haml_spec.rb
... ...
@@ -1,17 +0,0 @@
1  
-require 'spec_helper'
2  
-
3  
-describe "posts/show" do
4  
-  before(:each) do
5  
-    @post = assign(:post, stub_model(Post,
6  
-      :title => "Title",
7  
-      :content => "Content"
8  
-    ))
9  
-  end
10  
-
11  
-  it "renders attributes in <p>" do
12  
-    render
13  
-    # Run the generator again with the --webrat flag if you want to use webrat matchers
14  
-    rendered.should match(/Title/)
15  
-    rendered.should match(/Content/)
16  
-  end
17  
-end

0 notes on commit e732c9e

Please sign in to comment.
Something went wrong with that request. Please try again.