@@ -1263,39 +1263,43 @@ def extract_execution_results(group)
12631263 end
12641264 end
12651265
1266- describe "example doc string" do
1267- let ( :group ) { RSpec . describe }
1268-
1269- it "accepts a string for an example doc string" do
1270- expect { group . it ( 'MyClass' ) { } } . not_to output . to_stderr
1271- end
1266+ describe "example doc string and metadata " do
1267+ context "when first argument of example is a string" do
1268+ it "returns the string as description" do
1269+ example = RSpec . describe . it ( "my example" )
1270+ expect ( example . metadata [ :description ] ) . to eq ( "my example" )
1271+ end
12721272
1273- it "accepts example without a doc string" do
1274- expect { group . it { } } . not_to output . to_stderr
1275- end
1273+ it "returns the string as description and symbol is set in metadata" do
1274+ example = RSpec . describe . it ( "my example" , :foo )
1275+ expect ( example . metadata [ :description ] ) . to eq ( "my example" )
1276+ expect ( example . metadata [ :foo ] ) . to be_truthy
1277+ end
12761278
1277- it "emits a warning when a Class is used as an example doc string" do
1278- expect { group . it ( Numeric ) { } }
1279- . to output ( /`Numeric` is used as example doc string. Use a string instead/ )
1280- . to_stderr
1279+ it "returns the string as description and hash is set in metadata" do
1280+ example = RSpec . describe . it ( "my example" , { "foo" => "bar" } )
1281+ expect ( example . metadata [ :description ] ) . to eq ( "my example" )
1282+ expect ( example . metadata [ "foo" ] ) . to eq ( "bar" )
1283+ end
12811284 end
12821285
1283- it "emits a warning when a Module is used as an example doc string" do
1284- expect { group . it ( RSpec ) { } }
1285- . to output ( /`RSpec` is used as example doc string. Use a string instead/ )
1286- . to_stderr
1287- end
1286+ context "when first argument of example is NOT a string" do
1287+ it "returns empty string as description" do
1288+ example = RSpec . describe . it
1289+ expect ( example . metadata [ :description ] ) . to be_empty
1290+ end
12881291
1289- it "emits a warning when a Symbol is used as an example doc string " do
1290- expect { group . it ( :foo ) { } }
1291- . to output ( /`:foo` is used as example doc string. Use a string instead/ )
1292- . to_stderr
1293- end
1292+ it "returns empty string as description and symbol is set in metadata " do
1293+ example = RSpec . describe . it ( :foo )
1294+ expect ( example . metadata [ :description ] ) . to be_empty
1295+ expect ( example . metadata [ :foo ] ) . to be_truthy
1296+ end
12941297
1295- it "emits a warning when a Hash is used as an example doc string" do
1296- expect { group . it ( foo : :bar ) { } }
1297- . to output ( /`{:foo=>:bar}` is used as example doc string. Use a string instead/ )
1298- . to_stderr
1298+ it "returns empty string as description and hash is set in metadata" do
1299+ example = RSpec . describe . it ( { "foo" => "bar" } )
1300+ expect ( example . metadata [ :description ] ) . to be_empty
1301+ expect ( example . metadata [ "foo" ] ) . to eq ( "bar" )
1302+ end
12991303 end
13001304 end
13011305
0 commit comments