diff --git a/Gemfile b/Gemfile index 4bf72113..0e9edb9f 100644 --- a/Gemfile +++ b/Gemfile @@ -42,6 +42,7 @@ group :development do end group :development, :test do + gem 'debugger' gem 'fabrication' gem 'rspec-rails' gem 'capybara' diff --git a/Gemfile.lock b/Gemfile.lock index 3d8a7b9f..43869d85 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,6 +64,7 @@ GEM coffee-script-source execjs coffee-script-source (1.7.0) + columnize (0.3.6) coveralls (0.7.0) multi_json (~> 1.3) rest-client @@ -82,6 +83,12 @@ GEM nokogiri (>= 1.5.0) rails (>= 3.0.0) database_cleaner (1.2.0) + debugger (1.6.5) + columnize (>= 0.3.1) + debugger-linecache (~> 1.2.0) + debugger-ruby_core_source (~> 1.3.1) + debugger-linecache (1.2.0) + debugger-ruby_core_source (1.3.2) devise (2.2.8) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.1) @@ -249,6 +256,7 @@ DEPENDENCIES coveralls cucumber-rails database_cleaner + debugger devise (~> 2.2.2) fabrication faker diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index e9377081..0761042d 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -19,7 +19,5 @@ def update format.html { redirect_to question_url(resource.question) } end end - - end diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index e34ded3e..60acc47c 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -23,7 +23,10 @@ def download @other_platforms = ["mac", "windows", "linux"] - [@platform] end - def api_root; render :layout => "api"; end + def api_root + render :layout => "api" + end + def newest_version render :json => {:version => "1.0.0"} end @@ -31,10 +34,6 @@ def newest_version protected def platform - if Rails.env.test? - "mac" - else - request.user_agent.match(/Mac|Linux|Windows/).try(:[], 0).try(:downcase) - end + request.user_agent.nil? ? nil : request.user_agent.downcase end end diff --git a/features/answers.feature b/features/answers.feature index 600859ff..d647cebe 100644 --- a/features/answers.feature +++ b/features/answers.feature @@ -1,9 +1,9 @@ Feature: CRUD actions for answers As a user of the site, I can perform standard CRUD actions on answers - + Scenario: Create an answer - Given a question exists + And a question exists And I answer that question Then I should be notified that my answer was submitted And an email should be sent to the author @@ -11,7 +11,7 @@ Feature: CRUD actions for answers And my answer should show on my profile page Scenario: Edit an answer - Given a question exists + And a question exists And I answer that question When I edit that answer Then I should see the updated answer diff --git a/features/lessons.feature b/features/lessons.feature new file mode 100644 index 00000000..0f3b92ad --- /dev/null +++ b/features/lessons.feature @@ -0,0 +1,13 @@ +Feature: Hackety Lessons + + As a user of the site, I can visit lessons page + + Scenario: View the lessons + When I visit lessons path + Then I should see the list of lessons + + Scenario: View specific lesson + When I visit lessons path + When I click on lesson's title + Then I should see lesson content + diff --git a/features/programs.feature b/features/programs.feature index 5680b723..f2ead8ec 100644 --- a/features/programs.feature +++ b/features/programs.feature @@ -1,7 +1,7 @@ Feature: Access Programs As a user of the site, I want to access users' programs - + Scenario: View a featured program Given there is a featured program Then I should be able to view a highlighted program diff --git a/features/signup.feature b/features/signup.feature index f1123432..442dd0bd 100644 --- a/features/signup.feature +++ b/features/signup.feature @@ -1,7 +1,7 @@ Feature: Sign up for an account As a new Hackety user, I want to create a new account and log in with it - + Scenario: Create an account via the signup form When I register a new account Then I should be logged in with my new account diff --git a/features/statics.feature b/features/statics.feature new file mode 100644 index 00000000..37294c25 --- /dev/null +++ b/features/statics.feature @@ -0,0 +1,19 @@ +Feature: Detect user's platform and provide download link + + As a fresh Hackety user, I want to download software for my current OS + + Scenario: MacOS User + Given "Mac" user agent + Then I should be able to download "mac" software + + Scenario: Windows User + Given "Windows" user agent + Then I should be able to download "windows" software + + Scenario: Linux User + Given "Linux" user agent + Then I should be able to download "linux" software + + Scenario: Android User + Given "android" user agent + Then I should be able to download "android" software diff --git a/features/step_definitions/lesson_steps.rb b/features/step_definitions/lesson_steps.rb new file mode 100644 index 00000000..d7355def --- /dev/null +++ b/features/step_definitions/lesson_steps.rb @@ -0,0 +1,17 @@ +When(/^I visit lessons path$/) do + visit lessons_path +end + +Then(/^I should see the list of lessons$/) do + page.should have_content("Lessons") + page.should have_content("A Tour of Hackety Hack") +end + +When(/^I click on lesson's title$/) do + click_link("A Tour of Hackety Hack") +end + +Then(/^I should see lesson content$/) do + expect(page).to have_title "A Tour of Hackety Hack" + page.should have_content("Welcome to the Hackety Hack tour!") +end diff --git a/features/step_definitions/static_steps.rb b/features/step_definitions/static_steps.rb new file mode 100644 index 00000000..b09a519a --- /dev/null +++ b/features/step_definitions/static_steps.rb @@ -0,0 +1,8 @@ +Given(/^"(.*?)" user agent$/) do |agent| + page.driver.header('User-Agent', agent) +end + +Then(/^I should be able to download "(.*?)" software$/) do |system| + visit download_path + page.should have_content("Version 1.0.1 for #{system}") +end \ No newline at end of file diff --git a/features/support/env.rb b/features/support/env.rb index ee6880e7..25e027c5 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -8,6 +8,7 @@ require_relative '../../spec/code_coverage' require 'cucumber/rails' +require 'ruby-debug' # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In # order to ease the transition to Capybara we set the default here. If you'd diff --git a/features/users.feature b/features/users.feature index 7dca8ff5..cbe60fdc 100644 --- a/features/users.feature +++ b/features/users.feature @@ -2,7 +2,7 @@ Feature: Manage account As a user of this site, I can view and update my profile, see my followers - Background: The user is logged in + Background: Given a logged in user Scenario: View my profile