Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes --webrat #850

Merged
merged 2 commits into from
Nov 22, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Bug fixes

* Use `__send__` rather than `send` to prevent naming collisions (Bradley Schaefer)

Breaking Changes for 3.0.0:

* Removes the `--webrat` option for the request spec generator (Andy Lindeman)

### 3.0.0.beta1 / 2013-11-07
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.99.0.beta1...v3.0.0.beta1)

Expand Down
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,24 @@ FactoryGirl and Capybara seem to be the most widely used. Whether you choose
these or other libs, we strongly recommend using something for each of these
roles.

# View specs
## <a id="feature-specs"></a>Feature Specs

Feature specs live in spec/features, and mix in functionality from the
capybara gem.

Feature specs test your application from the outside by simulating a browser.
capybara is used to manage the simulated browser.

To use feature specs, add `capybara` to `Gemfile`:

```ruby
gem "capybara"
```

For more information, see the [cucumber scenarios for feature
specs](https://www.relishapp.com/rspec/rspec-rails/v/3-0/docs/feature-specs/feature-spec).

## View specs

View specs live in spec/views, and mix in ActionView::TestCase::Behavior.

Expand Down Expand Up @@ -417,21 +434,6 @@ However, you must first clear the task that rspec-rails defined:
task("spec").clear
```

### Webrat and Capybara

You can choose between webrat or capybara for simulating a browser, automating
a browser, or setting expectations using the matchers they supply. Just add
your preference to the Gemfile:

```ruby
gem "webrat"
# ... or ...
gem "capybara"
```

See [http://rubydoc.info/gems/rspec-rails/file/Capybara.md](http://rubydoc.info/gems/rspec-rails/file/Capybara.md)
for more info on Capybara integration.

# Contribute

See [http://github.com/rspec/rspec-dev](http://github.com/rspec/rspec-dev).
Expand Down
22 changes: 7 additions & 15 deletions features/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
rspec-rails extends Rails' built-in testing framework to support rspec examples
for requests, controllers, models, views, helpers, mailers and routing.
rspec-rails extends Rails' built-in testing framework to support rspec
examples for requests, controllers, models, views, helpers, mailers and
routing.

## Rails-3
## Rails

rspec-rails-2 supports rails-3.0.0 and later. For earlier versions of Rails,
you need [rspec-rails-1.3](http://rspec.info).
rspec-rails 3 supports Rails 3.x and 4.x. For earlier versions of Rails, you
need [rspec-rails 1](https://github.com/dchelimsky/rspec-rails).

## Install

Expand All @@ -23,7 +24,7 @@ This installs the following gems:
Add rspec-rails to the :test and :development groups in the Gemfile:

group :test, :development do
gem "rspec-rails", "~> 2.4"
gem "rspec-rails", "~> 2.14"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not reflect one of the 3.x builds? Given that this is a 3.x build?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Will update this in master, thanks.

end

It needs to be in the :development group to expose generators and rake tasks
Expand All @@ -36,15 +37,6 @@ Now you can run:
This adds the spec directory and some skeleton files, including a .rspec
file.

## Webrat and Capybara

You can choose between webrat or capybara for simulating a browser, automating
a browser, or setting expectations using the matchers they supply. Just add
your preference to the Gemfile:

gem "webrat"
gem "capybara"

## Issues

The documentation for rspec-rails is a work in progress. We'll be adding
Expand Down
11 changes: 0 additions & 11 deletions lib/generators/rspec/integration/integration_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,13 @@ module Rspec
module Generators
class IntegrationGenerator < Base
class_option :request_specs, :type => :boolean, :default => true, :desc => "Generate request specs"
class_option :webrat, :type => :boolean, :default => false, :desc => "Use webrat methods/matchers"
class_option :webrat_matchers, :type => :boolean, :default => false, :desc => "Use webrat methods/matchers (deprecated - use --webrat)"

def generate_request_spec
return unless options[:request_specs]

template 'request_spec.rb',
File.join('spec/requests', class_path, "#{table_name}_spec.rb")
end

protected

# @deprecated Use `--webrat` instead.
def webrat?
RSpec.deprecate("the --webrat-matchers option", :replacement => "--webrat") if options[:webrat_matchers]
options[:webrat] || options[:webrat_matchers]
end

end
end
end
5 changes: 0 additions & 5 deletions lib/generators/rspec/integration/templates/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
describe "<%= class_name.pluralize %>" do
describe "GET /<%= table_name %>" do
it "works! (now write some real specs)" do
<% if webrat? -%>
visit <%= index_helper %>_path
<% else -%>
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
get <%= index_helper %>_path
<% end -%>
expect(response.status).to be(200)
end
end
Expand Down
8 changes: 0 additions & 8 deletions lib/generators/rspec/scaffold/scaffold_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class ScaffoldGenerator < Base

class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs"
class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs"
class_option :webrat, :type => :boolean, :default => false, :desc => "Use webrat methods/matchers"
class_option :webrat_matchers, :type => :boolean, :default => false, :desc => "Use webrat methods/matchers (deprecated - use --webrat)"
class_option :helper_specs, :type => :boolean, :default => true, :desc => "Generate helper specs"
class_option :routing_specs, :type => :boolean, :default => true, :desc => "Generate routing specs"

Expand Down Expand Up @@ -46,12 +44,6 @@ def generate_routing_spec

protected

# @deprecated Use `--webrat` instead.
def webrat?
RSpec.deprecate("--webrat-matchers", :replacement => "--webrat") if options[:webrat_matchers]
options[:webrat] || options[:webrat_matchers]
end

def copy_view(view)
template "#{view}_spec.rb",
File.join("spec/views", controller_file_path, "#{view}.html.#{options[:template_engine]}_spec.rb")
Expand Down
9 changes: 0 additions & 9 deletions lib/generators/rspec/scaffold/templates/edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,10 @@
it "renders the edit <%= ns_file_name %> form" do
render

<% if webrat? -%>
expect(rendered).to have_selector("form", :action => <%= ns_file_name %>_path(@<%= ns_file_name %>), :method => "post") do |form|
<% for attribute in output_attributes -%>
expect(form).to have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
<% end -%>
end
<% else -%>
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form[action=?][method=?]", <%= ns_file_name %>_path(@<%= ns_file_name %>), "post" do
<% for attribute in output_attributes -%>
assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>[name=?]", "<%= ns_file_name %>[<%= attribute.name %>]"
<% end -%>
end
<% end -%>
end
end
7 changes: 0 additions & 7 deletions lib/generators/rspec/scaffold/templates/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,8 @@

it "renders a list of <%= ns_table_name %>" do
render
<% unless webrat? -%>
# Run the generator again with the --webrat flag if you want to use webrat matchers
<% end -%>
<% for attribute in output_attributes -%>
<% if webrat? -%>
expect(rendered).to have_selector("tr>td", :content => <%= value_for(attribute) %>.to_s, :count => 2)
<% else -%>
assert_select "tr>td", :text => <%= value_for(attribute) %>.to_s, :count => 2
<% end -%>
<% end -%>
end
end
9 changes: 0 additions & 9 deletions lib/generators/rspec/scaffold/templates/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,10 @@
it "renders new <%= ns_file_name %> form" do
render

<% if webrat? -%>
expect(rendered).to have_selector("form", :action => <%= table_name %>_path, :method => "post") do |form|
<% for attribute in output_attributes -%>
expect(form).to have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
<% end -%>
end
<% else -%>
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form[action=?][method=?]", <%= index_helper %>_path, "post" do
<% for attribute in output_attributes -%>
assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>[name=?]", "<%= ns_file_name %>[<%= attribute.name %>]"
<% end -%>
end
<% end -%>
end
end
7 changes: 0 additions & 7 deletions lib/generators/rspec/scaffold/templates/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,8 @@

it "renders attributes in <p>" do
render
<% unless webrat? -%>
# Run the generator again with the --webrat flag if you want to use webrat matchers
<% end -%>
<% for attribute in output_attributes -%>
<% if webrat? -%>
expect(rendered).to contain(<%= value_for(attribute) %>.to_s)
<% else -%>
expect(rendered).to match(/<%= eval(value_for(attribute)) %>/)
<% end -%>
<% end -%>
end
end
1 change: 0 additions & 1 deletion lib/rspec/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@
require 'rspec/rails/mocks'
require 'rspec/rails/example'
require 'rspec/rails/vendor/capybara'
require 'rspec/rails/vendor/webrat'
26 changes: 7 additions & 19 deletions spec/generators/rspec/integration/integration_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,13 @@
end

describe 'are generated' do
describe 'without webrat matchers by default' do
before do
run_generator %w(posts)
end
subject { file('spec/requests/posts_spec.rb') }
it { should exist }
it { should contain(/require 'spec_helper'/) }
it { should contain(/describe "GET \/posts"/) }
it { should contain(/get posts_index_path/) }
end
describe 'with webrat matchers' do
before do
run_generator %w(posts --webrat)
end
subject { file('spec/requests/posts_spec.rb') }
it { should exist }
it { should contain(/require 'spec_helper'/) }
it { should contain(/describe "GET \/posts"/) }
it { should contain(/visit posts_index_path/) }
before do
run_generator %w(posts)
end
subject { file('spec/requests/posts_spec.rb') }
it { should exist }
it { should contain(/require 'spec_helper'/) }
it { should contain(/describe "GET \/posts"/) }
it { should contain(/get posts_index_path/) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth updating the style of these specs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth leveraging rspec/rspec-core#1180

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely, I'll file a separate issue.

end
end