Skip to content

Commit aff0f1f

Browse files
committed
Use standard RSpec expect() matchers instead of Wrong
Wrong 0.7.1 raises an exception when loading the `close_to` matcher. Running specs with `bundle exec` tends to fix this, but that feels kinda accidental. You probably still need `bundle exec` if you have multiple versions of any gem (rake, tilt) installed locally. Fixes railsbridge#479
1 parent d30bf80 commit aff0f1f

9 files changed

+32
-53
lines changed

Gemfile

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ gem 'jquery-cdn'
2222
gem 'sprockets'
2323

2424
group :development do
25-
gem "wrong", "~> 0.7.0"
2625
gem "rspec"
2726
gem "rerun"
2827
gem "rake"

Gemfile.lock

-14
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ GEM
5252
nokogiri (1.6.6.2)
5353
mini_portile (~> 0.6.0)
5454
polyglot (0.3.5)
55-
predicated (0.2.6)
5655
rack (1.6.0)
5756
rack-codehighlighter (0.5.0)
5857
nokogiri (>= 1.4.1)
@@ -81,14 +80,8 @@ GEM
8180
diff-lcs (>= 1.2.0, < 2.0)
8281
rspec-support (~> 3.2.0)
8382
rspec-support (3.2.2)
84-
ruby2ruby (2.1.4)
85-
ruby_parser (~> 3.1)
86-
sexp_processor (~> 4.0)
87-
ruby_parser (3.6.6)
88-
sexp_processor (~> 4.1)
8983
rubyzip (1.1.7)
9084
sass (3.4.13)
91-
sexp_processor (4.5.0)
9285
sinatra (1.4.6)
9386
rack (~> 1.4)
9487
rack-protection (~> 1.4)
@@ -115,12 +108,6 @@ GEM
115108
trollop (2.1.2)
116109
tzinfo (1.2.2)
117110
thread_safe (~> 0.1)
118-
wrong (0.7.1)
119-
diff-lcs (~> 1.2.5)
120-
predicated (~> 0.2.6)
121-
ruby2ruby (>= 2.0.1)
122-
ruby_parser (>= 3.0.1)
123-
sexp_processor (>= 4.0)
124111

125112
PLATFORMS
126113
ruby
@@ -150,4 +137,3 @@ DEPENDENCIES
150137
sinatra-contrib (~> 1.4.0)
151138
sprockets
152139
thin
153-
wrong (~> 0.7.0)

app.rb

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
require 'zip'
1010
require 'tmpdir'
1111

12-
#require 'wrong'
13-
#include Wrong::D
14-
1512
here = File.expand_path File.dirname(__FILE__)
1613
lib = File.expand_path "#{here}/lib"
1714
$: << lib

spec/app_deck_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# todo: move to shared module
1010
def get! *args
1111
get *args
12-
assert { last_response.status == 200 }
12+
expect(last_response.status).to eq(200)
1313
end
1414

1515
def app
@@ -45,19 +45,19 @@ def app
4545
it "renders a deck" do
4646
get! "/meals/breakfast"
4747
# rendered_breakfast = Deck::SlideDeck.new(:slides => Deck::Slide.split(@breakfast)).to_pretty # for some reason it's not rendering pretty from the app even though the app uses .to_pretty
48-
assert { last_response.body.include? "Raisin Bran" }
48+
expect(last_response.body).to include("Raisin Bran")
4949
end
5050

5151
# todo: include deck.js source right inside the HTML
5252
it "serves up deck.js and other public assets" do
5353
get! "/deck.js/core/deck.core.js"
54-
assert { last_response.body.include?("Deck JS - deck.core")}
54+
expect(last_response.body).to include("Deck JS - deck.core")
5555

5656
get! "/deck.js/jquery-1.7.2.min.js"
57-
assert { last_response.body.include?("jQuery v1.7.2 jquery.com")}
57+
expect(last_response.body).to include("jQuery v1.7.2 jquery.com")
5858

5959
get! "/assets/application.css"
60-
assert { last_response.body.include?("/* Code ray css */")}
60+
expect(last_response.body).to include("/* Code ray css */")
6161
end
6262
end
6363
end

spec/app_spec.rb

+14-14
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,32 @@ def true_app
3232
def get! *args
3333
get *args
3434
follow_redirect! while last_response.redirect?
35-
assert { last_response.status == 200 }
35+
expect(last_response.status).to eq(200)
3636
end
3737

3838
it "is a sinatra app" do
3939
get '/'
40-
assert { true_app.is_a? InstallFest }
41-
assert { true_app.class.ancestors.include? Sinatra::Application }
40+
expect(true_app).to be_a(InstallFest)
41+
expect(true_app.class.ancestors).to include(Sinatra::Application)
4242
end
4343

4444
it "redirects / to the default site" do
4545
get! "/"
46-
assert { last_request.path == "/docs/" }
46+
expect(last_request.path).to eq("/docs/")
4747
end
4848

4949
it "redirects /site to /site/" do
5050
get! "/installfest"
51-
assert { last_request.path == "/installfest/" }
51+
expect(last_request.path).to eq("/installfest/")
5252
end
5353

5454
it "redirects /site/page/ to /site/page" do
5555
get! "/installfest/linux/"
56-
assert { last_request.path == "/installfest/linux" }
56+
expect(last_request.path).to eq("/installfest/linux")
5757
end
5858

5959
it "has a default site" do
60-
assert { true_app.default_site == "docs" }
60+
expect(true_app.default_site).to eq("docs")
6161
end
6262

6363
describe "settings" do
@@ -68,23 +68,23 @@ def get! *args
6868
describe "learns the locale from" do
6969
it "the locale parameter" do
7070
true_app.params = {locale: 'es'}
71-
assert { true_app.dynamic_locale == 'es' }
71+
expect(true_app.dynamic_locale).to eq('es')
7272
end
7373

7474
it "the l parameter" do
7575
true_app.params = {l: 'es'}
76-
assert { true_app.dynamic_locale == 'es' }
76+
expect(true_app.dynamic_locale).to eq('es')
7777
end
7878

7979
it "the subdomain" do
8080
true_app.request = Rack::Request.new({"HTTP_HOST" => "es.example.com"})
81-
assert { true_app.dynamic_locale == 'es' }
81+
expect(true_app.dynamic_locale).to eq('es')
8282
end
8383

8484
it "the SITE_LOCALE environment var" do
8585
begin
8686
ENV["SITE_LOCALE"] = "es"
87-
assert { true_app.dynamic_locale == 'es' }
87+
expect(true_app.dynamic_locale).to eq('es')
8888
ensure
8989
ENV["SITE_LOCALE"] = nil
9090
end
@@ -94,17 +94,17 @@ def get! *args
9494

9595
it "looks for a site named the same as the host" do
9696
get "/", {}, {"HTTP_HOST" => "docs.example.com"}
97-
assert { last_response.redirect? }
97+
expect(last_response).to be_redirect
9898
follow_redirect! while last_response.redirect?
99-
assert { last_request.path == "/docs/" }
99+
expect(last_request.path).to eq("/docs/")
100100
end
101101

102102
describe "in the 'es' locale" do
103103
it "uses the 'es' subdir as the sites_dir" do
104104
get "/", locale: "es"
105105

106106
es_dir = File.expand_path(File.join(__FILE__, "..", "..", "sites", "es"))
107-
assert { true_app.sites_dir == es_dir }
107+
expect(true_app.sites_dir).to eq(es_dir)
108108
end
109109

110110
end

spec/media_wiki_spec.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
describe "mw2md" do
77
it "converts [[]]" do
8-
assert {
9-
mw2md("[[OS X 10.7 (Lion)]]") == "[OS X 10.7 Lion](os_x_10_7_lion)"
10-
}
8+
expect(mw2md("[[OS X 10.7 (Lion)]]")).to eq("[OS X 10.7 Lion](os_x_10_7_lion)")
119
end
1210
end
1311

spec/site_syntax_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ def app
4141
end
4242

4343
last_response_status = last_response.status
44-
assert { last_response_status == 200 }
44+
expect(last_response_status).to eq(200)
4545

4646
if doc.filename.end_with?('.step')
47-
assert { last_response.body !~ /FUZZY/ }
47+
expect(last_response.body).not_to match(/FUZZY/)
4848
end
4949
end
5050
end

spec/spec_helper.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
$: << "#{top}/lib"
44

55
require "rspec"
6-
require "wrong/adapters/rspec"
76
require "nokogiri"
87
require "files"
98
require 'active_support/core_ext/string/strip'
109

1110
Dir[File.join(top, "spec/support/**/*.rb")].each {|f| require f}
1211

1312
def assert_loosely_equal lhs, rhs
14-
assert { lhs.gsub(/\n\s*/, '') == rhs.gsub(/\n\s*/, '') }
13+
expect(lhs.gsub(/\n\s*/, '')).to eq(rhs.gsub(/\n\s*/, ''))
1514
end
1615

1716
RSpec.configure do |c|

spec/step_spec.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ def step_obj_for(path)
3535
<h1>#{checkbox_html}<span class="prefix">Step 1: </span>hello</h1>
3636
</div>
3737
HTML
38-
assert { html == expected }
38+
expect(html).to eq(expected)
3939
end
4040

4141
it "puts anchors in based on step numbers" do
4242
steps = html_doc.css(".step")
4343
steps.each_with_index do |step, i|
44-
assert { step.previous }
45-
assert { to_html(step.previous) == "<a name=\"step#{i+1}\"></a>" }
44+
expect(step.previous).to be_truthy
45+
expect(to_html(step.previous)).to eq("<a name=\"step#{i+1}\"></a>")
4646
end
4747
end
4848

@@ -53,7 +53,7 @@ def step_obj_for(path)
5353

5454
anchors = html_doc.css("a")
5555
names = anchors.map{|a| a["name"]}
56-
assert { names == %w(step1 happy_step) }
56+
expect(names).to eq(%w(step1 happy_step))
5757
end
5858

5959
it "nests anchor numbers" do
@@ -70,7 +70,7 @@ def step_obj_for(path)
7070

7171
anchors = html_doc.css("a")
7272
names = anchors.map{|a| a["name"]}
73-
assert { names == %w(step1 step1-1 step1-2 step2 step2-1 step2-2) }
73+
expect(names).to eq(%w(step1 step1-1 step1-2 step2 step2-1 step2-2))
7474
end
7575

7676
describe 'link' do
@@ -85,7 +85,7 @@ def step_obj_for(path)
8585
end
8686
RUBY
8787
a = html_doc.css(".step a.link").first
88-
assert { a["href"] == "choose_breakfast" }
88+
expect(a["href"]).to eq("choose_breakfast")
8989
end
9090

9191
it "has an optional parameter for the caption" do
@@ -94,7 +94,7 @@ def step_obj_for(path)
9494
link "breakfast", caption: "Eat some"
9595
end
9696
RUBY
97-
assert { html_doc.css("p.link").text == "Eat some Breakfast" }
97+
expect(html_doc.css("p.link").text).to eq("Eat some Breakfast")
9898
end
9999
end
100100

@@ -103,14 +103,14 @@ def step_obj_for(path)
103103
html_doc(<<-RUBY)
104104
source_code "x = 2"
105105
RUBY
106-
assert { @html == "<pre class=\"code\">x = 2</pre>" }
106+
expect(@html).to eq("<pre class=\"code\">x = 2</pre>")
107107
end
108108

109109
it "emits a block of code with a language directive" do
110110
html_doc(<<-RUBY)
111111
source_code :ruby, "x = 2"
112112
RUBY
113-
assert { @html == "<pre class=\"code\">\n:::ruby\nx = 2</pre>" }
113+
expect(@html).to eq("<pre class=\"code\">\n:::ruby\nx = 2</pre>")
114114
end
115115
end
116116

0 commit comments

Comments
 (0)