simple_resource 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ 0.2.0 (January 15, 2013)
4
+
5
+ * CanCan support
6
+ * Default locales are in config/locales/en.yml
7
+ * Redirect to collection_url after create and update actions
8
+
3
9
  0.1.0 (October 19, 2012)
4
10
 
5
11
  * First release with basic functionality
@@ -1,4 +1,4 @@
1
- # SimpleResource for Developers
1
+ # Contributing to SimpleResource
2
2
 
3
3
  ## Forking the project
4
4
 
@@ -22,11 +22,11 @@ And then execute:
22
22
 
23
23
  ## Running tests
24
24
 
25
- Start Guard:
26
-
27
- $ bundle exec guard start
28
-
29
- Run all specs by pressing the enter.
25
+ $ cd spec/dummy
26
+ $ rake db:setup
27
+ $ rake db:test:clone
28
+ $ cd ../..
29
+ $ rake spec
30
30
 
31
31
  ## Adding a new feature
32
32
 
data/README.md CHANGED
@@ -12,6 +12,7 @@ SimpleResource speeds up development of standard Rails applications by integrati
12
12
  * Support for external form builders
13
13
  * [Formtastic](https://github.com/justinfrench/formtastic)
14
14
  * [SimpleForm](https://github.com/plataformatec/simple_form)
15
+ * Support for CanCan
15
16
 
16
17
  ## Requirements
17
18
 
@@ -28,6 +29,44 @@ And then execute:
28
29
 
29
30
  $ bundle
30
31
 
32
+ ## Usage
33
+
34
+ Inherit your resource controllers from SimpleResource::BaseController. For example:
35
+
36
+ class ProjectsController < SimpleResource::BaseController
37
+ end
38
+
39
+ That's it. Your resource now uses Formtastic as a form builder, views from SimpleResource and restful actions from Inherited Resources.
40
+
41
+ ### Configuring form builder
42
+
43
+ You can configure which form builders you want to use. Configuration can be done application-wide or per resource.
44
+
45
+ For example, if you like to use simple_form by default for all your resources, configure the builder in the app/views/simple_resource/_form.html.erb:
46
+
47
+ <%= render_form "simple_form" %>
48
+
49
+ If you like to use simple_form only for products resource, put the above line into the app/views/products/_form.html.erb.
50
+
51
+ ### Creating own form builder
52
+
53
+ Put your form builder into the app/views/simple_resource/builders/_my_builder.html.erb:
54
+
55
+ <form>
56
+ <% fields.each do |field| %>
57
+ <%= input_field_tag(field) %>
58
+ <% end %>
59
+ <%= submit_tag "Submit" %>
60
+ </form>
61
+
62
+ Then use it (see section "Configuring form builder"):
63
+
64
+ <%= render_form "my_builder" %>
65
+
66
+ ### Overriding views
67
+
68
+ You may override SimpleResource views application-wide or per resource.
69
+
31
70
  ## Support
32
71
 
33
72
  If you have any questions or issues with SimpleResource, or if you like to report a bug, please create an [issue on GitHub](https://github.com/jarijokinen/simple_resource/issues).
@@ -1,6 +1,22 @@
1
1
  module SimpleResource
2
2
  class BaseController < ::ApplicationController
3
+ if defined?(CanCan)
4
+ load_and_authorize_resource
5
+
6
+ rescue_from CanCan::AccessDenied do |exception|
7
+ redirect_to root_url, alert: exception.message
8
+ end
9
+ end
10
+
3
11
  inherit_resources
4
12
  defaults route_prefix: ""
13
+
14
+ def create
15
+ create! { collection_url }
16
+ end
17
+
18
+ def update
19
+ update! { collection_url }
20
+ end
5
21
  end
6
22
  end
@@ -13,22 +13,24 @@ module SimpleResource
13
13
  end
14
14
 
15
15
  def collection_title
16
- I18n.t("activerecord.models.#{controller_name.singularize}.other",
16
+ t("activerecord.models.#{controller_name.singularize}.other",
17
17
  default: controller_name.humanize)
18
18
  end
19
19
 
20
20
  def new_resource_title
21
- I18n.t("simple_resource.new_resource", resource_name: resource_human_name,
22
- default: "New #{resource_human_name}")
21
+ t("simple_resource.titles.new_resource", resource_name: resource_human_name)
22
+ end
23
+
24
+ def new_resource_link_title
25
+ t("simple_resource.links.new_resource", resource_name: resource_human_name)
23
26
  end
24
27
 
25
28
  def new_resource_link
26
- link_to(new_resource_title, new_resource_path)
29
+ link_to(new_resource_link_title, new_resource_path)
27
30
  end
28
31
 
29
32
  def edit_resource_title
30
- I18n.t("simple_resource.edit_resource", resource_name: resource_human_name,
31
- default: "Edit #{resource_human_name}")
33
+ t("simple_resource.titles.edit_resource", resource_name: resource_human_name)
32
34
  end
33
35
 
34
36
  def resource_attributes
@@ -49,7 +51,7 @@ module SimpleResource
49
51
 
50
52
  def attribute_human_name(attribute_name)
51
53
  attribute_name = attribute_name.to_s
52
- I18n.t("activerecord.attributes.#{controller_name.singularize}.#{attribute_name}",
54
+ t("activerecord.attributes.#{controller_name.singularize}.#{attribute_name}",
53
55
  default: attribute_name.humanize)
54
56
  end
55
57
 
@@ -66,7 +68,7 @@ module SimpleResource
66
68
  action_name = action_name.to_sym
67
69
  if action_name == :delete
68
70
  link_to(t("simple_resource.#{action_name.to_s}", default: title), path,
69
- method: :delete, confirm: t("simple_resource.delete_confirmation", default: "Are you sure?"))
71
+ method: :delete, confirm: t("simple_resource.messages.delete_confirmation"))
70
72
  else
71
73
  link_to(t("simple_resource.#{action_name.to_s}", default: title), path)
72
74
  end
@@ -74,9 +76,9 @@ module SimpleResource
74
76
 
75
77
  def default_actions_for(resource)
76
78
  html = Array.new
77
- html << link_to_action(:show, "Show", resource_path(resource))
78
- html << link_to_action(:edit, "Edit", edit_resource_path(resource))
79
- html << link_to_action(:delete, "Delete", resource_path(resource))
79
+ html << link_to_action(:show, t("simple_resource.links.show"), resource_path(resource))
80
+ html << link_to_action(:edit, t("simple_resource.links.edit"), edit_resource_path(resource))
81
+ html << link_to_action(:delete, t("simple_resource.links.delete"), resource_path(resource))
80
82
  html.join("\n").html_safe
81
83
  end
82
84
 
@@ -1,4 +1,9 @@
1
1
  <% @title ||= collection_title %>
2
2
 
3
- <%= render_collection_table %>
3
+ <%=
4
+ unless collection.blank?
5
+ render_collection_table
6
+ end
7
+ %>
8
+
4
9
  <%= new_resource_link %>
@@ -2,6 +2,6 @@
2
2
  <%= f.inputs(*(fields)) %>
3
3
  <%= f.actions do %>
4
4
  <%= f.action :submit %>
5
- <%= f.action :cancel, label: t(:cancel, default: "Cancel"), url: collection_path %>
5
+ <%= f.action :cancel, label: t("simple_resource.buttons.cancel"), url: collection_path %>
6
6
  <% end %>
7
7
  <% end %>
@@ -0,0 +1,15 @@
1
+ en:
2
+ simple_resource:
3
+ buttons:
4
+ cancel: "Cancel"
5
+ links:
6
+ new_resource: "New %{resource_name}"
7
+ edit_resource: "Edit %{resource_name}"
8
+ show: "Show"
9
+ edit: "Edit"
10
+ delete: "Delete"
11
+ messages:
12
+ delete_confirmation: "Are you sure?"
13
+ titles:
14
+ new_resource: "New %{resource_name}"
15
+ edit_resource: "Edit %{resource_name}"
@@ -1,3 +1,3 @@
1
1
  module SimpleResource
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -16,10 +16,10 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = gem.files.grep(%r{^spec/})
17
17
  gem.require_paths = ["lib"]
18
18
 
19
- gem.add_dependency "rails", "~> 3.2.8"
19
+ gem.add_dependency "rails", "~> 3.2.11"
20
20
  gem.add_dependency "inherited_resources", "~> 1.3.1"
21
21
 
22
- gem.add_development_dependency "capybara"
22
+ gem.add_development_dependency "capybara", "1.1.4"
23
23
  gem.add_development_dependency "database_cleaner"
24
24
  gem.add_development_dependency "factory_girl_rails"
25
25
  gem.add_development_dependency "forgery"
@@ -1,2 +1,4 @@
1
- class Backend::LanguagesController < SimpleResource::BaseController
1
+ module Backend
2
+ class LanguagesController < SimpleResource::BaseController
3
+ end
2
4
  end
@@ -1,4 +1,6 @@
1
1
  class Language < ActiveRecord::Base
2
2
  attr_accessible :name
3
3
  has_many :posts
4
+
5
+ validates_presence_of :name
4
6
  end
@@ -7,6 +7,9 @@
7
7
  <%= csrf_meta_tags %>
8
8
  </head>
9
9
  <body>
10
+ <% flash.each do |key, msg| %>
11
+ <%= content_tag(:div, msg, class: "flash #{key}") %>
12
+ <% end %>
10
13
  <%= content_tag(:h1, @title) unless @title.blank? %>
11
14
  <%= yield %>
12
15
  </body>
@@ -33,7 +33,7 @@ module Dummy
33
33
 
34
34
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
35
35
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
36
- # config.i18n.default_locale = :de
36
+ # config.i18n.default_locale = :fi
37
37
 
38
38
  # Configure the default encoding used in templates for Ruby 1.9.
39
39
  config.encoding = "utf-8"
@@ -8,9 +8,14 @@ fi:
8
8
  language:
9
9
  name: "Nimi"
10
10
  simple_resource:
11
- new_resource: "Uusi %{resource_name}"
12
- edit_resource: "Muokkaa %{resource_name}"
13
- show: "Näytä"
14
- edit: "Muokkaa"
15
- delete: "Poista"
16
- delete_confirmation: "Oletko varma?"
11
+ links:
12
+ new_resource: "Uusi %{resource_name}"
13
+ edit_resource: "Muokkaa %{resource_name}"
14
+ show: "Näytä"
15
+ edit: "Muokkaa"
16
+ delete: "Poista"
17
+ messages:
18
+ delete_confirmation: "Oletko varma?"
19
+ titles:
20
+ new_resource: "Uusi %{resource_name}"
21
+ edit_resource: "Muokkaa %{resource_name}"
@@ -0,0 +1,169 @@
1
+ require "spec_helper"
2
+
3
+ describe "Languages resource" do
4
+ let!(:collection) { FactoryGirl.create_list(:language, 10) }
5
+
6
+ before :each do
7
+ visit "/languages"
8
+ end
9
+
10
+ describe "index" do
11
+ it "has a correct title" do
12
+ page.html.should have_xpath "//title", text: "Languages | Dummy"
13
+ end
14
+
15
+ it "has a correct heading" do
16
+ page.should have_css "h1", text: "Languages"
17
+ end
18
+
19
+ it "lists all languages" do
20
+ within "table" do
21
+ within "thead" do
22
+ page.should have_css "th", text: "Name"
23
+ end
24
+ within "tbody" do
25
+ collection.each do |resource|
26
+ page.should have_css "td", text: resource.name
27
+ page.should have_link "Show", href: "/languages/#{resource.id}"
28
+ page.should have_link "Edit", href: "/languages/#{resource.id}/edit"
29
+ page.should have_link "Delete", href: "/languages/#{resource.id}"
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ it "has a link to create a new language" do
36
+ page.should have_link "New Language", href: "/languages/new"
37
+ end
38
+ end
39
+
40
+ describe "creating a new language" do
41
+ let(:resource) { FactoryGirl.build(:language) }
42
+
43
+ before :each do
44
+ click_link "New Language"
45
+ end
46
+
47
+ it "has a correct title" do
48
+ page.html.should have_xpath "//title", text: "New Language | Dummy"
49
+ end
50
+
51
+ it "has a correct heading" do
52
+ page.should have_css "h1", text: "New Language"
53
+ end
54
+
55
+ it "has a name field" do
56
+ page.should have_field "Name"
57
+ end
58
+
59
+ it "has a create language button" do
60
+ page.should have_button "Create Language"
61
+ end
62
+
63
+ it "has a cancel link" do
64
+ page.should have_link "Cancel", href: "/languages"
65
+ end
66
+
67
+ context "with correct values" do
68
+ before :each do
69
+ fill_in "Name", with: resource.name
70
+ click_button "Create Language"
71
+ end
72
+
73
+ it "redirects to index" do
74
+ page.current_path.should == "/languages"
75
+ end
76
+
77
+ it "displays success message" do
78
+ page.should have_content "Language was successfully created"
79
+ end
80
+
81
+ it "lists the new resource" do
82
+ page.should have_content resource.name
83
+ end
84
+ end
85
+
86
+ context "without a required field" do
87
+ before :each do
88
+ click_button "Create Language"
89
+ end
90
+
91
+ it "stays on the same page" do
92
+ page.should have_css "h1", text: "New Language"
93
+ page.should have_field "Name"
94
+ end
95
+
96
+ it "displays inline error message" do
97
+ page.should have_content "can't be blank"
98
+ end
99
+ end
100
+ end
101
+
102
+ describe "editing a language" do
103
+ let(:resource) { collection.first }
104
+ let(:new_resource) { FactoryGirl.build(:language) }
105
+
106
+ before :each do
107
+ click_link "Edit"
108
+ end
109
+
110
+ it "has a correct title" do
111
+ page.html.should have_xpath "//title", text: "Edit Language | Dummy"
112
+ end
113
+
114
+ it "has a correct heading" do
115
+ page.should have_css "h1", text: "Edit Language"
116
+ end
117
+
118
+ it "has a name field" do
119
+ page.should have_field "Name", with: resource.name
120
+ end
121
+
122
+ it "has a update language button" do
123
+ page.should have_button "Update Language"
124
+ end
125
+
126
+ it "has a cancel link" do
127
+ page.should have_link "Cancel", href: "/languages"
128
+ end
129
+
130
+ context "with correct values" do
131
+ before :each do
132
+ fill_in "Name", with: new_resource.name
133
+ click_button "Update Language"
134
+ end
135
+
136
+ it "redirects to index" do
137
+ page.current_path.should == "/languages"
138
+ end
139
+
140
+ it "displays success message" do
141
+ page.should have_content "Language was successfully updated"
142
+ end
143
+
144
+ it "lists the new resource" do
145
+ page.should have_content new_resource.name
146
+ end
147
+
148
+ it "does not list the old resource" do
149
+ page.should_not have_content resource.name
150
+ end
151
+ end
152
+
153
+ context "without a required field" do
154
+ before :each do
155
+ fill_in "Name", with: ""
156
+ click_button "Update Language"
157
+ end
158
+
159
+ it "stays on the same page" do
160
+ page.should have_css "h1", text: "Edit Language"
161
+ page.should have_field "Name"
162
+ end
163
+
164
+ it "displays inline error message" do
165
+ page.should have_content "can't be blank"
166
+ end
167
+ end
168
+ end
169
+ end
@@ -181,7 +181,7 @@ describe SimpleResource::BaseHelper do
181
181
 
182
182
  it "returns translated show link" do
183
183
  set_locale
184
- helper.link_to_action(:show, "Show", "/languages/1").should eq('<a href="/languages/1">Näytä</a>')
184
+ helper.link_to_action(:show, "Näytä", "/languages/1").should eq('<a href="/languages/1">Näytä</a>')
185
185
  reset_locale
186
186
  end
187
187
  end
@@ -193,7 +193,7 @@ describe SimpleResource::BaseHelper do
193
193
 
194
194
  it "returns translated edit link" do
195
195
  set_locale
196
- helper.link_to_action(:edit, "Edit", "/languages/1/edit").should eq('<a href="/languages/1/edit">Muokkaa</a>')
196
+ helper.link_to_action(:edit, "Muokkaa", "/languages/1/edit").should eq('<a href="/languages/1/edit">Muokkaa</a>')
197
197
  reset_locale
198
198
  end
199
199
  end
@@ -205,7 +205,7 @@ describe SimpleResource::BaseHelper do
205
205
 
206
206
  it "returns translated delete link" do
207
207
  set_locale
208
- helper.link_to_action(:delete, "Delete", "/languages/1").should eq('<a href="/languages/1" data-confirm="Oletko varma?" data-method="delete" rel="nofollow">Poista</a>')
208
+ helper.link_to_action(:delete, "Poista", "/languages/1").should eq('<a href="/languages/1" data-confirm="Oletko varma?" data-method="delete" rel="nofollow">Poista</a>')
209
209
  reset_locale
210
210
  end
211
211
  end
@@ -369,8 +369,8 @@ describe SimpleResource::BaseHelper do
369
369
  </div>
370
370
  <fieldset class="inputs">
371
371
  <ol>
372
- <li class="string input optional stringish" id="language_name_input">
373
- <label class=" label" for="language_name">Name</label>
372
+ <li class="string input required stringish" id="language_name_input">
373
+ <label class=" label" for="language_name">Name<abbr title="required">*</abbr></label>
374
374
  <input id="language_name" maxlength="255" name="language[name]" type="text" />
375
375
  </li>
376
376
  </ol>
@@ -411,8 +411,8 @@ describe SimpleResource::BaseHelper do
411
411
  </div>
412
412
  <fieldset class="inputs">
413
413
  <ol>
414
- <li class="string input optional stringish" id="language_name_input">
415
- <label class=" label" for="language_name">Name</label>
414
+ <li class="string input required stringish" id="language_name_input">
415
+ <label class=" label" for="language_name">Name<abbr title="required">*</abbr></label>
416
416
  <input id="language_name" maxlength="255" name="language[name]" type="text"
417
417
  value="#{language.name}" />
418
418
  </li>
data/spec/spec_helper.rb CHANGED
@@ -37,5 +37,6 @@ end
37
37
 
38
38
  Spork.each_run do
39
39
  require "factory_girl_rails"
40
+ ActiveSupport::Dependencies.clear
40
41
  FactoryGirl.reload
41
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-18 00:00:00.000000000 Z
12
+ date: 2013-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 3.2.8
21
+ version: 3.2.11
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 3.2.8
29
+ version: 3.2.11
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: inherited_resources
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -48,17 +48,17 @@ dependencies:
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - '='
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: 1.1.4
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 1.1.4
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: database_cleaner
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -231,9 +231,8 @@ files:
231
231
  - .rspec
232
232
  - .travis.yml
233
233
  - CHANGELOG.md
234
- - DEVELOPER_GUIDE.md
234
+ - CONTRIBUTING.md
235
235
  - Gemfile
236
- - Guardfile
237
236
  - LICENSE.txt
238
237
  - README.md
239
238
  - Rakefile
@@ -248,6 +247,7 @@ files:
248
247
  - app/views/simple_resource/base/show.html.erb
249
248
  - app/views/simple_resource/builders/_formtastic.html.erb
250
249
  - app/views/simple_resource/builders/_simple_form.html.erb
250
+ - config/locales/en.yml
251
251
  - lib/simple_resource.rb
252
252
  - lib/simple_resource/engine.rb
253
253
  - lib/simple_resource/version.rb
@@ -298,8 +298,8 @@ files:
298
298
  - spec/factories/categories.rb
299
299
  - spec/factories/languages.rb
300
300
  - spec/factories/posts.rb
301
+ - spec/features/languages_spec.rb
301
302
  - spec/helpers/base_helper_spec.rb
302
- - spec/integration/languages_spec.rb
303
303
  - spec/spec_helper.rb
304
304
  - spec/support/helpers.rb
305
305
  homepage: https://github.com/jarijokinen/simple_resource
@@ -314,12 +314,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
314
314
  - - ! '>='
315
315
  - !ruby/object:Gem::Version
316
316
  version: '0'
317
+ segments:
318
+ - 0
319
+ hash: 1479618243370591090
317
320
  required_rubygems_version: !ruby/object:Gem::Requirement
318
321
  none: false
319
322
  requirements:
320
323
  - - ! '>='
321
324
  - !ruby/object:Gem::Version
322
325
  version: '0'
326
+ segments:
327
+ - 0
328
+ hash: 1479618243370591090
323
329
  requirements: []
324
330
  rubyforge_project:
325
331
  rubygems_version: 1.8.24
@@ -372,8 +378,7 @@ test_files:
372
378
  - spec/factories/categories.rb
373
379
  - spec/factories/languages.rb
374
380
  - spec/factories/posts.rb
381
+ - spec/features/languages_spec.rb
375
382
  - spec/helpers/base_helper_spec.rb
376
- - spec/integration/languages_spec.rb
377
383
  - spec/spec_helper.rb
378
384
  - spec/support/helpers.rb
379
- has_rdoc:
data/Guardfile DELETED
@@ -1,30 +0,0 @@
1
- guard "spork", rspec_env: { "RAILS_ENV" => "test" } do
2
- watch("config/application.rb")
3
- watch("config/environment.rb")
4
- watch("config/environments/test.rb")
5
- watch(%r{^config/initializers/.+\.rb$})
6
- watch("Gemfile")
7
- watch("Gemfile.lock")
8
- watch("spec/spec_helper.rb") { :rspec }
9
- end
10
-
11
- guard "rspec", cli: "--drb --color", all_on_start: false, all_after_pass: false do
12
- watch(%r{^spec/.+_spec\.rb$})
13
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
14
- watch("spec/spec_helper.rb") { "spec" }
15
-
16
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
17
- watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
18
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
19
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
20
- watch("config/routes.rb") { "spec/routing" }
21
- watch("app/controllers/application_controller.rb") { "spec/controllers" }
22
-
23
- # Capybara request specs
24
- watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
25
-
26
- # Turnip features and steps
27
- watch(%r{^spec/acceptance/(.+)\.feature$})
28
- watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance" }
29
- end
30
-
@@ -1,39 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Languages" do
4
- describe "#index" do
5
- let!(:collection) { FactoryGirl.create_list(:language, 10) }
6
-
7
- before :each do
8
- visit "/languages"
9
- end
10
-
11
- it "has a correct title" do
12
- page.should have_xpath "//title", text: "Languages | Dummy"
13
- end
14
-
15
- it "has a correct heading" do
16
- page.should have_css "h1", "Languages"
17
- end
18
-
19
- it "lists all languages" do
20
- within "table" do
21
- within "thead" do
22
- page.should have_css "th", text: "Name"
23
- end
24
- within "tbody" do
25
- collection.each do |resource|
26
- page.should have_css "td", text: resource.name
27
- page.should have_link "Show", href: "/languages/#{resource.id}"
28
- page.should have_link "Edit", href: "/languages/#{resource.id}/edit"
29
- page.should have_link "Delete", href: "/languages/#{resource.id}"
30
- end
31
- end
32
- end
33
- end
34
-
35
- it "has a link to create a new language" do
36
- page.should have_link "New Language", href: "/languages/new"
37
- end
38
- end
39
- end