Skip to content

Commit e54a48e

Browse files
committed
Increase tests coverage
1 parent 211605c commit e54a48e

16 files changed

+95
-14
lines changed

Diff for: Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ group :development do
4242
end
4343

4444
group :development, :test do
45+
gem 'debugger'
4546
gem 'fabrication'
4647
gem 'rspec-rails'
4748
gem 'capybara'

Diff for: Gemfile.lock

+8
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ GEM
6464
coffee-script-source
6565
execjs
6666
coffee-script-source (1.7.0)
67+
columnize (0.3.6)
6768
coveralls (0.7.0)
6869
multi_json (~> 1.3)
6970
rest-client
@@ -82,6 +83,12 @@ GEM
8283
nokogiri (>= 1.5.0)
8384
rails (>= 3.0.0)
8485
database_cleaner (1.2.0)
86+
debugger (1.6.5)
87+
columnize (>= 0.3.1)
88+
debugger-linecache (~> 1.2.0)
89+
debugger-ruby_core_source (~> 1.3.1)
90+
debugger-linecache (1.2.0)
91+
debugger-ruby_core_source (1.3.2)
8592
devise (2.2.8)
8693
bcrypt-ruby (~> 3.0)
8794
orm_adapter (~> 0.1)
@@ -249,6 +256,7 @@ DEPENDENCIES
249256
coveralls
250257
cucumber-rails
251258
database_cleaner
259+
debugger
252260
devise (~> 2.2.2)
253261
fabrication
254262
faker

Diff for: app/controllers/answers_controller.rb

-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,5 @@ def update
1919
format.html { redirect_to question_url(resource.question) }
2020
end
2121
end
22-
23-
2422
end
2523

Diff for: app/controllers/static_controller.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,17 @@ def download
2323
@other_platforms = ["mac", "windows", "linux"] - [@platform]
2424
end
2525

26-
def api_root; render :layout => "api"; end
26+
def api_root
27+
render :layout => "api"
28+
end
29+
2730
def newest_version
2831
render :json => {:version => "1.0.0"}
2932
end
3033

3134
protected
3235

3336
def platform
34-
if Rails.env.test?
35-
"mac"
36-
else
37-
request.user_agent.match(/Mac|Linux|Windows/).try(:[], 0).try(:downcase)
38-
end
37+
request.user_agent.downcase
3938
end
4039
end

Diff for: features/answers.feature

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
Feature: CRUD actions for answers
22

33
As a user of the site, I can perform standard CRUD actions on answers
4+
5+
Background:
6+
Given "Mac" user agent
47

58
Scenario: Create an answer
6-
Given a question exists
9+
And a question exists
710
And I answer that question
811
Then I should be notified that my answer was submitted
912
And an email should be sent to the author
1013
And I should be able to see my answer
1114
And my answer should show on my profile page
1215

1316
Scenario: Edit an answer
14-
Given a question exists
17+
And a question exists
1518
And I answer that question
1619
When I edit that answer
1720
Then I should see the updated answer

Diff for: features/blog.feature

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
Feature: Hackety Blog
22

33
As an admin, I can post to the hackety blog.
4-
4+
5+
Background:
6+
Given "Mac" user agent
7+
58
Scenario: Read the blog
69
Given a blog post exists
710
When I visit the blog

Diff for: features/lessons.feature

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Feature: Hackety Lessons
2+
3+
As a user of the site, I can visit lessons page
4+
5+
Scenario: View the lessons
6+
When I visit lessons path
7+
Then I should see the list of lessons
8+
9+
Scenario: View specific lesson
10+
When I visit lessons path
11+
When I click on lesson's title
12+
Then I should see lesson content
13+

Diff for: features/moderator.feature

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Feature: Moderate questions
33
As a moderator, I should be able to delete questions from the site.
44

55
Background:
6-
Given there is a question from someone else
6+
Given "Mac" user agent
7+
And there is a question from someone else
78

89
Scenario: Delete a question
910
Given I am a moderator

Diff for: features/programs.feature

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Feature: Access Programs
22

33
As a user of the site, I want to access users' programs
4+
5+
Background:
6+
Given "Mac" user agent
47

58
Scenario: View a featured program
69
Given there is a featured program

Diff for: features/questions.feature

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ Feature: CRUD actions for question
22

33
As a user of the site, I can perform standard CRUD actions on questions
44

5+
Background:
6+
Given "Mac" user agent
7+
58
Scenario: Create a question
69
When I create a new question
710
Then I should be told the question was created

Diff for: features/signup.feature

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Feature: Sign up for an account
22

33
As a new Hackety user, I want to create a new account and log in with it
4+
5+
Background:
6+
Given "Mac" user agent
47

58
Scenario: Create an account via the signup form
69
When I register a new account

Diff for: features/statics.feature

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Feature: Detect user's platform and provide download link
2+
3+
As a fresh Hackety user, I want to download software for my current OS
4+
5+
Scenario: MacOS User
6+
Given "Mac" user agent
7+
Then I should be able to download "mac" software
8+
9+
Scenario: Windows User
10+
Given "Windows" user agent
11+
Then I should be able to download "windows" software
12+
13+
Scenario: Linux User
14+
Given "Linux" user agent
15+
Then I should be able to download "linux" software
16+
17+
Scenario: Android User
18+
Given "android" user agent
19+
Then I should be able to download "android" software

Diff for: features/step_definitions/lesson_steps.rb

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
When(/^I visit lessons path$/) do
2+
visit lessons_path
3+
end
4+
5+
Then(/^I should see the list of lessons$/) do
6+
page.should have_content("Lessons")
7+
page.should have_content("A Tour of Hackety Hack")
8+
end
9+
10+
When(/^I click on lesson's title$/) do
11+
click_link("A Tour of Hackety Hack")
12+
end
13+
14+
Then(/^I should see lesson content$/) do
15+
expect(page).to have_title "A Tour of Hackety Hack"
16+
page.should have_content("Welcome to the Hackety Hack tour!")
17+
end

Diff for: features/step_definitions/static_steps.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Given(/^"(.*?)" user agent$/) do |agent|
2+
page.driver.header('User-Agent', agent)
3+
end
4+
5+
Then(/^I should be able to download "(.*?)" software$/) do |system|
6+
visit download_path
7+
page.should have_content("Version 1.0.1 for #{system}")
8+
end

Diff for: features/support/env.rb

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
require_relative '../../spec/code_coverage'
99

1010
require 'cucumber/rails'
11+
require 'ruby-debug'
1112

1213
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
1314
# order to ease the transition to Capybara we set the default here. If you'd

Diff for: features/users.feature

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ Feature: Manage account
22

33
As a user of this site, I can view and update my profile, see my followers
44

5-
Background: The user is logged in
6-
Given a logged in user
5+
Background:
6+
Given "Mac" user agent
7+
And a logged in user
78

89
Scenario: View my profile
910
When I go to look at my profile page

0 commit comments

Comments
 (0)