Sha256: 9b8fb02c935729f8ce2ac6984c9475ea4f40f7941f7c9205ad5852e1d05bc14a

Contents?: true

Size: 1.52 KB

Versions: 21

Compression:

Stored size: 1.52 KB

Contents

#
# Where to go
#
steps_for(:ra_navigation) do
  #
  # GET
  # Go to a given page.
  When "$actor goes to $path" do |actor, path|
    case path
    when 'the home page' then get '/'
    else                      get path
    end
  end

  # POST -- Ex:
  #   When she creates a book with ISBN: '0967539854' and comment: 'I love this book' and rating: '4'
  #   When she creates a singular session with login: 'reggie' and password: 'i_haxxor_joo'
  # Since I'm not smrt enough to do it right, explicitly specify singular resources
  When %r{$actor creates an? $resource with $attributes} do |actor, resource, attributes|
    attributes = attributes.to_hash_from_story
    if resource =~ %r{singular ([\w/]+)}
      resource = $1.downcase.singularize
      post "/#{resource}", attributes
    else
      post "/#{resource.downcase.pluralize}", { resource.downcase.singularize => attributes }
    end
  end

  # PUT
  When %r{$actor asks to update '$resource' with $attributes} do |_, resource, attributes|
    attributes = attributes.to_hash_from_story
    put "#{resource}", attributes
    dump_response
  end

  # DELETE -- Slap together the POST-form-as-fake-HTTP-DELETE submission
  When %r{$actor asks to delete '$resource'} do |_, resource|
    post "/#{resource.downcase.pluralize}", { :_method => :delete }
    dump_response
  end


  # Redirect --
  #   Rather than coding in get/get_via_redirect's and past/p_v_r's,
  #   let's just demand that in the story itself.
  When "$actor follows that redirect!" do |actor|
    follow_redirect!
  end
end

Version data entries

21 entries across 21 versions & 5 rubygems

Version Path
caleb-restful-authentication-1.1.1 generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
dwaite-restful-authentication-1.1.1 generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
ggoodale-restful-authentication-1.1.1 generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
simonmenke-mr_authentication-0.0.1 vendor/plugins/restful-authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-3.0.3 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-3.0.2 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-3.0.1 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-3.0.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-2.0.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-2.1.2 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-2.2.1 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-2.1.1 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-2.1.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-2.2.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-2.4.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-2.3.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-2.2.2 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-2.5.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-2.5.2 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
tournament-2.6.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb