Mission and MissionAgent factories

James Peret 10 ans auparavant
Parent
Commettre
f069c3e019
4 fichiers modifiés avec 49 ajouts et 19 suppressions
  1. 24 19
      features/missions_view.feature
  2. 8 0
      features/step_definitions/mission_steps.rb
  3. 3 0
      features/support/paths.rb
  4. 14 0
      spec/factories.rb

+ 24 - 19
features/missions_view.feature

@@ -1,19 +1,24 @@
1
-# @mission_view
2
-# Feature: Missions
3
-# 	In order to browse for missions
4
-# 	As an Avalanche Agent
5
-# 	I want to view missions and agent roles
6
-#
7
-# 	Background:
8
-# 	Given the website is configured
9
-# 	And the following list of missions
10
-# 	| title       | objective              | briefing            | slug        |
11
-# 	| Hello World | Welcome to the website | First Post          | hello_world |
12
-# 	| Test 001    | 1 2 3 testing          | Testing the website | test_001    |
13
-#
14
-# 	Scenario: View mission list
15
-# 		When I go to the missions page
16
-# 		Then I should see "Hello World"
17
-# 		And I should see "First Post"
18
-# 		And I should see "Test 001"
19
-# 		And I should see "Testing the website"
1
+@mission_view
2
+Feature: Missions
3
+	In order to browse for missions
4
+	As an Avalanche Agent
5
+	I want to view missions and agent roles
6
+
7
+	Background:
8
+	Given the website is configured
9
+	And the following list of missions
10
+	| title        | objective                  | briefing                                                        | slug        | status |
11
+	| Bank Robbery | Rob a bank and get rich    | The target will be Fort Knox. Only expert agents allowed.       | hello_world | 1      |
12
+	| Test 001     | 1 2 3 testing              | Testing the website                                             | test_001    | 1      |
13
+	And the the mission "Bank Robbery" has the following agents
14
+	| role         | objective                  | briefing                                                        | description |
15
+	| Mr. Pink     | Get the money in the vault | Find the manager, make him open the vault and get all the money |             | 
16
+	| Mr. Blue     | Take care of the hostages  | Make sure the hostages dont try anything stupid.                |             | 
17
+	| Mr. Green    | Drive the gettaway car     | Wait for the others to return and lose the cops.                |             | 
18
+
19
+	Scenario: View mission list
20
+		When I go to the missions page
21
+		Then I should see "Bank Robbery"
22
+		And I should see "Rob a bank and get rich"
23
+		And I should see "Test 001"
24
+		And I should see "1 2 3 testing"

+ 8 - 0
features/step_definitions/mission_steps.rb

@@ -5,4 +5,12 @@ Given(/^the following list of missions$/) do |table|
5 5
     mission.owner = user
6 6
     mission.save
7 7
   end
8
+end
9
+
10
+Given(/^the the mission "(.*?)" has the following agents$/) do |arg1, table|
11
+  mission = Mission.where(title: arg1)
12
+  table.hashes.each do |hash| 
13
+    agent = FactoryGirl.create("mission_agent", hash)
14
+    agent.update(mission_id: mission)
15
+  end
8 16
 end

+ 3 - 0
features/support/paths.rb

@@ -37,6 +37,9 @@ module NavigationHelpers
37 37
     when/the subscribers page/
38 38
       visit admin_subscribers_path
39 39
       
40
+    when/the missions page/
41
+      visit missions_path
42
+      
40 43
     else
41 44
       raise "Can't find mapping from \"#{page_name}\" to a path."
42 45
     end

+ 14 - 0
spec/factories.rb

@@ -42,5 +42,19 @@ FactoryGirl.define do
42 42
     f.email "foobar@website.com"
43 43
   end 
44 44
   
45
+  factory :mission do |f|
46
+    f.title     "Test #1505"
47
+    f.slug      "test_1505"
48
+    f.objective "Test the avalanche network system for possible error."
49
+    f.briefing  "Iterate thru all tests to check the system for possible errors or bugs."
50
+  end
51
+  
52
+  factory :mission_agent do |f|
53
+    f.role        "Mr. White"
54
+    f.objective   "Complete this mission"
55
+    f.briefing    "Just do everything marked in here."
56
+    f.description ""
57
+  end
58
+  
45 59
 end  
46 60