Skip to content
Browse files

refactoring cucumber

  • Loading branch information...
1 parent d8d6a53 commit 27d3f3f64301492c199e7fdda7b37010fcfe30a7 @Draiken committed Apr 18, 2012
View
14 README.rdoc
@@ -30,15 +30,16 @@ The most common way to quickly get Opinio working is:
rails g opinio:install comment
This will generate the *Comment* model, migration and also generate the opinio initializer for customization of the engine.
-A `opinio_model` will be added on the `routes.rb`. This method adds the default urls for the model that will acts as the comment
+A +opinio_model+ will be added on the +routes.rb+. This method adds the default urls for the model that will act as the comment
+in your app.
-In order to add the comments functionallity to a model, you use the *opinio_subjectum* method
+In order to add the comments functionality to a model, you use the *opinio_subjectum* method
class Post < ActiveRecord::Base
opinio_subjectum
end
-On the `routes.rb` you should simply add an `opinio` for your resource that will have comments
+On the +routes.rb+ you should simply add an +opinio+ for your resource that will have comments
resources :posts do
opinio
@@ -56,12 +57,12 @@ Alternatively you can render just the comments or just the form like this:
<%= render_comments_form @post %>
If you need to render the comments with a specific page or limit
-you can use Kaminari's configurations like `paginates_per 10` on your comment model
+you can use Kaminari's configurations like +paginates_per 10+ on your comment model
or you can customize it for specific views on the helpers
<%= render_comments @post, :page => params[:page], :limit => 5 %>
-This can also be used on the `comments_for` helper.
+This can also be used on the +comments_for+ helper.
== Customization
@@ -142,8 +143,7 @@ For issues please use the github {issues tracker}[https://github.com/Draiken/opi
=== TODO
- * Haml views
* Better controller overriding (coding and documentation)
* Support for deeper levels of replies
- * Refactor the `comments_for` helper
+ * Refactor the +comments_for+ helper
* Extract documentation to wiki
View
2 app/controllers/opinio/comments_controller.rb
@@ -21,7 +21,7 @@ def create
format.js
format.html do
set_flash(flash_area, message)
- redirect_to(resource)
+ redirect_to(resource.is_a?(Opinio.model_name.constantize) ? resource.commentable : resource)
end
end
end
View
7 features/have_replies.feature
@@ -6,7 +6,6 @@ Feature: Have replies
@javascript
Scenario: Reply comment
Given I visit a page with comments
- When I follow "Reply" within "#comments li:first-child"
- And I fill in "Comment" with "Your comment is useless"
- And press "Send Comment"
- Then I should see "Your comment is useless" within ".replies"
+ When I choose to reply a comment
+ And I send the reply
+ Then I should see my reply
View
11 features/step_definitions/comment_steps.rb
@@ -16,10 +16,7 @@
When /^I send a comment$/ do
@message = "I love to comment"
- within "#new_comment" do
- fill_in "comment_body", :with => @message
- click_button "Add comment"
- end
+ send_comment(@message)
end
Then /^I should see the comment I've sent$/ do
@@ -28,3 +25,9 @@
end
end
+def send_comment(message)
+ within "#new_comment" do
+ fill_in "comment_body", :with => message
+ click_button "Add comment"
+ end
+end
View
2 features/step_definitions/remove_comment_steps.rb
@@ -15,7 +15,7 @@
When /^I remove that comment$/ do
within("#comment_#{@comment.id}") do
- click_link 'Destroy'
+ click_link 'Delete'
end
end
View
16 features/step_definitions/reply_steps.rb
@@ -0,0 +1,16 @@
+When /^I choose to reply a comment$/ do
+ within "#comments li:first-child" do
+ page.click_link "Reply"
+ end
+end
+
+When /^I send the reply$/ do
+ @message = "This is a reply"
+ send_comment(@message)
+end
+
+Then /^I should see my reply$/ do
+ within '.replies' do
+ page.should have_content(@message)
+ end
+end
View
1 spec/dummy/config/environments/development.rb
@@ -11,7 +11,6 @@
# Show full error reports and disable caching
config.consider_all_requests_local = true
- config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send

0 comments on commit 27d3f3f

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