faithfulgeek (owner)

Revisions

gist: 178252 Download_button fork
public
Public Clone URL: git://gist.github.com/178252.git
Embed All Files: show embed
CleRBwiki/features/document.feature #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Feature: Wiki Documents
  In order to manage wiki content
  As a user
  I want see, create and edit wiki documents
 
  #
  Scenario: View document page
    Given there is a document titled "TestDocument"
    When I visit the "TestDocument" document page
    Then I should see "TestDocument"
 
  #
  Scenario: Create a document without correct information
    Given I am on the new document page
    When I press "Add Page"
    Then I should see "Title can't be blank"
    And I should see "Document body can't be blank"
 
  #
  Scenario: Create a document
    Given I am on the new document page
    When I fill in the following:
      | 'Title' | 'MyDocument' |
      | 'Body' | 'Here is some content.' |
    When I press "Add Page"
    Then I should be on /documents/MyDocument
    And I should see "MyDocument"
    And I should see "Document successfully added"
CleRBwiki/features/step_definitions/document_steps.rb #
1
2
3
4
5
6
7
Given /^there is a document titled "([^\"]*)"$/ do |title|
  Document.create!(:title => title, :body => 'Some content.')
end
 
When /^I visit the "([^\"]*)" document page$/ do |title|
  visit "/documents/#{title}"
end
CleRBwiki/features/support/paths.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module NavigationHelpers
  # Maps a name to a path. Used by the
  #
  # When /^I go to (.+)$/ do |page_name|
  #
  # step definition in webrat_steps.rb
  #
  def path_to(page_name)
    case page_name
    
    when /the homepage/
      '/'
    
    # Add more mappings here.
    # Here is a more fancy example:
    #
    # when /^(.*)'s profile page$/i
    # user_profile_path(User.find_by_login($1))
 
    ### ADD THIS FOR CleRBwiki!
    when /the new document page/
      '/documents/new'
    ### END ADD THIS
 
    else
      raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
        "Now, go and add a mapping in #{__FILE__}"
    end
  end
end
 
World(NavigationHelpers)