You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sites/en/testing/types_of_tests.step
+9-9
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ steps do
20
20
message "First, create a orange model. By creating the model, a spec file will also be added to the models folder of the spec folder. Type this in the terminal:"
21
21
22
22
console_without_message "rails g model Orange"
23
-
23
+
24
24
message "Then, run the migration to actually create the oranges table."
message "You should see some report but no tests exist yet. So, let's add one! Copy the below test, paste it into the orange model spec file and then run 'bundle exec rspec' on the terminal again."
34
34
35
35
console_without_message <<-RUBY
36
-
Rspec.describe Orange, :type => :model do
36
+
RSpec.describe Orange, :type => :model do
37
37
context 'ActiveRecord associations' do
38
38
it 'Orange belongs to tree' do
39
39
expect(Orange.reflect_on_association(:tree).macro).to be (:belongs_to)
40
40
end
41
-
end
41
+
end
42
42
end
43
43
RUBY
44
44
@@ -66,13 +66,13 @@ steps do
66
66
message "You should see a report with some passing tests but those are just the model tests you wrote. So, let's add some controller tests! Copy the below test, paste it into the oranges controller spec file, create the relevant view files and then run 'bundle exec rspec' on the terminal again."
67
67
68
68
console_without_message <<-RUBY
69
-
Rspec.describe OrangesController do
69
+
RSpec.describe OrangesController do
70
70
context '#index' do
71
71
it "renders the index view" do
72
72
get :index
73
73
expect(response).to render_template("index")
74
74
end
75
-
75
+
76
76
it "renders html" do
77
77
process :index, method: :get
78
78
expect(response.content_type).to eq "text/html"
@@ -82,7 +82,7 @@ steps do
82
82
RUBY
83
83
84
84
message "Great, that test should be passing! That's an example of a controller test on the index action. Let's modify that test to fail. Then, run 'bundle exec rspec' and see what happens. Awesome! Let's revert back to the passing test. Now, write another controller test for the new action (hint: you might need to look up what a mock is)."
85
-
85
+
86
86
message "Note: as you write the controller tests, you may be prompted to install a missing gem called 'rails-controller-testing' to use the assert_template method. If prompted, please add it and do a bundle install!"
87
87
end
88
88
end
@@ -134,10 +134,10 @@ MARKDOWN
134
134
img src: "img/rails-test-types.png", alt: "Thoughtbot's diagram of types of Rails tests"
135
135
136
136
message <<-MARKDOWN
137
-
Capybara is a common framework used to write integration tests in Rails. It integrates nicely with RSpec such that you can use the same kind of test language to write integration tests.
138
-
137
+
Capybara is a common framework used to write integration tests in Rails. It integrates nicely with RSpec such that you can use the same kind of test language to write integration tests.
138
+
139
139
As an added bonus for this section, write an integration test :)
140
-
140
+
141
141
Use the following link to get started: https://www.sitepoint.com/basics-capybara-improving-tests/
0 commit comments