Created
September 15, 2013 12:01
-
-
Save mskyle/6570174 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
feature "User creates an issue", %q{ | |
As a user | |
I want to create an issue | |
So that I can track the progress of the issue | |
} do | |
# Acceptance Criteria: | |
# * I must provide a title | |
# * I must provide description | |
# * I can mark the issue as reproducible | |
# * I can specify the category of the issue | |
# * I must select a category for the issue | |
# * I can categorize an issue as either "Bug", "Feature Request", or "Customer Service" | |
# * I can rate the severity of the `Issue` as either "High", "Moderate" or "Low" | |
# * I must choose a severity | |
context "with valid attributes" do | |
it "creates an issue with valid attributes" do | |
Category.create(name: "Bug") | |
Category.create(name: "Feature Request") | |
visit '/issues/new' | |
fill_in "Title", with: "Broken link" | |
fill_in "Description", with: "The sign in link is broken" | |
# Check the checkbox with a label that says 'Is reproducible' | |
check "Is reproducible" | |
save_and_open_page | |
select "Feature Request", from: "Category" | |
choose "Moderate" | |
click_on "Create Issue" | |
expect(page).to have_content "Issue was successfully created" | |
end | |
end | |
context "with invalid attributes" do | |
it "sees errors for invalid attributes" do | |
visit '/issues/new' | |
click_on "Create Issue" | |
expect(page).to have_content "Title can't be blank" | |
expect(page).to have_content "Description can't be blank" | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Failures: | |
1) User creates an issue | |
As a user | |
I want to create an issue | |
So that I can track the progress of the issue | |
with valid attributes creates an issue with valid attributes | |
Failure/Error: select "Feature Request", from: "Category" | |
Capybara::ElementNotFound: | |
Unable to find select box "Category" | |
# ./spec/features/creating_issues_spec.rb:32:in `block (3 levels) in <top (required)>' | |
Finished in 1.22 seconds | |
2 examples, 1 failure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for(@issue) do |f| %> | |
<% if @issue.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@issue.errors.count, "error") %> prohibited this issue from being saved:</h2> | |
<ul> | |
<% @issue.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> | |
</ul> | |
</div> | |
<% end %> | |
<div class="field"> | |
<%= f.label :title %><br> | |
<%= f.text_field :title %> | |
</div> | |
<div class="field"> | |
<%= f.label :description %><br> | |
<%= f.text_area :description %> | |
</div> | |
<div class="field"> | |
<%= f.label :is_reproducible %><br> | |
<%= f.check_box :is_reproducible, checked: true, class: 'reproducible' %> | |
</div> | |
<div class="field"> | |
<%= f.label :category %><br> | |
<%= f.collection_select :category_id, Category.all, :id, :name, include_blank: true %> | |
</div> | |
<div class="field"> | |
<%= f.label :severity %><br> | |
<%- Issue.severities.each do |severity| -%> | |
<%= f.radio_button :severity, severity %> | |
<%= f.label :severity, severity, value: severity %> | |
<%- end -%> | |
</div> | |
<div class="actions"> | |
<%= f.submit %> | |
</div> | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>IssueTracker</title> | |
<link data-turbolinks-track="true" href="/assets/application.css" media="all" rel="stylesheet" /> | |
<script data-turbolinks-track="true" src="/assets/application.js"></script> | |
</head> | |
<body> | |
<h1>New issue</h1> | |
<form accept-charset="UTF-8" action="/issues" class="new_issue" id="new_issue" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /></div> | |
<div class="field"> | |
<label for="issue_title">Title</label><br> | |
<input id="issue_title" name="issue[title]" type="text" /> | |
</div> | |
<div class="field"> | |
<label for="issue_description">Description</label><br> | |
<textarea id="issue_description" name="issue[description]"> | |
</textarea> | |
</div> | |
<div class="field"> | |
<label for="issue_is_reproducible">Is reproducible</label><br> | |
<input name="issue[is_reproducible]" type="hidden" value="0" /><input checked="checked" class="reproducible" id="issue_is_reproducible" name="issue[is_reproducible]" type="checkbox" value="1" /> | |
</div> | |
<div class="field"> | |
<label for="issue_category">Category</label><br> | |
<select id="issue_category_id" name="issue[category_id]"><option value=""></option> | |
<option value="13">Bug</option> | |
<option value="14">Feature Request</option></select> | |
</div> | |
<div class="field"> | |
<label for="issue_severity">Severity</label><br> | |
<input id="issue_severity_low" name="issue[severity]" type="radio" value="Low" /> | |
<label for="issue_severity_low">Low</label> | |
<input id="issue_severity_moderate" name="issue[severity]" type="radio" value="Moderate" /> | |
<label for="issue_severity_moderate">Moderate</label> | |
<input id="issue_severity_high" name="issue[severity]" type="radio" value="High" /> | |
<label for="issue_severity_high">High</label> | |
</div> | |
<div class="actions"> | |
<input name="commit" type="submit" value="Create Issue" /> | |
</div> | |
</form> | |
<a href="/issues">Back</a> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment